0

I have an input field in a JSF Page like the following (maps to BigDecimal on backing bean)

    <h:inputText disabled="#{volumeBean.grossVolumeDisabled}" id="grossVolume" size="10" validateOnExit="true" value="#{volumeBean.enteredGrossVolume}" >
    <a4j:support ajaxSingle="true" event="onblur" ignoreDupResponses="true" oncomplete="checkFieldValidation(this)" onsubmit="updateDirty()"/>
    </h:inputText>

And an a4j:commandButton to "refresh" all the data from the database on the page:

    <a4j:commandButton accesskey="T" action="#{volumeBean.revert}" button-type="ajax" disabled="#{volumeBean.revertDisabled}" id="volumeBean_reset"         immediate="true" reRender="volumesTable" value="#{msg.button_RESET}"/>

Here are the steps to reproduce my problem: And please note that the error occurs regardless of whether there is a reRender attribute set on the a4j:support

Here are the steps to reproduce - just to clarify further:

  1. navigate to the screen where the BigDecimal input field exists
  2. type aa into the field (should be a number but put non-numeric characters purposely)
  3. tab off the field
  4. notice that an error is reported 'aa' is not a valid netVolume
  5. click on the RESET button
  6. all of the changed fields have their original values EXCEPT those that have non-numeric data entered
  7. unless the user manually deletes the non-numeric data in the fields or refreshes the entire screen, the "bad data" sticks
Nena
  • 681
  • 1
  • 10
  • 27

2 Answers2

0

When you do a reset, you fire an Ajax request, the entire form is submitted and you get validation error again. So the field still has the old (incorrect) value.

Max Katz
  • 1,582
  • 1
  • 9
  • 5
  • The reset button has 'immediate="true"', so it should be bypassing validation. – Naganalf Mar 10 '11 at 23:43
  • Because conversation fails, the incorrect value is kept inside submittedValue in the component. You are correct, conversation/validation is not processed when immediate="true", but when the page is rendered, the value from submittedValue is used. You need to clear submittedValue. – Max Katz Mar 11 '11 at 01:02
  • how can one automatically or programmatically clear submittedValue? – Nena Mar 11 '11 at 23:13
  • Look in JSF API, component.getSubmittedValue() – Max Katz Mar 22 '11 at 17:15
0

Try adding the parameter ajaxSingle="true" to the button. I've found that immediate="true" is not adequate for bypassing validation on ajax components.

Naganalf
  • 1,091
  • 7
  • 11
  • ajaxSingle will not skip validation. It means that only the current component will be processed, in other words, go through JSF life cycle. – Max Katz Mar 11 '11 at 01:19
  • I tried using ajaxSingle="true" - didn't work. the value is still cached on the client side somehow. – Nena Mar 11 '11 at 23:12