You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by René Günther <re...@innflow.com> on 2007/12/11 09:40:22 UTC

inputHidden and disabled form fields are lost

I am updating an object with a JSF form. I got some inputHidden fields and
one selectOneMenu which is disabled when I update (instead of adding) the
object. I got some required fields. If I clear the content of a required
field and submit the form, the values of inputHidden fields and of the
disabled selectOneMenu are lost in the response. If I just update some data
without omitting a required field everything works fine: so the setter
methods seem to work but when rendering the response after validation
errors, the getter methods for the inputHidden fields return null.

Any suggestions what I could do?

I am using:
myfaces-impl-1.2.0.jar
myfaces-api-1.2.0.jar
tomahawk-1.1.6.jar

Regards
René


Re: inputHidden and disabled form fields are lost

Posted by Simon Lessard <si...@gmail.com>.
Hello René,

Simply because we didn't use Tomahawk at all in those project and it was
simple to code. t:saveState should work perfectly fine as well.


Regards,

~ Simon

On Dec 11, 2007 1:30 PM, Rene Guenther <re...@innflow.com> wrote:

>
>
>
>
> Simon Lessard wrote:
> >
> > . The most common terminology we used was along
> > the lines of:
> >
> > <inputHidden flash="true"/>
> > <flashInputHidden/>
> > <contextValue/>
> >
> >
>
> Thanks Simon.
> Is there a reason why you dont use tomahawks saveState instead? Because I
> am
> thinking about using this tag instead of inputHidden then.
>
> Regards
> Rene
> --
> View this message in context:
> http://www.nabble.com/inputHidden-and-disabled-form-fields-are-lost-tp14269886p14280056.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: inputHidden and disabled form fields are lost

Posted by Rene Guenther <re...@innflow.com>.



Simon Lessard wrote:
> 
> . The most common terminology we used was along
> the lines of:
> 
> <inputHidden flash="true"/>
> <flashInputHidden/>
> <contextValue/>
> 
> 

Thanks Simon.
Is there a reason why you dont use tomahawks saveState instead? Because I am
thinking about using this tag instead of inputHidden then.

Regards
Rene
-- 
View this message in context: http://www.nabble.com/inputHidden-and-disabled-form-fields-are-lost-tp14269886p14280056.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: inputHidden and disabled form fields are lost

Posted by Simon Lessard <si...@gmail.com>.
Hello René,

It works as expected. inputHidden, unlike the output, gets a local value
from the 3 that's being submitted with the form. Since local value when
validation fails, the old value can be rendered back. This is, alas, a weak
point of JSF here. Even if you set the inputHidden as immediate, it still
won't push the value back to the model until update value phase. To go
around that nuisance, we created a truly immediate inputHidden in some of
our projects that does everything during apply request values and does
nothing during the process validations and update model phase. The same
strategy would fix your issue. The most common terminology we used was along
the lines of:

<inputHidden flash="true"/>
<flashInputHidden/>
<contextValue/>


Regards,

~ Simon


On Dec 11, 2007 12:48 PM, René Günther <re...@innflow.com> wrote:

> I found out that this related to the validation. The field of the
> inputHidden is not lost.
>
> The code for inputHidden is:
> <h:inputHidden id="version" value="#{userForm.user.version}">
> This component works correct.
>
> But something like:
> <h:outputText value="Version: #{userForm.user.version}" />
> wont work as expected
>
> If I submit the form and some other required field is not provided, the
> validation fails, then userForm.user.version is NULL for the component
> <h:outputText> but <h:inputHidden> is rendered with the correct value (
> userForm.user.version != NULL). Eg the HTML sourcecode after failing
> validation is something like
>
> <input type="hidden" id="userForm:version" name="userForm:version"
> value="3" />
> Version:
>
> Where I expect it to be:
>
> <input type="hidden" id="userForm:version" name="userForm:version"
> value="3" />
> Version: 3
>
> I guess it has something to do with some other libraries I am using. Any
> suggestions where I should start searching? Or could you recommend to
> replace all inputHidden with saveState?
>
> Thanks
> René
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Rene Guenther [mailto:rene.guenther@innflow.com]
> Gesendet: Dienstag, 11. Dezember 2007 10:53
> An: users@myfaces.apache.org
> Betreff: Re: inputHidden and disabled form fields are lost
>
>
>
>
> > ---- "René Günther" <re...@innflow.com> schrieb:
> >> I am updating an object with a JSF form. I got some inputHidden fields
> >> and
> >> one selectOneMenu which is disabled when I update (instead of adding)
> the
> >> object. I got some required fields. If I clear the content of a
> required
> >> field and submit the form, the values of inputHidden fields and of the
> >> disabled selectOneMenu are lost in the response. If I just update some
> >> data
> >> without omitting a required field everything works fine: so the setter
> >> methods seem to work but when rendering the response after validation
> >> errors, the getter methods for the inputHidden fields return null.
> >>
> >> Any suggestions what I could do?
> >>
> >
> > I'm not sure what is happening with your hidden fields. Those are not
> > marked "disabled" are they?
> >
> >
>
> I forgot about the side effects of the disabled property. But the hidden
> fields are not disabled and they only get lost when validation errors
> occur.
> If I "replace" inputHidden with saveState it works.
>
> Regards
> René
>
>
> --
> View this message in context:
> http://www.nabble.com/inputHidden-and-disabled-form-fields-are-lost-tp14269886p14270828.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: AW: inputHidden and disabled form fields are lost

Posted by rabolfazl <ra...@yahoo.com>.
You are doing it the right way. The problem is with JSF lifecycle. On any
validation error which is detected in "Process Validation Phase" the next
phase "Update Model Values" is bypassed so model values (typically bean
properties) are not updated. So if a value is not saved in View State then
it'll be lost! For example after a server-side validation failure, inputText
values are preserved in the resulting view but outputText values are empty.
Also if you rely on an inputHidden value to be set in some bean property to
render the resulting view (e.g. some inputHidden for the ID of an entity the
page is designed to edit), this will not work.


Rene Guenther wrote:
> 
> I found out that this related to the validation. The field of the
> inputHidden is not lost.
> 
> The code for inputHidden is:
> <h:inputHidden id="version" value="#{userForm.user.version}">
> This component works correct.
> 
> But something like:
> <h:outputText value="Version: #{userForm.user.version}" />
> wont work as expected
> 
> If I submit the form and some other required field is not provided, the
> validation fails, then userForm.user.version is NULL for the component
> <h:outputText> but <h:inputHidden> is rendered with the correct value
> (userForm.user.version != NULL). Eg the HTML sourcecode after failing
> validation is something like
> 
> <input type="hidden" id="userForm:version" name="userForm:version"
> value="3" />
> Version: 
> 
> Where I expect it to be:
> 
> <input type="hidden" id="userForm:version" name="userForm:version"
> value="3" />
> Version: 3
> 
> I guess it has something to do with some other libraries I am using. Any
> suggestions where I should start searching? Or could you recommend to
> replace all inputHidden with saveState?
> 
> Thanks
> René
> 
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Rene Guenther [mailto:rene.guenther@innflow.com] 
> Gesendet: Dienstag, 11. Dezember 2007 10:53
> An: users@myfaces.apache.org
> Betreff: Re: inputHidden and disabled form fields are lost
> 
> 
> 
> 
>> ---- "René Günther" <re...@innflow.com> schrieb:
>>> I am updating an object with a JSF form. I got some inputHidden fields
>>> and
>>> one selectOneMenu which is disabled when I update (instead of adding)
>>> the
>>> object. I got some required fields. If I clear the content of a required
>>> field and submit the form, the values of inputHidden fields and of the
>>> disabled selectOneMenu are lost in the response. If I just update some
>>> data
>>> without omitting a required field everything works fine: so the setter
>>> methods seem to work but when rendering the response after validation
>>> errors, the getter methods for the inputHidden fields return null.
>>> 
>>> Any suggestions what I could do?
>>> 
>> 
>> I'm not sure what is happening with your hidden fields. Those are not
>> marked "disabled" are they?
>> 
>> 
> 
> I forgot about the side effects of the disabled property. But the hidden
> fields are not disabled and they only get lost when validation errors
> occur.
> If I "replace" inputHidden with saveState it works.
> 
> Regards
> René
> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/inputHidden-and-disabled-form-fields-are-lost-tp14269886p14270828.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/inputHidden-and-disabled-form-fields-are-lost-tp14269886p19337213.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


AW: inputHidden and disabled form fields are lost

Posted by René Günther <re...@innflow.com>.
I found out that this related to the validation. The field of the inputHidden is not lost.

The code for inputHidden is:
<h:inputHidden id="version" value="#{userForm.user.version}">
This component works correct.

But something like:
<h:outputText value="Version: #{userForm.user.version}" />
wont work as expected

If I submit the form and some other required field is not provided, the validation fails, then userForm.user.version is NULL for the component <h:outputText> but <h:inputHidden> is rendered with the correct value (userForm.user.version != NULL). Eg the HTML sourcecode after failing validation is something like

<input type="hidden" id="userForm:version" name="userForm:version" value="3" />
Version: 

Where I expect it to be:

<input type="hidden" id="userForm:version" name="userForm:version" value="3" />
Version: 3

I guess it has something to do with some other libraries I am using. Any suggestions where I should start searching? Or could you recommend to replace all inputHidden with saveState?

Thanks
René



-----Ursprüngliche Nachricht-----
Von: Rene Guenther [mailto:rene.guenther@innflow.com] 
Gesendet: Dienstag, 11. Dezember 2007 10:53
An: users@myfaces.apache.org
Betreff: Re: inputHidden and disabled form fields are lost




> ---- "René Günther" <re...@innflow.com> schrieb:
>> I am updating an object with a JSF form. I got some inputHidden fields
>> and
>> one selectOneMenu which is disabled when I update (instead of adding) the
>> object. I got some required fields. If I clear the content of a required
>> field and submit the form, the values of inputHidden fields and of the
>> disabled selectOneMenu are lost in the response. If I just update some
>> data
>> without omitting a required field everything works fine: so the setter
>> methods seem to work but when rendering the response after validation
>> errors, the getter methods for the inputHidden fields return null.
>> 
>> Any suggestions what I could do?
>> 
> 
> I'm not sure what is happening with your hidden fields. Those are not
> marked "disabled" are they?
> 
> 

I forgot about the side effects of the disabled property. But the hidden
fields are not disabled and they only get lost when validation errors occur.
If I "replace" inputHidden with saveState it works.

Regards
René


-- 
View this message in context: http://www.nabble.com/inputHidden-and-disabled-form-fields-are-lost-tp14269886p14270828.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: inputHidden and disabled form fields are lost

Posted by Rene Guenther <re...@innflow.com>.


> ---- "René Günther" <re...@innflow.com> schrieb:
>> I am updating an object with a JSF form. I got some inputHidden fields
>> and
>> one selectOneMenu which is disabled when I update (instead of adding) the
>> object. I got some required fields. If I clear the content of a required
>> field and submit the form, the values of inputHidden fields and of the
>> disabled selectOneMenu are lost in the response. If I just update some
>> data
>> without omitting a required field everything works fine: so the setter
>> methods seem to work but when rendering the response after validation
>> errors, the getter methods for the inputHidden fields return null.
>> 
>> Any suggestions what I could do?
>> 
> 
> I'm not sure what is happening with your hidden fields. Those are not
> marked "disabled" are they?
> 
> 

I forgot about the side effects of the disabled property. But the hidden
fields are not disabled and they only get lost when validation errors occur.
If I "replace" inputHidden with saveState it works.

Regards
René


-- 
View this message in context: http://www.nabble.com/inputHidden-and-disabled-form-fields-are-lost-tp14269886p14270828.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.