i need check box component within each dataTale rows.
I need to display what are all the rows to be selected at the time of show Rows command button clicked
This is my xhtml sample code
<a4j:form id="form" reRender="table-body" ajaxSubmit="true" ignoreDupResponses="true" requestDelay="500">
<a4j:region id="stat1">
<a4j:outputPanel id="table-body">
<rich:dataTable id="prodList" rows="10" value="#{productlist}" var="product">
<f:facet name="header">
<rich:columnGroup>
<h:column>
<h:outputText value="Select" />
</h:column>
<h:column>
<h:outputText value="Model" />
</h:column>
</rich:columnGroup>
</f:facet>
<h:column>
<h:selectBooleanCheckbox value="#{searchSelections[product]}"/>
</h:column>
<h:column>
<h:outputText value="#{product.productName}" />
</h:column>
</rich:dataTable>
<rich:datascroller for="prodList" maxPages="10" />
<h:commandButton value="Show Rows" action="#{productsearch.showRows}"/>
</a4j:outputPanel>
</a4j:region>
</a4j:form>
@Stateful
@Name("productsearch")
public class ProductsAction implements ProductsLocal,Serializable
{
@PersistenceContext
EntityManager em;
@Out(scope=ScopeType.CONVERSATION,required=false)
Map<TblProducts, Boolean> searchSelections;
@Out(required=false)
static List<TblProducts> productlist;
@Begin(join=true)
public String init() {
productlist =em.createQuery("select t from TblProducts t").getResultList();
searchSelections=new HashMap<TblProducts, Boolean> ()
}
public String showRows() {
for (TblProducts item: productlist)
{
Boolean selected = searchSelections.get(item);
if (selected!=null && selected)
System.out.println("Selected row is :"+ item.getProductName());
}
}
}