Immediate Attribute

I understand that the immediate attribute when it is set to true plays a diifferent role when it is part of an inputText or of a commandButton.

For example if I the inputText has a required="true" and an immediate="true" the validation will happen and I will see an message of is Required when I submit the form.

On the other side if the immediate="true" is an attribute of the h:commandButton (the button that submits the form) the validation will not happen.

Am I correct?And if I am why should I ever use the immediate="true" in a component othet that button, what it will offer me?

Thanks in advance.

[635 byte] By [juanitaJa] at [2007-11-26 16:32:24]
# 1
Check http://balusc.xs4all.nl/srv/dev-jep-djl.html to get some insights in the JSF lifecycle and the incluence of the immediate attribute.
BalusCa at 2007-7-8 22:57:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Yes I have already read that and I have the above questions.
juanitaJa at 2007-7-8 22:57:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
You want to know when and why to use this attribute? Well .. Use it if you want to skip validation and/or don't want the values being submitted. For example, pagination button, cancel button, skip button, next button, navigation button, etc.
BalusCa at 2007-7-8 22:57:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
why should I use it in an h :inputText or in h:selectOneMenu since it does not escape validation in that case?What it will offer me to have the validation at ApplyRequests phase?
juanitaJa at 2007-7-8 22:57:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Using immediate means the component value will be validated during apply-request-values, ie before any non-immediate component values (which validate in process-validations).

Using immediate causes the component ActionListener or action-method to be executed at the end of the apply-request-values phase, ie before any non-immediate value validation and before any backing bean updates (update-model phase).

amitteva at 2007-7-8 22:57:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

So if I have the immediate="true" in a selectOneMany component that onchange submits the form and above this component I have an inputText component with attribute required="true" the validation for the inputText will occur earlier than if I did not have the immediate="true" in

the selectOneMany correct?So what will this offer to me?

juanitaJa at 2007-7-8 22:57:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
I don't know the answer myself but this is also discussed here. http://forum.java.sun.com/thread.jspa?threadID=769155&messageID=4387814Might be of some interest to you!IlluMessage was edited by: Illu
Illua at 2007-7-8 22:57:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

Thank you lllu, I was thinking of that discussion.

Juanita, everyone here has given you good advice on the immediate attribute. So keep it all in mind. I'm going to try and answer your question directly.

The immediate attribute on UIInput is used, typically, when you submit the form from the component. Usually when you have a valueChangeListener that you want invoked "immediately" when a change occurs. Thus, it will run before all the other components (without immediate="true") get validated. So then all the other components on your page can't stop the valueChangeListener from running (due to validation errors).

It looks like you understand the usage of immediate="true" on the UICommand components.

CowKing

IamCowKinga at 2007-7-8 22:57:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
Ok I think I got the idea.Thank you very much all.
juanitaJa at 2007-7-8 22:57:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...