3 Replies Latest reply on Oct 25, 2009 8:10 PM by Florian Gessner

    extendedDataList: selection not working

    Florian Gessner Newbie

      Hi,


      I try to create a UI which contains a extendedDataList with a detail screen below. When the user selects a table row, the information of this table row should be visible below the table.


      The UI is implemented as follows:


      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
           xmlns:s="http://jboss.com/products/seam/taglib"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:rich="http://richfaces.org/rich"
           template="../../layout/template.xhtml"
           xmlns:a4j="http://richfaces.org/a4j">
      
           <ui:define name="content">
      
                <h1>User Management</h1>
      
                <rich:panel>
                     <f:facet name="header">
                          <h:outputText value="User List:" />
                     </f:facet>
                     <rich:toolBar height="18px" itemSeparator="line">
                          <rich:toolBarGroup>
                               <h:commandButton action="newUser.xhtml" value="Create User" alt="create a new user" />
                               <h:commandButton action="editUser.xhtml" value="Edit User" alt="edit selected user" />
                          </rich:toolBarGroup>
                     </rich:toolBar>
                     <rich:extendedDataTable id="userList" var="user" value="#{users}" rendered="#{not empty users}" sortMode="single"
                          selectionMode="single" selection="#{userList.selection}" rows="10" width="100%">
                          <rich:column label="Id" sortable="true" sortBy="#{user.userId}">
                               <f:facet name="header">
                                    <h:outputText value="Id" />
                               </f:facet>
                               <h:outputText value="#{user.userId}" />
                          </rich:column>
                          <rich:column label="Username" sortable="true" sortBy="#{user.username}">
                               <f:facet name="header">
                                    <h:outputText value="Username" />
                               </f:facet>
                               <h:outputText value="#{user.username}" />
                          </rich:column>
                          <rich:column label="Firstname" sortable="true" sortBy="#{user.firstname}">
                               <f:facet name="header">
                                    <h:outputText value="Firstname" />
                               </f:facet>
                               <h:outputText value="#{user.firstname}" />
                          </rich:column>
                          <rich:column label="Lastname" sortable="true" sortBy="#{user.lastname}">
                               <f:facet name="header">
                                    <h:outputText value="Lastname" />
                               </f:facet>
                               <h:outputText value="#{user.lastname}" />
                          </rich:column>
                          <rich:column label="Active" sortable="true" sortBy="#{user.enabled}">
                               <f:facet name="header">
                                    <h:outputText value="Active" />
                               </f:facet>
                               <h:selectBooleanCheckbox id="Active" title="Active" value="#{user.enabled}" disabled="true" readonly="true" />
                          </rich:column>
                          <rich:column label="Technical User" sortable="true" sortBy="#{user.technicalUser}">
                               <f:facet name="header">
                                    <h:outputText value="Technical User" />
                               </f:facet>
                               <h:selectBooleanCheckbox id="technicalUser" title="technicalUser" value="#{user.technicalUser}" readonly="true" disabled="true" />
                          </rich:column>
                          <a4j:support reRender="userDetails" action="#{userList.onSelect}" event="onSelectionChange" />
                     </rich:extendedDataTable>
                </rich:panel>
                <rich:panel id="userDetails">
                     <f:facet name="header">
                          <h:outputText value="User Details:" />
                     </f:facet>
                     <h:panelGrid columns="2">
                          <h:outputLabel value="Username:" for="username"     style="font-weight:bold" />
                          <h:outputText id="username" value="#{userList.selectedUser.username}" />
                     </h:panelGrid>
                </rich:panel>
           </ui:define>
      </ui:composition>




      The Backend Bean coding:


      @Stateful
      @Name("userList")
      @Scope(ScopeType.CONVERSATION)
      public class UserListCBean implements UserListCLocal {
          @EJB
          UserManagerLocal userManager;
      
          @DataModel
          private List<User> users;
      
          @DataModelSelection("users")
          private User selectedUser;
      
          private SimpleSelection selection;
          
          @Logger
          Log log;
      
          @Factory("users")
          public void queryUserList() {
           users = userManager.getAllUsers();
          }
      
          public User getSelectedUser() {
           return selectedUser;
          }
      
          public void setSelectedUser(User selectedUser) {
           this.selectedUser = selectedUser;
          }
      
          public void onSelect() {
           log.info("Out", "Out");
           
           if (getSelection() != null && getSelection().getKeys() != null) {
               Iterator<Object> iterator = getSelection().getKeys();
               while (iterator.hasNext()) {
                Object key = iterator.next();          
                Integer i = (Integer) key;
                selectedUser = users.get(i);
               }
           }
          }
      
          public List<User> getUsers() {
           return users;
          }
      
          public void setUsers(List<User> users) {
           this.users = users;
          }
      
          public SimpleSelection getSelection() {
           return selection;
          }
      
          public void setSelection(SimpleSelection selection) {
           this.selection = selection;
          }
      
          @Destroy
          @Remove
          public void destroy() {}
      }



      and also the Local interface of the backend bean.


      @Local
      public interface UserListCLocal {
          public void destroy();
          public void queryUserList();
          public User getSelectedUser();
          public void setSelectedUser(User selectedUser);
          public void onSelect();
          public List<User> getUsers();
          public void setUsers(List<User> users);
          public SimpleSelection getSelection();
          public void setSelection(SimpleSelection selection);
      }




      I assume that the a4j action is not executed.
      I user Seam 2.1.2 with JBoss AS 5.0.1.


      Thanks for you help!!


      Best Regards
      Florian