2 Replies Latest reply on Mar 26, 2007 6:40 AM by knuwu

    Selectable linklist without <h:dataTable>

    knuwu Newbie

      I have a List of items stored in a session bean and i've created a link list on the page. When I click on the link, I want to transfer the underlying item to the action methode.

      I used enhanced EL for that purpose, but the parameter of methode selectModule() is always 'null'.

      <div id="configList">
       <ul>
       <c:forEach var="module" items="#{configSelector.moduleList}">
       <li><s:link value="#{module.name}"
       action="#{configSelector.selectModule(module)}"/></li>
       </c:forEach>
       </ul>
      </div>
      


      @Stateful
      @Name("configSelector")
      @Scope(ScopeType.SESSION)
      public class ConfigurationSelectorImpl implements ConfigurationSelector {
      
       @Logger private Log log;
      
       private ArrayList<Module> moduleList = new ArrayList<Module>();
      
       @Out(required=false)
       private Module selectedModule;
      
       @SuppressWarnings("unused")
       @Create
       public void initModuleList() {
       moduleList.add(AdminModule.getInstance());
       }
      
       public ArrayList<Module> getModuleList () {
       return this.moduleList;
       }
      
       public void selectModule(Module pModule) {
       this.selectedModule = pModule;
       log.info("#0 selected", this.selectedModule.getName());
       }
      
       @Destroy @Remove
       public void destroy() {}
      
      }
      


      I can't use <h:dataTable> because I do not want to render the list in a table.

      I'm surely missing something. Please help

        • 1. Re: Selectable linklist without <h:dataTable>
          Gavin King Master

          It must be a DataModel, not a plain List.

          • 2. Re: Selectable linklist without <h:dataTable>
            knuwu Newbie

            I changed the list to DataModel using DataModel Annotation:

            @Stateful
            @Name("configSelector")
            @Scope(ScopeType.SESSION)
            public class ConfigurationSelectorImpl implements ConfigurationSelector {
            
             @Logger private Log log;
            
             @DataModel
             private ArrayList<Module> moduleList = new ArrayList<Module>();
            
             @DataModelSelection
             @Out(required=false)
             private Module selectedModule;
            
             @SuppressWarnings("unused")
             @Create
             public void initModuleList() {
             moduleList.add(AdminModule.getInstance());
             moduleList.add(TestModule.getInstance());
             }
            
             public ArrayList<Module> getModuleList () {
             return this.moduleList;
             }
            
             public void selectModule(Module pModule) {
             this.selectedModule = pModule;
             log.info("#0 selected", this.selectedModule.getName());
             }
            
             @Destroy @Remove
             public void destroy() {}
            
            }


            The first entry of the DataModel is automatically stored in variable selectedModule (DataModelSelection annotated). This is not may prefered behavior but would be acceptable if there's no other possiblity.

            Unfortunatly the parameter pModule is still null in Methode selectModule() when I click another link in the list. The variable selected Module still points to the first list element.

            Any idea?