4 Replies Latest reply on Feb 28, 2011 3:36 AM by ilya_shaikovsky

    Using DataTable and SubTable in DataEntry

    james_hays

      I'm attempting to use DataTable and SubTable in a data entry form. The table is set up very similar to the richfaces demo for DataTable, but when I submit my form, the only changes that occur in my bean are those that are utilized in the DataTable. The sub-list that is handled by the SubTable does not appear to be passed backed to my bean for persistence. Looking at the docs, it appears as if the subTable attribute, componentState, is what I need to use, but I'm not sure how to use it.

      Can anybody point me in the right direction here?

      Thanks,

      James

        • 1. Re: Using DataTable and SubTable in DataEntry
          james_hays

          Here is my xhtml.

          <h:form id="ManageForm">
           <rich:dataTable value="#{manageExternalLinks.baseProfile.baseProfileGates}" var="baseProfileGate" width="750px" bgcolor="blue">
           <f:facet name="header">
           <rich:columnGroup>
           <rich:column colspan="4">
           <h:outputText value="#{manageExternalLinks.baseProfile.name} - #{manageExternalLinks.baseProfile.version}" />
           </rich:column>
           </rich:columnGroup>
           </f:facet>
           <rich:column colspan="2">
           <f:facet name="header">Gate Name</f:facet>
           <h:outputText value="#{baseProfileGate.gate.name}" styleClass="text"/>
           </rich:column>
           <rich:column>
           <f:facet name="header">External URL</f:facet>
           <h:inputText value="#{baseProfileGate.externalUrl}" styleClass="text">
           <a4j:support event="onkeyup" reRender="GateUrl" ajaxSingle="true" limitToList="true" requestDelay="500"/>
           </h:inputText><br/>
           <h:outputLink id="GateUrl" value="#{baseProfileGate.externalUrl}" target="_blank">#{baseProfileGate.externalUrl}</h:outputLink>
           </rich:column>
           <rich:column>
           <f:facet name="header">Intent</f:facet>
           <h:inputTextarea value="#{baseProfileGate.description}" styleClass="textArea"/>
           </rich:column>
          
           <rich:subTable value="#{baseProfileGate.productTemplates}" var="productTemplate">
           <rich:column>
           <!--<f:facet name="header"><rich:spacer /></f:facet> -->
           <rich:spacer/>
           <f:facet name="footer"><rich:spacer /></f:facet>
           </rich:column>
           <rich:column>
           <!--<f:facet name="header">Product Name</f:facet>-->
           <h:inputText value="#{productTemplate.name}" styleClass="text"/>
           <f:facet name="footer"><rich:spacer /></f:facet>
           </rich:column>
           <rich:column>
           <!--<f:facet name="header">External URL</f:facet>-->
           <h:inputText value="#{productTemplate.externalUrl}" styleClass="text">
           <a4j:support event="onkeyup" reRender="ProductUrl" ajaxSingle="true" limitToList="true" requestDelay="500"/>
           </h:inputText><br/>
           <h:outputLink id="ProductUrl" value="#{productTemplate.externalUrl}">#{productTemplate.externalUrl}</h:outputLink>
           <f:facet name="footer"><rich:spacer /></f:facet>
           </rich:column>
           <rich:column>
           <!--<f:facet name="header">Intent</f:facet>-->
           <h:inputTextarea value="#{productTemplate.description}"/>
           <f:facet name="footer"><rich:spacer /></f:facet>
           </rich:column>
           </rich:subTable>
           </rich:dataTable>
           <h:commandButton action="#{manageExternalLinks.submitChanges}" value="Submit" />
           </h:form>
          


          And here is my SFSB
          @Stateful
          @Name("manageExternalLinks")
          public class ManageExternalLinksAction implements ManageExternalLinks
           {
           @PersistenceContext(type = PersistenceContextType.EXTENDED)
           private EntityManager em;
          
           private BaseProfile baseProfile;
          
           public BaseProfile getBaseProfile()
           {
           return baseProfile;
           }
          
           public void setBaseProfile(BaseProfile baseProfile)
           {
           this.baseProfile = baseProfile;
           }
          
           @End
           public void submitChanges()
           {
           this.baseProfile = em.merge(baseProfile);
           }
          
           @Factory(value = "allBaseProfiles")
           public List<BaseProfile> loadBaseProfiles()
           {
           return em.createQuery("Select bp from BaseProfile bp").getResultList();
           }
          
           @Destroy
           @Remove
           public void destroy()
           {
           }
           }
          


          • 2. Using DataTable and SubTable in DataEntry
            taysay

            Hi James,

             

            Please   can I have a look at the baseProfileGates  object ?

            I am having issues with the subtable and it appears you example may give me the leading.   sori I am riding on your problem for my solution.

             

            Have a good one.

            • 3. Using DataTable and SubTable in DataEntry
              ilya_shaikovsky
              • 4. Using DataTable and SubTable in DataEntry
                ilya_shaikovsky

                any exceptions on submission?