6 Replies Latest reply on Feb 10, 2009 12:06 PM by sebo sebo

    How to send some data from DataTable to TabPanel

    sebo sebo Newbie

      Hi,
      I'm not able to send some data from datatable to tabpanel with rich:componentControl. I was googling all evening :) but no luck. I try to do something like this: when user click on table row ModalPanel appears with tabpanel inside with rows having user data like email, login and etc. but i can't receive data after onRowClick event. I'm new with richfaces so i think that it's my fault. Below is my code:

       <h:form id="userList">
      
       <rich:modalPanel id="userMenuModalPanel">
       <f:facet name="header">
       <h:outputText value="header" />
       </f:facet>
       <rich:tabPanel width="100%" switchType="client" >
       <rich:tab label="Dane personalne" >
       <b><h:outputText value="#{userList.userId}"/></b>
       <b> {login} </b>
       </rich:tab>
       <rich:tab label="Dane systemowe">
       Test 2
       </rich:tab>
       <rich:tab label="Dane prywatne">
       test 3
       </rich:tab>
       </rich:tabPanel>
       <a onclick="Richfaces.hideModalPanel('userMenuModalPanel');" href="#" style="color:white;">Hide</a>
       </rich:modalPanel>
      
      
       <rich:dataTable id="userListTable" rows="4" value="#{userList.users}" var="user" width="100%" >
       <f:facet name="caption"><h:outputText value="Lista użytkowników" /></f:facet>
       <rich:column sortBy="#{user.name}" filterBy="#{user.name}" filterEvent="onkeyup" title="Wpisz frazę wyszukiwania">
       <f:facet name="header">
       <h:outputText value="Nazwa użytkownika"/>
       </f:facet>
       <h:outputText value="#{user.name}"/>
       <f:facet name="footer">
       <h:outputText value="Nazwa użytkownika"/>
       </f:facet>
       </rich:column>
       <rich:column sortBy="#{user.login}" filterBy="#{user.login}" filterEvent="onkeyup" title="Wpisz frazę wyszukiwania">
       <f:facet name="header">
       <h:outputText value="Login użytkownika w systemie"/>
       </f:facet>
       <h:outputText value="#{user.login}"/>
       <f:facet name="footer">
       <h:outputText value="Login użytkownika w systemie"/>
       </f:facet>
       </rich:column>
      
       <rich:componentControl event="onRowClick" for="userMenuModalPanel" operation="show">
       <f:param value="#{user.login}" name="login" /> <!-- not working -->
       <a4j:actionparam value="#{user.id}" name="userId" assignTo="#{userList.userId}"/> <!-- not working too :( -->
       </rich:componentControl>
      
       </rich:dataTable>
      
       </h:form>
      

      I try to make lik is show on example http://livedemo.exadel.com/richfaces-demo/richfaces/contextMenu.jsf?c=contextMenu&tab=usage (this one with cars) but that didn't work either :(.

        • 3. Re: How to send some data from DataTable to TabPanel
          sebo sebo Newbie

          And I stopped again :\... but this time with bean problem ... when i try to invoke action method I get

          javax.servlet.ServletException: /pages/admin/users/user-list.jspx @123,67 value="#{userList.user.id}": Target Unreachable, 'user' returned null
          
          root cause
          
          javax.el.PropertyNotFoundException: /pages/admin/users/user-list.jspx @123,67 value="#{userList.user.id}": Target Unreachable, 'user' returned null
          

          how to force richfaces(or jsf) to not save values for user entity after click on Store button (ONLY) ? Or , if ther is other way to do this, to store them properly.

          Below my code:
          facelet fragment
          ...
           <rich:column>
           <f:facet name="header">
           Actions
           </f:facet>
           <a4j:commandLink ajaxSingle="true" id="editlink" oncomplete="#{rich:component('editPanel')}.show()">
           <h:graphicImage value="/images/icons/edit.gif" style="border:0"/>
           <f:setPropertyActionListener value="#{user}" target="#{userList.user}" />
           <f:setPropertyActionListener value="#{row}" target="#{userList.rowId}" />
           </a4j:commandLink>
           <rich:toolTip for="editlink" value="Edit"/>
           <a4j:commandLink ajaxSingle="true" id="deletelink" oncomplete="#{rich:component('deletePanel')}.show()">
           <h:graphicImage value="/images/icons/delete.gif" style="border:0"/>
           <f:setPropertyActionListener value="#{row}" target="#{userList.rowId}" />
           </a4j:commandLink>
           <rich:toolTip for="deletelink" value="Delete"/>
           </rich:column>
          
           </rich:dataTable>
           <rich:datascroller align="center" for="userListTable" reRender="top" id="bottom" />
           </a4j:region>
          
           </h:form>
          
           <rich:modalPanel id="editPanel" autosized="true" width="450">
           <f:facet name="header">
           <h:outputText value="Edit Current Car" />
           </f:facet>
           <f:facet name="controls">
           <h:panelGroup>
           <h:graphicImage value="/images/modal/close.png" id="hidelink" styleClass="hidelink"/>
           <rich:componentControl for="editPanel" attachTo="hidelink" operation="hide" event="onclick" />
           </h:panelGroup>
           </f:facet>
           <h:form>
           <rich:messages style="color:red;"></rich:messages>
           <h:panelGrid columns="1">
           <a4j:outputPanel ajaxRendered="true">
           <h:panelGrid columns="2">
           <h:outputText value="Make"/>
           <h:inputText value="#{userList.user.id}" />
           <h:outputText value="Model" />
           <h:inputText value="#{userList.user.name}" />
           <h:outputText value="Price" />
           <h:inputText value="#{userList.user.email}" label="Price"/>
           </h:panelGrid>
           <rich:message showSummary="true" showDetail="false" for="price"/>
           </a4j:outputPanel>
           <a4j:commandButton value="Store" reRender="name, email, login" action="#{userList.storeUser}"
           oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('editPanel')}.hide();" />
           </h:panelGrid>
           </h:form>
           </rich:modalPanel>
          

          ...
          my bean
          public class UserList extends BusinessDelegate
          {
           private List<Users> users;
           private Selection selection;//selection jest przypisana do tabeli
           private Integer userId;//id użytkownika wybranego poprzez kliknięcie do edycji
           private Users user;//aktualnie wybrany użytkownik
           private Integer rowId;//aktualnie wybrany wiersz
           private Integer keys;//klucze
          
           public UserList() throws FacadeNotFoundException, NoDbRecordException
           {
           super();
           this.users = this.local_llug_facade.GetAllUsers();
           this.selection = new SimpleSelection();
           }
          
           public List<Users> getUsers() { return users; }
           public void setUsers(List<Users> users) { this.users = users; }
          
           public Integer getUserId() { return userId; }
           public void setUserId(Integer userId) { this.userId = userId; }
          
           public Users getUser() { return user; }
           public void setUser(Users user) { this.user = user; }
          
           public Selection getSelection() { return selection; }
           public void setSelection(Selection selection) { this.selection = selection; }
          
           public Integer getRowId() { return rowId; }
           public void setRowId(Integer rowId) { this.rowId = rowId; }
          
           public Integer getKeys() { return keys; }
           public void setKeys(Integer keys) { this.keys = keys; }
          
           public String storeUser()
           {
           System.out.println("\nTest:"+this.user.getName()+"\n");
           return "ok";
           }
          }
          


          • 5. Re: How to send some data from DataTable to TabPanel
            Nick Belaevski Master

            This exception happens because #{userList.user} variable is not set in the case of store link.

            For your question, maybe this: http://jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/html/region.html will help?

            • 6. Re: How to send some data from DataTable to TabPanel
              sebo sebo Newbie

              Nop, that doesn't helped :(. I tryed with a4j:region and nothing, only

              ...
              static User user
              ...
              
              help, but that is not good practice :). Where i can find backing bean for this example http://livedemo.exadel.com/richfaces-demo/richfaces/dataTable.jsf?tab=editDataTable&cid=393055 ? My work is copy of that :) so why it's not working for me ?