I have facelets page with a control that usually is disabled by default, i. e. when the page is first rendered to the client. This is determined by an EL expression:
disabled="#{referenceValue != requestbean.dependentControlValue}" id="notWorking"
After the page is rendered, the user can set the requestbean.dependentControlValue
to referenceValue
and via some Javascript for the dependent control, the component "notWorking" is enabled.
However, upon submitting the form the value for notWorking
does not get updated as found out by adding a debug log message in the setter for the value. I can see, that the value for notWorking
is set in the request when inspecting it with firefox.
Question: What am I doing wrong?
By the way:
I know that according to HTML specification, disabled controls cannot be successful thanks to the research here on StackOverflow.
Moreover, I know from this post, that the disabled
and rendered
expressions are considered before updating the model values, but I think the disabled expression should evaluate to false
upon submitting the form.
What am I doing wrong?
Using JavaScript instead of JSF to re-enable the input.
As part of JSF's builtin safeguard against tampered/hacked HTTP requests, the disabled
attribute is (like rendered
and readonly
attributes) re-evaluated during processing the form submit. If they evaluate in such way that the value shouldn't be processed at all (i.e. disabled/readonly=true
and rendered=false
, then the submitted value won't be applied, converted, validated and the model won't be updated.
The solution would be to use JSF instead of JavaScript to re-enable the input, or to rewrite the condition in disabled
attribute in such way so that the disabled
attribute evaluates false
during processing the form submit.