13 Replies Latest reply on Mar 10, 2011 1:35 PM by Nina Check

    conversion errors and immediate="true"

    Nina Check Newbie

      Hi Everyone,

       

      I'm having an issue with an input field that is bound to an Integer on my backing bean.

       

      On the xhtml, I have the following:

       

      <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>

       

      if the user types in a non-numeric value in this text field, an error results (standard jsf converter)

       

      To enable users to clear bad values or "revert" their data, I have a revert ajax button as follows:

       

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

       

      Clicking the button does not refresh the screen with updated values - even with the immediate=true flag - it fails conversion and then simply does not refresh the field.

       

      I'm not sure how I can work around this without refreshing the entire screen?  I need to only do a partial reRendering of the screen....

       

      Please advise...thanks in advance!

        • 1. conversion errors and immediate="true"
          Nina Check Newbie

          Sorry - I should correct something - clicking the button refreshes everything BUT the fail conversion values - those values seem to somehow stick or be cached somewhere.  The actual backing bean value contains the correct value but the screen does not show it after reRender.  Please help!

          • 2. Re: conversion errors and immediate="true"
            Rocky S Master

            You forget to add this attribute, this will update your backing bean value on the screen-

             

            <a4j:support ajaxSingle="true" event="onblur" ignoreDupResponses="true" oncomplete="checkFieldValidation(this)" onsubmit="updateDirty()"/>

             

            change to

             

            <a4j:support

            reRender="grossVolume" ajaxSingle="true" event="onblur" ignoreDupResponses="true" oncomplete="checkFieldValidation(this)" onsubmit="updateDirty()"/>

             

             

             

             

             

            Don't forget to mark the post as correct/helpful answer, if it solves/helps you.

            • 3. conversion errors and immediate="true"
              Nina Check Newbie

              Hi Aman,

               

              Thank you for your reply - normally, I would have put the reRender attribute as you suggested, however, in this particular instance the reRender tag has been purposely omitted because in IE, the reRender causes the user to lose focus if an error (validation) has occurred on the page.  for this reason, I am updating the status in the oncomplete.

               

              The above all works fine - it is with the REFRESH (or attempted refresh) of the panel in which the bad (non-convertable) field is found that the issue exsists.  The cached value seems to persist somewhere and I'm not sure how to clear it?

               

              Thanks again!

              • 4. Re: conversion errors and immediate="true"
                Rocky S Master

                Please let us know your conversion error stack trace and what is this datatype {volumeBean.enteredGrossVolume}?

                 

                I guess your revert ajax button purpose is to clear the value entered by the user and show the existing value from the bean. For this either you have to add a4j:region around all h:inputText elements you want to rerender or add rerender attribute to your revert button, listing all the fields you want to rerender.

                • 5. conversion errors and immediate="true"
                  Nina Check Newbie

                  I don't have the conversion error stack - it just returns an error the datatype is BigDecimal and if I enter something non-numeric in the field, a subsequent reRender of the containing panel does not update the bad data - it's stuck there and keeps failing conversion....

                  • 6. Re: conversion errors and immediate="true"
                    Rocky S Master

                    this is how jsf lifecycle works, if there is conversion error, it won't update the model values.

                    • 7. conversion errors and immediate="true"
                      Nina Check Newbie

                      Hi again,

                       

                      Yes, I know that the model is not updated - however my problem is not the model - the model contains the correct values.

                       

                      The problem is that I cannot FORCE the screen to refresh (partial update) with the correct values on the click of my refresh button - the bad fields are not cleared unless the user is forced to clear them - which should not happen if the a4j:commmandButton has immediate="true"

                      • 8. conversion errors and immediate="true"
                        Nina Check Newbie

                        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

                        • 9. conversion errors and immediate="true"
                          Nick Belaevski Master

                          Nina,

                           

                          Is 'volumeBean.revert' being called when you press the button? Also it the button inside or outside table?

                          • 10. conversion errors and immediate="true"
                            Rocky S Master

                            I guess your revert ajax button purpose is to clear the value entered by the user and show the existing value from the bean. For this either you have to add a4j:region around all h:inputText elements you want to rerender or add rerender attribute to your revert button, listing all the fields you want to rerender or clear.

                                     Did you tried this?

                            • 11. conversion errors and immediate="true"
                              Nina Check Newbie

                              HI Aman,

                               

                              Yes, I've tried this.  I've tried both reRendering the individual fields and the outputPanel - both with the same result....

                              • 12. conversion errors and immediate="true"
                                Nina Check Newbie

                                Hi Nick,

                                 

                                I've tried both - the a4j:commandButton inside the same panel and outside the panel - both yield the same results - the aa string is not refreshed to original (valid) value....

                                 

                                N

                                • 13. conversion errors and immediate="true"
                                  Nina Check Newbie

                                  Hi Nick,  - also add 'yes', volumeBean.revert is being called for 100% sure