• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF form POSTed data not stored in the bean (sometimes)

 
YinLi Tao
Greenhorn
Posts: 7
Debian Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a simple form whose data gets changed with JavaScript. When the readonly attribute is set to true on one of the fields the data does not propagate to the bean.

Complete code below.

Index page:



Page 1 with a bit of JavaScript in it and the readonly attribute on the input field:



Page 2:



The controller:



The bean:



Whether the readonly attribute is set to true or not the POST data looks similar (good) in both cases when I go from page 1 to page 2:

POST wrote:
aForm aForm
aForm:firstName a
aForm:j_idt10 Go to second page
aForm:lastName injected comment 1
javax.faces.ViewState -8046861354365775552:5685256088338501791


However, the controller will print the following (bad) when the readonly attribute is set to true:

Controller wrote:
INFO: User{firstName=a, lastName=b}
INFO: User{firstName=a, lastName=b}


and this (good) when it is not:

Controller wrote:
INFO: User{firstName=a, lastName=b}
INFO: User{firstName=a, lastName=injected comment 1}


What is the problem?
 
YinLi Tao
Greenhorn
Posts: 7
Debian Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using



instead of



solved the problem.

Here is why.
 
K. Tsang
Bartender
Posts: 3604
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad you solved your problem. The behavior you described for "readonly" fields also happen for "disabled" fields.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!