7 Replies Latest reply on May 11, 2009 5:33 AM by JB LeBron

    Trouble editing two fields at the same time

    JB LeBron Newbie

      Hello, we're developing a simple web application which contains a table that allows people to Insert, Edit and delete records from a DB.

      The screen works fine for Insert and delete. It also works if the user edits only 1 field.

      However, we run into trouble when the user tries to edit 2 fields at the same time. When user tries to amend both, the first field (Field 1 below) will be changed, but the second remains unchanged. We looked at the data bean and it seems that the bean is unable to retrieve the new value the user input.

      Below is the skeleton of the code:

      <a4j:form id="dataForm" ajaxSubmit="true" reRender="output">
      
      <!-- Some code here -->
      
      <rich:dataTable>
      <rich:column label="Field1" sortable="false" width="50">
       <f:facet name="header">
       <h:outputText value="Field1" />
       </f:facet>
       <h:outputText value="#{data.Field1}"
       rendered="#{data ne myBean.selectedName}" />
       <h:panelGroup rendered="#{data eq myBean.selectedName}">
       <h:selectOneMenu
       value="#{data.Field1}"
       label="Field1">
       <f:selectItems value="#{refDataBean.Field1List}" />
       </h:selectOneMenu>
       <rich:message for="Field1" fatalClass="formMsgFatal"
       errorClass="formMsgError" />
       </h:panelGroup>
       <f:facet name="footer">
       <h:selectOneMenu
       value="#{myBean.newName.Field1}"
       label="Field1"
       rendered="#{myBean.selectedName == null}">
       <f:selectItems value="#{refDataBean.Field1List}" />
       </h:selectOneMenu>
       </f:facet>
       </rich:column>
      
       <!-- Some other code here -->
      
      <rich:column label="field2" sortable="false" width="350">
       <f:facet name="header">
       <h:outputText value="field2" />
       </f:facet>
       <h:outputText value="#{data.field2}"
       rendered="#{data ne myBean.selectedName}" />
       <h:panelGroup rendered="#{data eq myBean.selectedName}">
       <h:inputText id="field2" label="field2"
       value="#{data.field2}" size="60" required="true">
       </h:inputText>
       <rich:message for="field2" fatalClass="formMsgFatal"
       errorClass="formMsgError" />
       </h:panelGroup>
       <f:facet name="footer">
       <h:panelGroup rendered="#{myBean.selectedName == null}">
       <h:inputText id="newfield2" label="field2"
       value="#{myBean.newName.field2}" size="50"
       required="true">
       </h:inputText>
       <rich:message for="newfield2" fatalClass="formMsgFatal"
       errorClass="formMsgError" />
       </h:panelGroup>
       </f:facet>
       </rich:column>
      
       <!-- Some other code here -->
      
       <rich:column label="Control" sortable="false">
       <f:facet name="header">
       </f:facet>
       <a4j:commandLink action="#{myBean.modify}"
       immediate="true">
       <h:graphicImage url="/image/pencil.gif" styleClass="graphicLink"
       rendered="#{data ne myBean.selectedName}" />
       </a4j:commandLink>
       <h:outputText value=" " style="pre" />
       <a4j:commandLink action="#{myBean.delete}"
       onclick="if (!confirm('Are you sure?', false)) return false"
       immediate="true">
       <h:graphicImage url="/image/delete.gif" styleClass="graphicLink"
       rendered="#{data ne myBean.selectedName}" />
       </a4j:commandLink>
       <a4j:commandLink action="#{myBean.save}"
       immediate="false">
       <h:graphicImage url="/image/accept.gif" styleClass="graphicLink"
       rendered="#{data eq myBean.selectedName}" />
       </a4j:commandLink>
       <h:outputText value=" " style="pre"
       rendered="#{data eq myBean.selectedName}" />
       <a4j:commandLink action="#{myBean.cancel}"
       immediate="true">
       <h:graphicImage url="/image/cross.gif" styleClass="graphicLink"
       rendered="#{data eq myBean.selectedName}" />
       </a4j:commandLink>
       <f:facet name="footer">
       <a4j:commandLink action="#{myBean.add}"
       immediate="false">
       <h:graphicImage url="/image/add.gif" styleClass="graphicLink"
       rendered="#{myBean.selectedName == null}" />
       </a4j:commandLink>
       </f:facet>
       </rich:column>
      
      <rich:column label="Field1" sortable="false" width="50">
       <f:facet name="header">
       <h:outputText value="Field1" />
       </f:facet>
       <h:outputText value="#{data.Field1}"
       rendered="#{data ne myBean.selectedName}" />
       <h:panelGroup rendered="#{data eq myBean.selectedName}">
       <h:selectOneMenu
       value="#{data.Field1}"
       label="Field1">
       <f:selectItems value="#{refDataBean.Field1List}" />
       </h:selectOneMenu>
       <rich:message for="Field1" fatalClass="formMsgFatal"
       errorClass="formMsgError" />
       </h:panelGroup>
       <f:facet name="footer">
       <h:selectOneMenu
       value="#{myBean.newName.Field1}"
       label="Field1"
       rendered="#{myBean.selectedName == null}">
       <f:selectItems value="#{refDataBean.Field1List}" />
       </h:selectOneMenu>
       </f:facet>
       </rich:column>
      
       <!-- Some other code here -->
      
      <rich:column label="field2" sortable="false" width="350">
       <f:facet name="header">
       <h:outputText value="field2" />
       </f:facet>
       <h:outputText value="#{data.field2}"
       rendered="#{data ne myBean.selectedName}" />
       <h:panelGroup rendered="#{data eq myBean.selectedName}">
       <h:inputText id="field2" label="field2"
       value="#{data.field2}" size="60" required="true">
       </h:inputText>
       <rich:message for="field2" fatalClass="formMsgFatal"
       errorClass="formMsgError" />
       </h:panelGroup>
       <f:facet name="footer">
       <h:panelGroup rendered="#{myBean.selectedName == null}">
       <h:inputText id="newfield2" label="field2"
       value="#{myBean.newName.field2}" size="50"
       required="true">
       </h:inputText>
       <rich:message for="newfield2" fatalClass="formMsgFatal"
       errorClass="formMsgError" />
       </h:panelGroup>
       </f:facet>
       </rich:column>
      
       <!-- Some other code here -->
      
       <rich:column label="Control" sortable="false">
       <f:facet name="header">
       </f:facet>
       <a4j:commandLink action="#{myBean.modify}"
       immediate="true">
       <h:graphicImage url="/image/pencil.gif" styleClass="graphicLink"
       rendered="#{data ne myBean.selectedName}" />
       </a4j:commandLink>
       <h:outputText value=" " style="pre" />
       <a4j:commandLink action="#{myBean.delete}"
       onclick="if (!confirm('Are you sure?', false)) return false"
       immediate="true">
       <h:graphicImage url="/image/delete.gif" styleClass="graphicLink"
       rendered="#{data ne myBean.selectedName}" />
       </a4j:commandLink>
       <a4j:commandLink action="#{myBean.save}"
       immediate="false">
       <h:graphicImage url="/image/accept.gif" styleClass="graphicLink"
       rendered="#{data eq myBean.selectedName}" />
       </a4j:commandLink>
       <h:outputText value=" " style="pre"
       rendered="#{data eq myBean.selectedName}" />
       <a4j:commandLink action="#{myBean.cancel}"
       immediate="true">
       <h:graphicImage url="/image/cross.gif" styleClass="graphicLink"
       rendered="#{data eq myBean.selectedName}" />
       </a4j:commandLink>
       <f:facet name="footer">
       <a4j:commandLink action="#{myBean.add}"
       immediate="false">
       <h:graphicImage url="/image/add.gif" styleClass="graphicLink"
       rendered="#{myBean.selectedName == null}" />
       </a4j:commandLink>
       </f:facet>
       </rich:column>
      </rich:dataTable>
      
      <!-- some code here -->
      
      </a4j:form>
      

      We've tried testing around, it's confirmed that the database works perfectly. However, it's the passing from richTable to the databean. Can anyone help on how to debug? Thanks!