• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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

 
Greenhorn
Posts: 7
Netbeans IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using



instead of



solved the problem.

Here is why.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad you solved your problem. The behavior you described for "readonly" fields also happen for "disabled" fields.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic