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

    rich:scrollableDataTable selection doesn't work.

      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:



           <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 ??





        • 1. Re: rich:scrollableDataTable selection doesn't work.
          admin.admin.email.tld

          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:

          value="#{custodianAccountList.searchedPortfolios}"


          can be changed to this:
          value="#{searchedPortfolios}"



          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).

          • 2. Re: rich:scrollableDataTable selection doesn't work.

            Worked, Thanks