Icefaces partialSubmit and immediate compared
Now let’s try something else: We want, next to the « Search » button, another one, « Back to Home », that goes directly to another page, let’s say the home page.
If we simply add the button in the .xhtml page, and click on it, we have the following result:
1 2 3 | <ice:commandButton id="homeAction" value="Back to Home" action="#{searchPage.backToHome}" /> |
Result:
You can see that we cannot go back to the homepage without setting required fields in the form. That’s clearly not good.
One of the solution to this, according to icefaces documentation, is to use partialSubmit= »true » in the button. This tell Icefaces to ignore all mandatory components that are not filled.
Let’s try:
1 2 3 | <ice:commandButton id="homeAction" value="Back to Home" action="#{searchPage.backToHome}" partialSubmit="true" /> |
And the result is working !
But, suppose that you’ve typed a wrong value in the first field, and press « Back to home » ?
Here is the result:
What happened ? partialSubmit bypassed the required check, but not the integer validation.
To avoid these 2 checks, we need to use another attribute in the button, it’s immediate= »true ». That means: When I press the button, just handle the button’s action, and forget about all other fields.
1 2 3 | <ice:commandButton id="homeAction" value="Back to Home" action="#{searchPage.backToHome}" immediate="true" /> |
And the result works, even with a bad value in the integer field!


Commentaires
Ecrire un commentaire Trackback