1

I’m struggling to get my bean to update with the new page values. I have two submit buttons on my page and I toggle which one displays based on a Boolean value for what mode my page is in. When my page is in update only (no validation) I show the submit button that has immediate=”true”. When the page is in process mode (validate) I show the submit button that does not have immediate=”true”. The problem I’m running into is when I am in update mode (no validation) the values in the input fields are not being set in the bean. All I want to do when in this mode is save the page as is and exit. No validation is needed because the information on that page is not ready to process or “really use” if you will. That said, if I have my page in process mode (validate) then everything works as intended. Values are submitted and saved.

I’m not posting any code yet as there is nothing special about what I’m trying to do. I simply have a value binding that points to simple getter / setter. My bean is in @ViewScope.

I’ve tried using the examples by BalusC in his excellent blogspot post: debug-jsf-lifecycle. Putting immediate=”true” on the input fields has no affect when clicking on the submit button with immediate="true". All and all though, the way I understand it is immediate=”true” on the UICommand is what tells the application to skip validation or not. Putting it on the input fields simply makes validation happen sooner. Am I missing something?

Any ideas? Any and all help with this is most appreciated!

App specifics:
JSF 2.0.3
Tomcat 6.0.14

1 Answer 1

1

The immediate="true" is not intented to disable validation. It's intented to either prioritize validation or to skip processing of the input altogether. See also the summary at the bottom of the article.

You need to disable validation by setting required="false", or <f:validator disabled="true">. Here's an example which assumes that you've a boolean process property which represents the form's state:

<h:inputText value="#{bean.value1}" required="#{bean.process}" />
<h:inputText value="#{bean.value2}" required="#{bean.process}">
    <f:validator validatorId="someValidatorId" disabled="#{!bean.process}" />
</h:inputText>
...

This way the fields aren't required and won't be validated when process evaluates false.

1
  • 1
    It appears that I'm a victim of the inputs not being processed. I don't know why but I somehow got it in my head that immediate="true" on a UICommand was what disabled the validation, but it's simply not processing those fields...As always, thank you BalusC! I wish I knew half of what you've forgotten :)
    – Mickelback
    Sep 13, 2011 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.