You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Jan Ziegler <zi...@top21.de> on 2008/05/27 11:37:32 UTC

inputHidden is not rendered correctly on immediate action

Hi,

I have a problem with h:inputHidden. I want to use it for keeping a request
scope bean´s value from one request to another. The following code shows a
simple example:

<h:form>
    
    <!-- show the text value -->
    <h:outputText value="textValue: #{formBean.textValue}" />
			
    <!-- keep the text value -->
    <h:inputHidden id="field_restore" value="#{formBean.textValue}" />

    <!-- set the text value -->
    <h:commandButton value="set data reload" immediate="true">
	<f:setPropertyActionListener target="#{formBean.textValue}" value="this is
the text value" />
    </h:commandButton>

    <!-- simple reload -->
    <h:commandButton value="simple reload"/><br/>
			
</h:form>


So I got 2 commandButtons: One ("set data reload") for setting
"formBean.textValue" with an f:setPropertyActionListener and one ("simple
reload") for just reloading the page (to check if the value get restored). I
want "formBean.textValue" to be kept over the request. In every case a get
back on the same page (no actions are invoked) 

For restoring the value, I use a h:inputHidden ("field_restore") which is
bound the request scoped bean ("formBean.textValue"). 

So the scenario is like this:
1) Press "set data reload" 
2) check the output: the textValue is set and the h:outputText shows it
3) Press "simple reload"
4) check the output: the textValue is restored and the h:outputText shows it

