• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF input text readonly issue  RSS feed

 
Vaibhav Deshpande
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kaustabh Singha Roy
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Frank Garber
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't set the JSF input field to "readonly", instead use javascript to set the field to element.readOnly=true; in the onload() function.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!