1 Reply Latest reply on Nov 8, 2010 4:22 AM by Ilya Shaikovsky

    Would like <h:inputText> to clear its submittedValue/localValue

    Ben Vanberg Newbie

      I have a problem where the value typed into <h:inputText> is not being cleared in my form when I really would like for it to be.

       

      Use Case:

       

      Modal dialog with a form. The form has a name field, save button and cancel button. The name field requires validation.

       

      If the user types a value into the name field (<h:inputText>) and clicks save, the dialog will close. Upon opening the dialog again the name field is blank. (I believe this is due to the name field having been processed fully and the UIInput submittedValue and localValue being cleared out.)

       

      If the user types a value into the name field and clicks cancel, the dialog will close. Upon opening the dialog again the name field contains the value the user typed in. This is not the desired behavior. I would like for the dialog form to be cleared every time it is reopened.

       

      Abbreviated XHTML:

       

       

       <h:form id="myForm">
         <a4j:outputPanel id="savedAnalysisPanel">
           ...
              <s:decorate id="reportNameDecoration" template="/layout/nonRequiredEdit.xhtml" rendered="#{reportDefinitionAction.mode ne 'EDIT'}">
                  <ui:define name="label">#{reportDefinitionBundle.nameLabel}:</ui:define>
                  <ui:define name="labelValue">
                      <h:inputText id="reportName" value="#{report.reportName}" style="width:400px">
                          <rich:ajaxValidator event="onblur"/>
                          <a4j:support event="onkeyup" reRender="reportOrderDecoration" ajaxSingle="true" action="#{reportDefinitionAction.categoryChanged}"/>
                      </h:inputText>
                  </ui:define>
              </s:decorate>
           ...
          </a4j:outputPanel>
           ...
          <h:panelGrid columns="2" styleClass="yx-buttons-center">
                          <h:panelGroup>
                              <yx:button>
                                  <a4j:commandLink id="saveButton" action="#{reportDefinitionAction.saveDialog}"
                                                   oncomplete="var saveStatus = $j('[id=saveFilterDialogForm:reportSaveStatus]').attr('value'); if(saveStatus == 'success') #{closePanel};"
                                                   reRender="fullSavePanel,openReport,#{everythingId}"
                                                   value="#{commonBundle.save}" />
                              </yx:button>
                          </h:panelGroup>
                          <h:panelGroup>
                              <yx:button type="secondary">
                                  <a4j:region>
                                  <a4j:commandLink id="cancelButton" value="#{commonBundle.cancel}"
                                                 action="#{reportDefinitionAction.cancelDialog}"
                                                 oncomplete="#{closePanel}"/>
                                  </a4j:region>
                              </yx:button>
                          </h:panelGroup>
          </h:panelGrid>
           ...
      </h:form>
      

       

      Note, the a4j:region around the cancel button to isolate it from the form. This is causing the name field to not be processed and thus the submittedValue/localValue getting stuck. Removing the a4j:region causes validation to occur on cancel which will also not work. Have tried various versions using immediate="true" and ajaxSingle="true". Seems like all I really want is to have the UIInput cleared out. Is this possible without processing those fields?