File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF problem with form (update user)

 
Oleksandr Hubachov
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3222
12
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Oleksandr Hubachov
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does not matter. Method does not calls at any case.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17624
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Oleksandr Hubachov
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic