rich:scrollableDataTable selection doesn't work.
nagendra_singh_krishnawat Jun 23, 2009 1:25 AMFirstly there is no backend code for any component examples/demo on seam website. I am trying to make scrollableDataTable selection work. Here is my code:
<a:form>
<h:panelGrid columns="2" id="searchGrid" styleClass="gridStyle" border="0">
<s:decorate id="nameDecoration"
template="../layout/edit.xhtml">
<ui:define name="label">Portfolio Name</ui:define>
<h:inputText id="portfolioName" size="15" value="#{custodianAccountList.name}" />
</s:decorate>
<a:commandButton id="search" value="Search" action="#{custodianAccountList.getSearchedPortfolios}" reRender="portfolioListId"/>
</h:panelGrid>
<rich:spacer height="30"/>
<rich:scrollableDataTable height="400px" width="100%"
id="portfolioListId" rows="40" selectionMode="multi" rowKeyVar="rkv"
value="#{custodianAccountList.searchedPortfolios}" var="costodianAccounttab" sortMode="single" selection="#{custodianAccountList.selection}">
<rich:column id="make">
<f:facet name="header"><h:outputText styleClass="headerText" value="Id" /></f:facet>
<h:outputText value="#{costodianAccounttab.id}" />
</rich:column>
</rich:scrollableDataTable>
<h:commandButton action="#{custodianAccountList.takeSelection}" value="Click me ! " />
</a:form> Here is the backing bean code
package com.myfirm.party.action;
import java.util.List;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.framework.EntityQuery;
import org.richfaces.model.selection.Selection;
import com.myfirm.portfolio.CustodianAccount;
import com.myfirm.portfolio.action.ArmConstant;
/**
* @author NKrishnawat
*
*/
@Name("custodianAccountList")
public class CustodianAccountList extends EntityQuery<CustodianAccount>{
private static final String EJBQL = "select t.id, t.name,t.primary_account_number, t.cca, t.lending_agent,t.data_source from custodian_account t";
public CustodianAccountList() {
setEjbql(EJBQL);
setMaxResults(new Integer(ArmConstant.MAX_QUERY_RESULTS_CONSTANT));
}
private Selection selection;
public Selection getSelection() {
return selection;
}
public void setSelection(Selection selection) {
this.selection = selection;
}
public String takeSelection() {
System.out.println(getSelection());
return null;
}
@DataModel
List<CustodianAccount> searchedPortfolios;
@SuppressWarnings("unchecked")
public List<CustodianAccount> getSearchedPortfolios(){
if(name==null) return null;
searchedPortfolios = getEntityManager().createQuery(ArmConstant.getUpdatePortfolioResultListQuery(name)).getResultList();
return searchedPortfolios;
}
@SuppressWarnings("unused")
private void selectedRows(List<String[]> str){
System.out.println(str);
}
private int portfolioNumber;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPortfolioNumber() {
return portfolioNumber;
}
public void setPortfolioNumber(int portfolioNumber) {
this.portfolioNumber = portfolioNumber;
}
public void search(){
}
}
But when I click on the button I don't get any selection, am I doing anything fundamentally wrong ??