myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Ziegler <zieg...@top21.de>
Subject Re: inputHidden is not rendered correctly on immediate action
Date Tue, 27 May 2008 09:42:02 GMT

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.


Mime
View raw message