Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF - input field is not updated

 
Peter Penzov
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Peter Penzov
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic