You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by rabolfazl <ra...@yahoo.com> on 2008/09/05 20:40:38 UTC

Re: AW: inputHidden and disabled form fields are lost

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.