Problem with apply request values phase

Adeel Ansari

Ranch Hand

Posts: 2874

posted 11 years ago

Hey folks,

My application is going great. The problem occurs, when I disable any of the input field in the html form due to any reason, say through javascript dynamically. Now as request processing life cycles says:

Restore View ----- > Apply Request Values

Its fine but I am getting the disabled field as null. I want the previous value of the field if the field is disabled in its current state.

Moreover, some of my .NET mates told me that in ASP.NET its simple and straight. If some field becomes disabled then the previous value is treated. And saying something about viewState stuff. I am not at all familiar with ASP.NET.

Do we have something to handle this within the JSF? Any solution with in the framework?

Please help me out, as I am new to JSF and its not really handy to me.

Varun Khanna

Ranch Hand

Posts: 1400

posted 11 years ago

Disabled fields aren't submitted as JSF doesn't feels the need of storing "read-only" fields at the server side and probably rightly so?

One of the alternate approach would be doing it in an old JSP way by using hidden variables (i.e. JSF hidden variables)

Another bad approach would be to let the state be non-disabled at the server side and in UI let javascript disable it during onload of page and while submitting enable it back :roll:

- Varun

Adeel Ansari

Ranch Hand

Posts: 2874

posted 11 years ago

Disabled fields aren't submitted as JSF doesn't feels the need of storing "read-only" fields at the server side and probably rightly so?

readonly is working like charm. disabled is not working .

Varun Khanna

Ranch Hand

Posts: 1400

posted 11 years ago

Oops, by "readonly" I meant non-EditableValueHolder and disabled components. I didn't mean component with readonly attribute set as true.