Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic