Help coderanch get a
new server
by contributing to the fundraiser
  • 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

JSF problem with form (update user)

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
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
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It does not matter. Method does not calls at any case.
 
Saloon Keeper
Posts: 28053
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic