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

    Resetting mapped back data in rich:dataTable's view

    Chuck Grohowski Newbie



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


      Here is the actionListener called trying to reset the form:


      public void resetModelAccessoryForm( ActionEvent evt ) {
           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));


      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,