Forums Register Login

JSF input text readonly issue

+Pie Number of slices to send: Send
Hi All,

I have one input text field. Its readonly attribute is set to true. The value in this field is "JAVA RANCH".

Now using javascript I make thsi field enable by setting readonly="false".

After enabling this field, I enter some new data like "SUN JSF".

When I click on the submit button the backing bean is not getting update with the new value "SUN JSF". The set method of the bean whcih is associtaed with this field is not called.

My backing bean is in session scope.

any idea why this data is not submitted to server even though the feild is now enabled?

Thanks,
vebs
+Pie Number of slices to send: Send
I am not absolutely sure but the fact is that the on form submit the form actually submits to the same page in the server. From the page depending on the action, event the flow is decided. In this case the HTML rendered view in the browser is no doubt editable but the component in the faces page in server is still a readonly. JSF knows it is readonly so do not attempt to check for its value change and updating the backing bean. I think this is the reason.

Regards.
+Pie Number of slices to send: Send
Don't set the JSF input field to "readonly", instead use javascript to set the field to element.readOnly=true; in the onload() function.
+Pie Number of slices to send: Send
Settting stuff like this (including enabling/disabling) can lead to problems, because JSF may render the underlying HTML in different ways. Some of which can lead to real problems, because the HTML you want to change may not match what the JavaScript can modify, or the server and client conceptions of what's enabled/visible/read-only may no longer be in sync.
"I know this defies the law of gravity... but I never studied law." -B. Bunny Defiant tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 13958 times.
Similar Threads
InputText in facelets repeat not updated with empty value
Inputfield in ui:repeat
JSF Variable State: Odd Behavior
Page not getting submitted if my text box is not part of backing bean...
JSF input text readonly issue
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:05:39.