You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 25 Members of 4546 |
| Forum: Seam Users |
24. Jun 2008, 14:05 CET | Link |
I do have an Entity User
and a corresponding UserHome
with manual flushing enabled:
@Name("userHome")
@Scope(ScopeType.CONVERSATION)
public class UserHome extends EntityHome<User> {
...
@In(create=true ) private EntityInfoManager entityInfoManager;
private String pw1, pw2;
...
@Override
public String update() {
final User u = getInstance();
...
if (someCondition) {
return null;
} else {
u.setUserPassword(PasswordUtil.generateRandomSaltMd5Digest(pw1));
}
getEntityManager().flush();
return super.update();
}
@Override
@Begin(flushMode=FlushModeType.MANUAL, join=true)
public void create() {
super.create();
//business logic code omitted
}
}
The corresponding view user.xhtml contains:
<h:commandButton id="update" value="Update" action="#{userHome.update}"
rendered="#{userHome.managed}" />
The User entity references other entities that may or may not be changed in the conversation and so far it works.
Now I want to display this update button shaded as long as no entity has been changed. In other words: I want to know if the User instance object or any referenced object within the conversation is in a dirty state.
I searched the Seam documentation and this (plus the former) Seam user's forum but did not find any hint.
Haven't tried, but falling back to the hibernate session should work:
((Session)entityManager.getDelegate()).isDirty()
This works for me, thanks!