0 Replies Latest reply on Nov 18, 2009 5:27 PM by Tanya Ruttenberg

    Trouble with editable dataTable with modalPanel

    Tanya Ruttenberg Expert

      I am trying to implement a simple editable datatable using a modalPanel for the editing.  The modalPanel renders just fine, but after change the input field and then click on the Update button, the page seems to re-render with no problem and displays a Successfully updated message. 


      However, when you look at output on the console, there is no update there at all.  And sure enough when you check the data in the database, it remains unchanged.


      This app was generated with seam-gen so it doesn't match the example on richfaces-demo exactly and I want to know what the heck I am missing.


      Here is the view:




          
      <h:form>
          <a4j:region>
            <rich:dataTable id="dataTable" value="#{devTagsList.resultList}"
              var="_devtags">
              <rich:column>
                <f:facet name="header">Row ID</f:facet>
                <h:outputText value="#{rowId}" id="rowid" />
              </rich:column>
              <rich:column>
                <f:facet name="header">
                  <h:outputText value="Asset Tag" />
                </f:facet>
                <h:outputText value="#{_devtags.devTagId}" id="hostname" />
              </rich:column>
              <rich:column>
                <f:facet name="header">
                  <h:outputText value="Serial Number" />
                </f:facet>
                <h:outputText value="#{_devtags.devSerialNum}" id="platform" />
              </rich:column>
              <rich:column>
                <f:facet name="header">
                  <h:outputText value="Comment" />
                </f:facet>
                <h:outputText value="#{_devtags.comment}" id="devId" />
              </rich:column>
              <rich:column>
                <f:facet name="header">
                  <h:outputText value="Device Id" />
                </f:facet>
                <h:outputText value="#{_devtags.devId}" />
              </rich:column>
              <rich:column>
                <a4j:commandLink ajaxSingle="true" id="editLink"
                  oncomplete="#{rich:component('editPanel')}.show()">
                  <h:graphicImage value="/img/icons/edit.gif" style="border:0" />
                  <f:setPropertyActionListener value="#{_devtags}"
                    target="#{devTagsHome.instance}" />
                </a4j:commandLink>
              </rich:column>
            </rich:dataTable>
            <rich:messages style="color:red;"></rich:messages>
          </a4j:region>
      </h:form>
      <rich:modalPanel id="editPanel" autosized="true" width="450">
          <f:facet name="header">Asset Tag</f:facet>
          <f:facet name="controls">
              <h:panelGroup>
                <h:graphicImage value="/img/modal/close.png"
                  id="hideEditPanel" styleClass="hidelink"
                  onclick="#{rich:component('editPanel')}.hide()" />
              </h:panelGroup>
          </f:facet>
          <h:form>
              <rich:messages for="assetTagPanel" style="color:red;"/>
              <a4j:outputPanel ajaxRendered="true" id="assetTagPanel">
                <h:panelGrid columns="2">
                  <h:outputText value="Serial Number. Change if necessary" />
                  <h:outputText value="#{devTagsHome.instance.devSerialNum}"
                    rendered="#{not empty devTagsHome.instance.devSerialNum}" />
                  <h:outputText value="Asset Tag" />
                  <h:inputText value="#{devTagsHome.instance.devTagId}" />
                  <h:outputText value="Comment" />
                  <h:outputText value="#{devTagsHome.instance.comment}" />
                </h:panelGrid>
              </a4j:outputPanel>
              <a4j:commandButton value="Persist"
                actionListener="#{devTagsHome.persist}"
                oncomplete="#{rich:component('editPanel')}.hide()"
                reRender="dataTable" />
              <a4j:commandButton value="Update"
                actionListener="#{devTagsHome.update}"
                oncomplete="#{rich:component('editPanel')}.hide()"
                reRender="dataTable" />
          </h:form>
      </rich:modalPanel>



      Here is DevTagsHome.java:




      @Name("devTagsHome")
      public class DevTagsHome extends EntityHome<DevTags> {
      
      
           public void setDevTagsTagId(Integer id) {
                setId(id);
           }
      
           public Integer getDevTagsTagId() {
                return (Integer) getId();
           }
      
           @Override
           protected DevTags createInstance() {
                DevTags devTags = new DevTags();
                return devTags;
           }
           
           public void load() {
                if (isIdDefined()) {
                     wire();
                }
           }
           public void wire() {
                getInstance();
           }
      
           public boolean isWired() {
                return true;
           }
      
           public DevTags getDefinedInstance() {
                return isIdDefined() ? getInstance() : null;
           }
      
      
      }




      Thanks in advance for your insight.


      TDR