0 Replies Latest reply on Nov 10, 2011 10:26 AM by cgrohowski

    Resetting mapped back data in rich:dataTable's view

    cgrohowski

      Hello,

       

      We currently have a requirement to "reset" an entire form back to its original values via a commandButton.  This form contains a few different elements, all of which are working fine.  The problem arises when we attempt to reset the values in a rich:dataTable.  The data is dynamic and contains selectOneMenu elements.  New rows are able to be added as necessary and values changed. 

       

      The code for the dataTable is listed below as well as the action to reset the form.  We maintain an original map of values and reset the model's state back to the original values, but the view is maintaining the same state.  We attemped to look in the viewRoot for the selectOneMenu items, but for some reason, even after traversing the view, we cannot seem to find them to set their submitted value back to their original value.  Is there a way to accomplish this?  We have a similar situation on a different page, but that page has inputText's and after a page refresh called oncomplete it's working fine. 

                               <rich:dataTable id="orderingRuleTable" 
                                      value="#{accessoryMaint.orderingRulesList}"
                                      var="r"
                                      width="100%"
                                      cellspacing="0" cellpadding="0"
                                      rowClasses="table-row, table-rowalt"
                                      rendered="#{not empty accessoryMaint.orderingRules}">
                                      <rich:column>
                                          <f:facet name="header">
                                              <h:outputText value="Ordering Rule" styleClass="txthead"/>
                                          </f:facet>
                                          <h:selectOneMenu value="#{accessoryMaint.orderingRules[r.key].ruleType}"
                                              styleClass="txt">
                                              <a4j:support event="onchange" ajaxSingle="true"/>
                                              <f:selectItems value="#{accessoryMaint.validOrderingRules}"/>
                                          </h:selectOneMenu>
                                      </rich:column>
                                      <rich:column>
                                          <f:facet name="header">
                                              <h:outputText value="Dependent Option" styleClass="txthead"/>
                                          </f:facet>
                                          <h:selectOneMenu id="orderingRuleOption" value="#{accessoryMaint.orderingRules[r.key].ruleOptionCode}"
                                              required="true" requiredMessage="Dependent Option is required" 
                                              styleClass="txt">
                                              <a4j:support event="onchange" ajaxSingle="true"/>
                                              <f:selectItem itemLabel=" --- Please Select --- "/>
                                              <f:selectItems value="#{accessoryMaint.allOptionsAndAccessories}"/>
                                          </h:selectOneMenu><br/>
                                          <b:message for="orderingRuleOption"/>
                                      </rich:column>
                                      <rich:column width="10%" rendered="#{security.admin}">
                                          <f:facet name="header">
                                              <h:outputText value="Action" styleClass="txthead"/>
                                          </f:facet>
                                          <a4j:commandButton value="Delete" 
                                              oncomplete="Richfaces.showModalPanel('deleteRuleModal')"
                                              ajaxSingle="true" reRender="orderingRuleListPanel" 
                                              styleClass="txt width-50"
                                              rendered="#{security.admin}">
                                              <a4j:actionparam name="ruleKey" value="#{r.key}" assignTo="#{accessoryMaint.deleteOrderingRuleKey}"/>
                                          </a4j:commandButton>
                                      </rich:column>
                                  </rich:dataTable>   
      

       

      Here is the actionListener called trying to reset the form:

       

      public void resetModelAccessoryForm( ActionEvent evt ) {
           FacesUtil.resetForm("accessoryMaintForm");
           getAlternateDescIn().setSubmittedValue(modelAccessory.getAltDesc() );
           //...More form reset code here
           // This is where the map is being reset but it's not reflected in the view     
           orderingRules = new java.util.TreeMap<Long, OrderingRuleHelper>();
           if ( !orderingRulesOriginal.isEmpty() ) {
                for ( Long key : orderingRulesOriginal.keySet() )
                     orderingRules.put(key, orderingRulesOriginal.get(key));
           }
      
           FacesContext.getCurrentInstance().renderResponse();
      }
      

       

      Any help would be appreciated on how to access the view elements that RF is maintaining *somewhere* or how to better accomplish this goal.

       

      Many thanks,

      Chuck