Seam not applying values to entity
seamsvictom Jan 30, 2009 6:17 PMHi
I am having some real strange issues any help will be appreciated. Here is the scenario:
On first page i have a s:link i start conversation here using propagation begin. Then on next page i show list of all Users. User is an entity class with name as user. Here the list is shown using datatable and i use @Model and @Factory annotations to display list of users. It is working fine. This action is stateful.
Then when someone clicks on any user, I outject a User object. Here is some excerpt from my action class. I am not listing all the code to shorten the post as much as possible
@Stateful @Name("usersListAction") @Restrict("#{s:hasRole('Admin')}") public class UsersListAction implements UserListLocal { @PersistenceContext(type=PersistenceContextType.EXTENDED) private EntityManager entityManager; @DataModel private List<User> userList; @DataModelSelection private User modelUser; @Out(required=false, value="selectedUser") private User mUser;
Here is the method which gets invoked when the link is clicked
@Begin(join=true) public void selectUser() { this.mUser = modelUser; }
This mUser object is outjected and i am displaying details of selected user on next page so that administrator can edit the details. Here is the code from next class:
@Stateful @Name("userDetailAction") @Restrict("#{s:hasRole('Admin')}") public class UserDetailAction implements UserDetailLocal { @In(required=false, value="selectedUser") private User selectedUser; @PersistenceContext(type=PersistenceContextType.EXTENDED) private EntityManager em;
Here comes the problem. It displays the values perfectly fine on my xhtml and i've bound the values of h:inputText fields with selectedUser.firstName etc. Now when i use h:commandButton and call editUser action. It doesn't work. The action is not called at all. Here is the action method in UserDetailAction class above:
@End public void editUser() { em.merge(selectedUser); }
But when i use s:button the action is called perfectly alright but this time the values are not applied to the bean, it is still loading old values and em.merge does nothing. I have turned the show sql property ON but i can't see any update statement only select ones. May be it is due to the fact that seam is not applying values to entity so entity is not changed and update is not called. I am really stuck with this one. Please help, it is pissing me off. I have tried everything even defined attributes in UserDetailAction with firstName, lastName etc and then set them into entity but still em.merge does nothing. I have tried to make my beans stateless but still no success.
Thanks