This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes JSF - input field is not updated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF - input field is not updated" Watch "JSF - input field is not updated" New topic
Author

JSF - input field is not updated

Peter Penzov
Greenhorn

Joined: Jul 19, 2011
Posts: 10
I have a problem with a JSF page which I can't solve. I have a JSF page which is used to store application settings into database table. This is the source code of the JSF page:



And this is the managed bean:



This is the problem that I face:

When I open the JSF page I get these menus:



Then I select custom from the menu:



I get this input field next to the menu:



Then I enter custom value from the keyboard:



But when I click Save button I get this. I can see that the database field is updated but the values is "custom"



When I enter the same twice value I get this:



I seems that when I click custom and I enter the custom value the HashMap is not updated. It's strange that when I do it again the HashMap is updated and the value is correct. How I can fix this problem?

I tried to reload the map from the DB after save. Basically, I called initSettings() in the end of updateDBSettings() but there was no change.

Best Wishes


Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

It's cleaner to use a 1-column panelGrid instead of raw HTML div elements for your framing.

It's a LOT cleaner to keep the JDBC code out of the backing bean and in its own bean.

It's also not recommended to give a backing bean a name that starts with a capital letter. Since a backing bean is an instance, not a class, the style rules dictate that the first letter should be lowercase. Failure to observe this convention may cause some tools to whine and/or malfunction.

What's probably cause your actual problem, however is that you coded the action as "#{ApplicationController.updateDBSettings()}". Lose the "()".

Finally, remember that if any element of a submitted form contains invalid data, the backing bean will not be updated and the action will not be invoked.


Customer surveys are for companies who didn't pay proper attention to begin with.
Peter Penzov
Greenhorn

Joined: Jul 19, 2011
Posts: 10
I edited the code as you recommended but I still get the same problem. Would you look at the AJAX code. Is there something missing?

Best wishes
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

Peter penzov wrote:I edited the code as you recommended but I still get the same problem. Would you look at the AJAX code. Is there something missing?

Best wishes


I regret to report that I never really developed expertise with the new ajax tag. I have been using RichFaces and they developed their own AJAX support for JSF1, which still works cleanly under JSF2, so I haven't felt the need to switch.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF - input field is not updated
 
Similar Threads
JSF - Missing source code using templating and composition
Selecting option in second selectOneMenu not setting property value
Passing a Parameter via Ajax
Multipart request problem
CommandButton doesn't call bean's method