This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JSF and the fly likes JSF problem with form (update user) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF problem with form (update user)" Watch "JSF problem with form (update user)" New topic
Author

JSF problem with form (update user)

Oleksandr Hubachov
Greenhorn

Joined: Jun 16, 2013
Posts: 3
Hi, all. I'm new in JSF and hope on your help. My task is to write simple CRUD application (JSF+Hibernate). I have a problem with Update operation. On page I choose user to update, than click button Update. Opens page with form, where all field filled of user information. Than I change something and click Update. But form become clean and method update() in bean does not calls. When I click to this button second time, this method is called, but i need to write user information manually. Why method does not calls first time? Code:
List of users:


Page of update:



Bean class


Thanks for your answers
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1973
    
    7

Why does your update() method call "update(contructUser())"? And in your constructUser() method, you are doing new User()... so when you call update, it will create a new instance of User making the original data lost.

In your JSF page you can call update(user) directly and pass in the user object to your bean. That way you can simply do session.update(user).


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7
Oleksandr Hubachov
Greenhorn

Joined: Jun 16, 2013
Posts: 3
It does not matter. Method does not calls at any case.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15662
    
  15

The following constructs are incorrect:



The primary purpose of EL is not to act as a programming language, it is to permit specifying bean property or method references. So, for example, your commandButton should be coded like this:


You did not indicate how (or even if) you associated class UserBean with the EL object named "user". So we need to see the bean annotations or faces-config.xml entry that defines the UserBean as a JSF Managed Bean.


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

Joined: Jun 16, 2013
Posts: 3
Thanks for your answers. I find an error. This method working correctly (even action="#{user.load()}" and action="#{user.load()}"). Problem is in p:calendar and p:selectOneMenu . I need to write right converter, but i don't know how. If i delete from page information about gender, nationality and birthday, all will be ok. I will google and post here a solution.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF problem with form (update user)
 
Similar Threads
Run the MethodeBean & display the fields that corresponds to selectMenu
Composite Components: relationship between them!
Primefaces: How to insert an object attributes on a PanelGrid?
multiple form in xhtml page nad update different controlls on two different forms
Unable to populate values obtained from ajax call using PrimeFaces