|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
inputHidden and disabled form fields are lostI 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 lostI 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é |
|
|
AW: inputHidden and disabled form fields are lostI 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@...] Gesendet: Dienstag, 11. Dezember 2007 10:53 An: users@... Betreff: Re: inputHidden and disabled form fields are lost > ---- "René Günther" <rene.guenther@...> 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 lostThanks 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 |
|
|
Re: inputHidden and disabled form fields are lostHello 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 <rene.guenther@...> wrote:
|
|
|
Re: AW: inputHidden and disabled form fields are lostYou 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.
|
| Free embeddable forum powered by Nabble | Forum Help |