Everthing works as expected when I set immediate of ("set data
reload")-commandButton to FALSE. 
The value ist set and the output shows it. On a "simple reload" the value is
restored an the output shows it again. If I look at the generated html code
the hidden input-field is rendered with the textValue like this:

<input type="hidden" value="this is the text" name="j_id110:field_restore"
id="j_id110:field_restore"/>

Now if I change the immediate-Flag to TRUE (which is necessary in my case to
bypass some other validations) the behavior is like this:
After pressing the "set data reload"-commandButton the value is set and the
output shows it (like above). But now on the following "simple reload" the
value gets lost! 

Therefor I checked the hidden-input field after pressing "set data reload"
and found the reason for not restoring the value - the hidden-input is
rendered like this:

<input type="hidden" value="" name="j_id110:field_restore"
id="j_id110:field_restore"/>

As you can see the value-Attribut is empty and therefor, nothing will be
restored in the next (simple) request. The strange thing is, that after
pressing "set data reload" the textValue on the bean is set  and the
h:output shows the correct value, but only the hidden-field value-Attribute
misses it.

I can use t:saveState which solves the problem but I think in this situation
it should really work by using h:inputHidden.

Why is it not working with immediate set to true? When I debug the lifecyle
I can see that the f:setPropertyActionListener for setting
formBean.textValue is fired (in APPLY_REQUEST_PHASE instead of
INVOKE_APPLIATION which is ok for immediate actions) and therefor the bean
value is set correctly (which I can see on the output) but why is the value
of the hidden field not rendered with this value?  

Thanx for any help / hints,
jan ziegler


-- 
View this message in context: http://www.nabble.com/inputHidden-is-not-rendered-correctly-on-immediate-action-tp17486716p17486716.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: inputHidden is not rendered correctly on immediate action

Posted by Jan Ziegler <zi...@top21.de>.
I forgot my environment:

MyFaces 1.23
Facelets 1.0.14
Richfaces 3.21 
Tomcat 6.0.16



Jan Ziegler wrote:
> 
> Hi,
> 
> I have a problem with h:inputHidden. I want to use it for keeping a
> request scope bean´s value from one request to another. The following code
> shows a simple example:
> 
> <h:form>
>     
>     <!-- show the text value -->
>     <h:outputText value="textValue: #{formBean.textValue}" />
> 			
>     <!-- keep the text value -->
>     <h:inputHidden id="field_restore" value="#{formBean.textValue}" />
> 
>     <!-- set the text value -->
>     <h:commandButton value="set data reload" immediate="true">
> 	<f:setPropertyActionListener target="#{formBean.textValue}" value="this
> is the text value" />
>     </h:commandButton>
> 
>     <!-- simple reload -->
>     <h:commandButton value="simple reload"/><br/>
> 			
> </h:form>
> 
> 
> So I got 2 commandButtons: One ("set data reload") for setting
> "formBean.textValue" with an f:setPropertyActionListener and one ("simple
> reload") for just reloading the page (to check if the value get restored).
> I want "formBean.textValue" to be kept over the request. In every case a
> get back on the same page (no actions are invoked) 
> 
> For restoring the value, I use a h:inputHidden ("field_restore") which is
> bound the request scoped bean ("formBean.textValue"). 
> 
> So the scenario is like this:
> 1) Press "set data reload" 
> 2) check the output: the textValue is set and the h:outputText shows it
> 3) Press "simple reload"
> 4) check the output: the textValue is restored and the h:outputText shows
> it
> 
> Everthing works as expected when I set immediate of ("set data
> reload")-commandButton to FALSE. 
> The value ist set and the output shows it. On a "simple reload" the value
> is restored an the output shows it again. If I look at the generated html
> code the hidden input-field is rendered with the textValue like this:
> 
> <input type="hidden" value="this is the text" name="j_id110:field_restore"
> id="j_id110:field_restore"/>
> 
> Now if I change the immediate-Flag to TRUE (which is necessary in my case
> to bypass some other validations) the behavior is like this:
> After pressing the "set data reload"-commandButton the value is set and
> the output shows it (like above). But now on the following "simple reload"
> the value gets lost! 
> 
> Therefor I checked the hidden-input field after pressing "set data reload"
> and found the reason for not restoring the value - the hidden-input is
> rendered like this:
> 
> <input type="hidden" value="" name="j_id110:field_restore"
> id="j_id110:field_restore"/>
> 
> As you can see the value-Attribut is empty and therefor, nothing will be
> restored in the next (simple) request. The strange thing is, that after
> pressing "set data reload" the textValue on the bean is set  and the
> h:output shows the correct value, but only the hidden-field
> value-Attribute misses it.
> 
> I can use t:saveState which solves the problem but I think in this
> situation it should really work by using h:inputHidden.
> 
> Why is it not working with immediate set to true? When I debug the
> lifecyle I can see that the f:setPropertyActionListener for setting
> formBean.textValue is fired (in APPLY_REQUEST_PHASE instead of
> INVOKE_APPLIATION which is ok for immediate actions) and therefor the bean
> value is set correctly (which I can see on the output) but why is the
> value of the hidden field not rendered with this value?  
> 
> Thanx for any help / hints,
> jan ziegler
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/inputHidden-is-not-rendered-correctly-on-immediate-action-tp17486716p17486778.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: inputHidden is not rendered correctly on immediate action

Posted by simon <si...@chello.at>.
On Tue, 2008-05-27 at 06:46 -0700, Jan Ziegler wrote:
> looked at the articel again - in the end it says:
> "Non-validated EditableValueHolder (UIInput) components render their
> submitted value, not the backing bean or local value."
> 
> ok, this is an explanation! 

Yep. The value in the submitted form data will have been stored into the
h:inputHidden component as a string. But an immediate command component
will run before that string value gets converted, validated and pushed
into the model. That's the point; you want the immediate action to run
even when submitted data fails to convert or validate.

If the immediate action does nothing, then normal page processing
continues.

If the immediate action causes the current page to be re-rendered, then
the hidden field will render that unconverted/unvalidated string value.
This is done because even when conversion or validation fails for a
component you don't want to throw the user input away.

But if the immediate action causes a new view to be created, then that
submitted data will be lost, because that particular h:inputHidden
component has been thrown away and the data it contained was never
pushed into any model object.

Regards,
Simon


Re: inputHidden is not rendered correctly on immediate action

Posted by Jan Ziegler <zi...@top21.de>.
looked at the articel again - in the end it says:
"Non-validated EditableValueHolder (UIInput) components render their
submitted value, not the backing bean or local value."

ok, this is an explanation! 




Jan Ziegler wrote:
> 
> Hi Simon,
> 
> thanks for your answer. I´ll checked that article on myFaces and found
> some interessting aspects.
> But I still have some problems with understanding my case:
> 
> I understand, that the UPDATE_MODEL phase is skipped when immediate on the
> commandButton is true, and therefor the bean isn´t updated in this phase
> BUT my f:setPropertyActionListener updates the bean on APPLY_REQUEST phase
> so the value IS set  (I can see it on the screen by h:outputText). So
> therefor I think it should also be rendered as a value of the hidden-field
> because RENDER_RESPONSE is handled as usual I think, even if immediate is
> set to true on the command,  isn´t it?
> 
> I tested the following:
> If I add an <h:inputText> to my form (bound to the same bean as the
> hidden-field) and enter some text and perform the same steps as before on
> my previous example then the value of this field IS restored on the
> "simple reload" and with immediate=TRUE. The only difference is that this
> value is entered manually and the value bound to the hidden-field ist set
> by the setPropertyActionListener:
> 
> <!-- field (with manually entered text) is restored -->
> <h:inputText id="field_restore2" value="#{formBean.textValue2}" />
> 
> <!-- field (with text set via actionListener) is not restored -->
> <h:inputHidden id="field_restore" value="#{formBean.secondField}" />
> 
> Only the hidden field isn´t restored???
> 
> BTW I tried the hack with immediate=true on the hidden-field before, it
> also doesn´t work. As I mentioned I can use t:saveState and it works, but
> it would be more satifying to understand why the hidden-thing is not
> working in this case.
> 
> Or maybe I just didn´t get the whole thing yet...
> 
> greetz
> jan
> 
> 
> 
> 
> 
> 
> 
> simon.kitching@chello.at wrote:
>> 
>> Jan Ziegler schrieb:
>>> Hi,
>>>
>>> I have a problem with h:inputHidden. I want to use it for keeping a
>>> request
>>> scope bean´s value from one request to another. The following code shows
>>> a
>>> simple example:
>>>
>>> <h:form>
>>>     
>>>     <!-- show the text value -->
>>>     <h:outputText value="textValue: #{formBean.textValue}" />
>>> 			
>>>     <!-- keep the text value -->
>>>     <h:inputHidden id="field_restore" value="#{formBean.textValue}" />
>>>
>>>     <!-- set the text value -->
>>>     <h:commandButton value="set data reload" immediate="true">
>>> 	<f:setPropertyActionListener target="#{formBean.textValue}" value="this
>>> is
>>> the text value" />
>>>     </h:commandButton>
>>>
>>>     <!-- simple reload -->
>>>     <h:commandButton value="simple reload"/><br/>
>>> 			
>>> </h:form>
>>>
>>>
>>> So I got 2 commandButtons: One ("set data reload") for setting
>>> "formBean.textValue" with an f:setPropertyActionListener and one
>>> ("simple
>>> reload") for just reloading the page (to check if the value get
>>> restored). I
>>> want "formBean.textValue" to be kept over the request. In every case a
>>> get
>>> back on the same page (no actions are invoked) 
>>>
>>> For restoring the value, I use a h:inputHidden ("field_restore") which
>>> is
>>> bound the request scoped bean ("formBean.textValue"). 
>>>
>>> So the scenario is like this:
>>> 1) Press "set data reload" 
>>> 2) check the output: the textValue is set and the h:outputText shows it
>>> 3) Press "simple reload"
>>> 4) check the output: the textValue is restored and the h:outputText
>>> shows it
>>>
>>> Everthing works as expected when I set immediate of ("set data
>>> reload")-commandButton to FALSE. 
>>> The value ist set and the output shows it. On a "simple reload" the
>>> value is
>>> restored an the output shows it again. If I look at the generated html
>>> code
>>> the hidden input-field is rendered with the textValue like this:
>>>
>>> <input type="hidden" value="this is the text"
>>> name="j_id110:field_restore"
>>> id="j_id110:field_restore"/>
>>>
>>> Now if I change the immediate-Flag to TRUE (which is necessary in my
>>> case to
>>> bypass some other validations) the behavior is like this:
>>> After pressing the "set data reload"-commandButton the value is set and
>>> the
>>> output shows it (like above). But now on the following "simple reload"
>>> the
>>> value gets lost! 
>>>
>>> Therefor I checked the hidden-input field after pressing "set data
>>> reload"
>>> and found the reason for not restoring the value - the hidden-input is
>>> rendered like this:
>>>
>>> <input type="hidden" value="" name="j_id110:field_restore"
>>> id="j_id110:field_restore"/>
>>>
>>> As you can see the value-Attribut is empty and therefor, nothing will be
>>> restored in the next (simple) request. The strange thing is, that after
>>> pressing "set data reload" the textValue on the bean is set  and the
>>> h:output shows the correct value, but only the hidden-field
>>> value-Attribute
>>> misses it.
>>>
>>> I can use t:saveState which solves the problem but I think in this
>>> situation
>>> it should really work by using h:inputHidden.
>>>
>>> Why is it not working with immediate set to true? When I debug the
>>> lifecyle
>>> I can see that the f:setPropertyActionListener for setting
>>> formBean.textValue is fired (in APPLY_REQUEST_PHASE instead of
>>> INVOKE_APPLIATION which is ok for immediate actions) and therefor the
>>> bean
>>> value is set correctly (which I can see on the output) but why is the
>>> value
>>> of the hidden field not rendered with this value?  
>>>   
>> 
>> What you see is exactly what is expected. The immediate flag is defined
>> by the spec as causing the associated action to be invoked *before*
>> doing a model update. In fact, that's the whole point of the immediate
>> flag. If the action navigates somewhere else, then no model updates are
>> done.
>> 
>> You might want to look at the tomahawk <t:saveState> component. It is
>> designed for carrying data from one page to another.
>> 
>> As a hack, you might also try setting immediate=true on your inputHidden
>> field. I think this will work as long as the immediate command component
>> comes later in the page than your hidden field. But it's ugly.
>> 
>> Regards,
>> Simon
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/inputHidden-is-not-rendered-correctly-on-immediate-action-tp17486716p17490818.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: inputHidden is not rendered correctly on immediate action

Posted by Jan Ziegler <zi...@top21.de>.
Hi Simon,

thanks for your answer. I´ll checked that article on myFaces and found some
interessting aspects.
But I still have some problems with understanding my case:

I understand, that the UPDATE_MODEL phase is skipped when immediate on the
commandButton is true, and therefor the bean isn´t updated in this phase BUT
my f:setPropertyActionListener updates the bean on APPLY_REQUEST phase so
the value IS set  (I can see it on the screen by h:outputText). So therefor
I think it should also be rendered as a value of the hidden-field because
RENDER_RESPONSE is handled as usual I think, even if immediate is set to
true on the command,  isn´t it?

I tested the following:
If I add an <h:inputText> to my form (bound to the same bean as the
hidden-field) and enter some text and perform the same steps as before on my
previous example then the value of this field IS restored on the "simple
reload" and with immediate=TRUE. The only difference is that this value is
entered manually and the value bound to the hidden-field ist set by the
setPropertyActionListener:

<!-- field (with manually entered text) is restored -->
<h:inputText id="field_restore2" value="#{formBean.textValue2}" />

<!-- field (with text set via actionListener) is not restored -->
<h:inputHidden id="field_restore" value="#{formBean.secondField}" />

Only the hidden field isn´t restored???

BTW I tried the hack with immediate=true on the hidden-field before, it also
doesn´t work. As I mentioned I can use t:saveState and it works, but it
would be more satifying to understand why the hidden-thing is not working in
this case.

Or maybe I just didn´t get the whole thing yet...

greetz
jan







simon.kitching@chello.at wrote:
> 
> Jan Ziegler schrieb:
>> Hi,
>>
>> I have a problem with h:inputHidden. I want to use it for keeping a
>> request
>> scope bean´s value from one request to another. The following code shows
>> a
>> simple example:
>>
>> <h:form>
>>     
>>     <!-- show the text value -->
>>     <h:outputText value="textValue: #{formBean.textValue}" />
>> 			
>>     <!-- keep the text value -->
>>     <h:inputHidden id="field_restore" value="#{formBean.textValue}" />
>>
>>     <!-- set the text value -->
>>     <h:commandButton value="set data reload" immediate="true">
>> 	<f:setPropertyActionListener target="#{formBean.textValue}" value="this
>> is
>> the text value" />
>>     </h:commandButton>
>>
>>     <!-- simple reload -->
>>     <h:commandButton value="simple reload"/><br/>
>> 			
>> </h:form>
>>
>>
>> So I got 2 commandButtons: One ("set data reload") for setting
>> "formBean.textValue" with an f:setPropertyActionListener and one ("simple
>> reload") for just reloading the page (to check if the value get
>> restored). I
>> want "formBean.textValue" to be kept over the request. In every case a
>> get
>> back on the same page (no actions are invoked) 
>>
>> For restoring the value, I use a h:inputHidden ("field_restore") which is
>> bound the request scoped bean ("formBean.textValue"). 
>>
>> So the scenario is like this:
>> 1) Press "set data reload" 
>> 2) check the output: the textValue is set and the h:outputText shows it
>> 3) Press "simple reload"
>> 4) check the output: the textValue is restored and the h:outputText shows
>> it
>>
>> Everthing works as expected when I set immediate of ("set data
>> reload")-commandButton to FALSE. 
>> The value ist set and the output shows it. On a "simple reload" the value
>> is
>> restored an the output shows it again. If I look at the generated html
>> code
>> the hidden input-field is rendered with the textValue like this:
>>
>> <input type="hidden" value="this is the text"
>> name="j_id110:field_restore"
>> id="j_id110:field_restore"/>
>>
>> Now if I change the immediate-Flag to TRUE (which is necessary in my case
>> to
>> bypass some other validations) the behavior is like this:
>> After pressing the "set data reload"-commandButton the value is set and
>> the
>> output shows it (like above). But now on the following "simple reload"
>> the
>> value gets lost! 
>>
>> Therefor I checked the hidden-input field after pressing "set data
>> reload"
>> and found the reason for not restoring the value - the hidden-input is
>> rendered like this:
>>
>> <input type="hidden" value="" name="j_id110:field_restore"
>> id="j_id110:field_restore"/>
>>
>> As you can see the value-Attribut is empty and therefor, nothing will be
>> restored in the next (simple) request. The strange thing is, that after
>> pressing "set data reload" the textValue on the bean is set  and the
>> h:output shows the correct value, but only the hidden-field
>> value-Attribute
>> misses it.
>>
>> I can use t:saveState which solves the problem but I think in this
>> situation
>> it should really work by using h:inputHidden.
>>
>> Why is it not working with immediate set to true? When I debug the
>> lifecyle
>> I can see that the f:setPropertyActionListener for setting
>> formBean.textValue is fired (in APPLY_REQUEST_PHASE instead of
>> INVOKE_APPLIATION which is ok for immediate actions) and therefor the
>> bean
>> value is set correctly (which I can see on the output) but why is the
>> value
>> of the hidden field not rendered with this value?  
>>   
> 
> What you see is exactly what is expected. The immediate flag is defined
> by the spec as causing the associated action to be invoked *before*
> doing a model update. In fact, that's the whole point of the immediate
> flag. If the action navigates somewhere else, then no model updates are
> done.
> 
> You might want to look at the tomahawk <t:saveState> component. It is
> designed for carrying data from one page to another.
> 
> As a hack, you might also try setting immediate=true on your inputHidden
> field. I think this will work as long as the immediate command component
> comes later in the page than your hidden field. But it's ugly.
> 
> Regards,
> Simon
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/inputHidden-is-not-rendered-correctly-on-immediate-action-tp17486716p17489203.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: inputHidden is not rendered correctly on immediate action

Posted by "simon.kitching@chello.at" <si...@chello.at>.
simon.kitching@chello.at schrieb:
> Jan Ziegler schrieb:
>   
>> Hi,
>>
>> I have a problem with h:inputHidden. I want to use it for keeping a request
>> scope bean´s value from one request to another. The following code shows a
>> simple example:
>>
>> <h:form>
>>     
>>     <!-- show the text value -->
>>     <h:outputText value="textValue: #{formBean.textValue}" />
>> 			
>>     <!-- keep the text value -->
>>     <h:inputHidden id="field_restore" value="#{formBean.textValue}" />
>>
>>     <!-- set the text value -->
>>     <h:commandButton value="set data reload" immediate="true">
>> 	<f:setPropertyActionListener target="#{formBean.textValue}" value="this is
>> the text value" />
>>     </h:commandButton>
>>
>>     <!-- simple reload -->
>>     <h:commandButton value="simple reload"/><br/>
>> 			
>> </h:form>
>>
>>
>> So I got 2 commandButtons: One ("set data reload") for setting
>> "formBean.textValue" with an f:setPropertyActionListener and one ("simple
>> reload") for just reloading the page (to check if the value get restored). I
>> want "formBean.textValue" to be kept over the request. In every case a get
>> back on the same page (no actions are invoked) 
>>
>> For restoring the value, I use a h:inputHidden ("field_restore") which is
>> bound the request scoped bean ("formBean.textValue"). 
>>
>> So the scenario is like this:
>> 1) Press "set data reload" 
>> 2) check the output: the textValue is set and the h:outputText shows it
>> 3) Press "simple reload"
>> 4) check the output: the textValue is restored and the h:outputText shows it
>>
>> Everthing works as expected when I set immediate of ("set data
>> reload")-commandButton to FALSE. 
>> The value ist set and the output shows it. On a "simple reload" the value is
>> restored an the output shows it again. If I look at the generated html code
>> the hidden input-field is rendered with the textValue like this:
>>
>> <input type="hidden" value="this is the text" name="j_id110:field_restore"
>> id="j_id110:field_restore"/>
>>
>> Now if I change the immediate-Flag to TRUE (which is necessary in my case to
>> bypass some other validations) the behavior is like this:
>> After pressing the "set data reload"-commandButton the value is set and the
>> output shows it (like above). But now on the following "simple reload" the
>> value gets lost! 
>>
>> Therefor I checked the hidden-input field after pressing "set data reload"
>> and found the reason for not restoring the value - the hidden-input is
>> rendered like this:
>>
>> <input type="hidden" value="" name="j_id110:field_restore"
>> id="j_id110:field_restore"/>
>>
>> As you can see the value-Attribut is empty and therefor, nothing will be
>> restored in the next (simple) request. The strange thing is, that after
>> pressing "set data reload" the textValue on the bean is set  and the
>> h:output shows the correct value, but only the hidden-field value-Attribute
>> misses it.
>>
>> I can use t:saveState which solves the problem but I think in this situation
>> it should really work by using h:inputHidden.
>>
>> Why is it not working with immediate set to true? When I debug the lifecyle
>> I can see that the f:setPropertyActionListener for setting
>> formBean.textValue is fired (in APPLY_REQUEST_PHASE instead of
>> INVOKE_APPLIATION which is ok for immediate actions) and therefor the bean
>> value is set correctly (which I can see on the output) but why is the value
>> of the hidden field not rendered with this value?  
>>   
>>     
>
> What you see is exactly what is expected. The immediate flag is defined
> by the spec as causing the associated action to be invoked *before*
> doing a model update. In fact, that's the whole point of the immediate
> flag. If the action navigates somewhere else, then no model updates are
> done.
>
> You might want to look at the tomahawk <t:saveState> component. It is
> designed for carrying data from one page to another.
>
> As a hack, you might also try setting immediate=true on your inputHidden
> field. I think this will work as long as the immediate command component
> comes later in the page than your hidden field. But it's ugly.
>   

BTW, you should probably read the link titled "How the Immediate
Attribute Works" on the myfaces wiki.

http://wiki.apache.org/myfaces

Regards,
Simon


Re: inputHidden is not rendered correctly on immediate action

Posted by "simon.kitching@chello.at" <si...@chello.at>.
Jan Ziegler schrieb:
> Hi,
>
> I have a problem with h:inputHidden. I want to use it for keeping a request
> scope bean´s value from one request to another. The following code shows a
> simple example:
>
> <h:form>
>     
>     <!-- show the text value -->
>     <h:outputText value="textValue: #{formBean.textValue}" />
> 			
>     <!-- keep the text value -->
>     <h:inputHidden id="field_restore" value="#{formBean.textValue}" />
>
>     <!-- set the text value -->
>     <h:commandButton value="set data reload" immediate="true">
> 	<f:setPropertyActionListener target="#{formBean.textValue}" value="this is
> the text value" />
>     </h:commandButton>
>
>     <!-- simple reload -->
>     <h:commandButton value="simple reload"/><br/>
> 			
> </h:form>
>
>
> So I got 2 commandButtons: One ("set data reload") for setting
> "formBean.textValue" with an f:setPropertyActionListener and one ("simple
> reload") for just reloading the page (to check if the value get restored). I
> want "formBean.textValue" to be kept over the request. In every case a get
> back on the same page (no actions are invoked) 
>
> For restoring the value, I use a h:inputHidden ("field_restore") which is
> bound the request scoped bean ("formBean.textValue"). 
>
> So the scenario is like this:
> 1) Press "set data reload" 
> 2) check the output: the textValue is set and the h:outputText shows it
> 3) Press "simple reload"
> 4) check the output: the textValue is restored and the h:outputText shows it
>
> Everthing works as expected when I set immediate of ("set data
> reload")-commandButton to FALSE. 
> The value ist set and the output shows it. On a "simple reload" the value is
> restored an the output shows it again. If I look at the generated html code
> the hidden input-field is rendered with the textValue like this:
>
> <input type="hidden" value="this is the text" name="j_id110:field_restore"
> id="j_id110:field_restore"/>
>
> Now if I change the immediate-Flag to TRUE (which is necessary in my case to
> bypass some other validations) the behavior is like this:
> After pressing the "set data reload"-commandButton the value is set and the
> output shows it (like above). But now on the following "simple reload" the
> value gets lost! 
>
> Therefor I checked the hidden-input field after pressing "set data reload"
> and found the reason for not restoring the value - the hidden-input is
> rendered like this:
>
> <input type="hidden" value="" name="j_id110:field_restore"
> id="j_id110:field_restore"/>
>
> As you can see the value-Attribut is empty and therefor, nothing will be
> restored in the next (simple) request. The strange thing is, that after
> pressing "set data reload" the textValue on the bean is set  and the
> h:output shows the correct value, but only the hidden-field value-Attribute
> misses it.
>
> I can use t:saveState which solves the problem but I think in this situation
> it should really work by using h:inputHidden.
>
> Why is it not working with immediate set to true? When I debug the lifecyle
> I can see that the f:setPropertyActionListener for setting
> formBean.textValue is fired (in APPLY_REQUEST_PHASE instead of
> INVOKE_APPLIATION which is ok for immediate actions) and therefor the bean
> value is set correctly (which I can see on the output) but why is the value
> of the hidden field not rendered with this value?  
>   

What you see is exactly what is expected. The immediate flag is defined
by the spec as causing the associated action to be invoked *before*
doing a model update. In fact, that's the whole point of the immediate
flag. If the action navigates somewhere else, then no model updates are
done.

You might want to look at the tomahawk <t:saveState> component. It is
designed for carrying data from one page to another.

As a hack, you might also try setting immediate=true on your inputHidden
field. I think this will work as long as the immediate command component
comes later in the page than your hidden field. But it's ugly.

Regards,
Simon