2 Replies Latest reply on Jun 23, 2009 2:20 AM by Nagendra krishnawat

    rich:scrollableDataTable selection doesn't work.

    Nagendra krishnawat Newbie

      Firstly 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:

                <h:panelGrid columns="2" id="searchGrid" styleClass="gridStyle" border="0">
                     <s:decorate id="nameDecoration"
                          <ui:define name="label">Portfolio Name</ui:define>
                          <h:inputText id="portfolioName" size="15" value="#{custodianAccountList.name}" />
                     <a:commandButton id="search" value="Search" action="#{custodianAccountList.getSearchedPortfolios}"  reRender="portfolioListId"/>
                 <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}" />
            <h:commandButton action="#{custodianAccountList.takeSelection}" value="Click me ! " />

      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
      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() {
              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() {
                return null;
           List<CustodianAccount> searchedPortfolios;
           public List<CustodianAccount> getSearchedPortfolios(){
                if(name==null) return null;
                searchedPortfolios = getEntityManager().createQuery(ArmConstant.getUpdatePortfolioResultListQuery(name)).getResultList();
                return searchedPortfolios;
           private void selectedRows(List<String[]> 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 ??

        • 1. Re: rich:scrollableDataTable selection doesn't work.
          System Administrator Expert

          since you are outjecting the context variable using @DataModel, use this:

          public void getSearchedPortfolios(){...}

          Also, try adding a breakpoint in your debugger and seeing what the value of the searchedPortfolios is in that method.

          Also, this:


          can be changed to this:

          The former is a method call and the latter is the context variable that was outjected to (in this case and this may be your problem, or part of it) EVENT scope which is the default for POJO/JavaBean.

          You need to add: @Scope(ScopeType.CONVERSATION) at the class level and probably promote a temporary conversation to long-running (LRC) via @Begin somewhere, like on the getSearchedPortfolios() method .  Or add @Stateful and implement a local interface to convert this POJO into a SFSB which is conversation-scoped by default (don't forget to add a @Remove method, it's required for SFSBs).