0 Replies Latest reply on Jul 8, 2013 1:37 PM by sharkey6

    EditBean problem Seam + jsf

    sharkey6

      Hey everyone, I'm beginner in seam, so I have created a small application but i have a problem. My backing beans are RequestScoped, and when i want edit sam records from the table in new page i can use f:setPropertyActionListener in commandButton (for example when I'm editing User I send user_id and I get User by Dao). In new page my values are set properly, but when I click "save" button, my backing bean is create as new in PostConstruct (User user = new User() ), and I lost information sending by previous page (user_id). I want to use one backing bean - UserBean to edit and create new user, so my construct should look like

       

      @Stateful

      @Model

      Public class MemberBean {

      .

      .

       

       

      @Inject

      private UserDao userDao;

      private User user;

      private Long userId;

       

      .

      .

      @PostConstruct

      public void initNewMember() {

           if(userId == null)

                 user= new User();

           else

                   user= UserDao.findById(User.class,userId) ;

           }

      }

       

      But I don't know how to implement this one. I'm thinging about Conversation Scopet instead RequestScoped, but i don't know if it's good idea. Is any good idea to do this with @RequestScoped?