0 Replies Latest reply on Jun 22, 2007 10:28 AM by james_hays

    Using DataTable and SubTable for DataEntry

    james_hays

      I have a simple page that lists a series of items in a rich:dataTable and rich:subTable as shown below. The issue I'm running into is that the data specified and modified in the subTable section never makes its way back to the server and as such, won't persist. The parent data found in the dataTable seems to work fine. Any thoughts on what may be causing this?

      Thanks,
      James

      <h:form id="ChooseForm">
       <h:selectOneMenu value="#{manageExternalLinks.baseProfile}">
       <s:selectItems value="#{allBaseProfiles}" var="baseProfile" label="#{baseProfile.name} - #{baseProfile.version}" noSelectionLabel="-- Select Base Profile --" hideNoSelection="#{manageExternalLinks.baseProfile != null}" />
       <a4j:support event="onchange" reRender="ChooseForm,ManageForm"
       onsubmit="toggleStatusBar('Loading Base Profile')"
       oncomplete="toggleStatusBar('Complete', 1000)"/>
       <s:convertEntity />
       </h:selectOneMenu>
      </h:form>
       <br />
      
      <h:form id="ManageForm">
       <rich:dataTable componentState="" 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>
      


      My StatefulBean is as such:

      @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()
       {
       }
       }