-
1. Re: Using Identity Management API with User class that has other required fields
shane.bryzak Oct 16, 2008 3:31 PM (in response to hermida.leandro.hermida.gmail.com)Write an observer for JpaIdentityStore.EVENT_PRE_PERSIST_USER (see section 15.4.2.4.1 in the security chapter). -
2. Re: Using Identity Management API with User class that has other required fields
hermida.leandro.hermida.gmail.com Oct 16, 2008 4:34 PM (in response to hermida.leandro.hermida.gmail.com)Hi and thanks again Shane
Sorry again I did miss that lot's of stuff in the ref docs. It works perfectly, for other newbies out there I simply put a method inside the appropriate session bean (in my case RegisterActionImpl.java) which looks like this:
@Observer(JpaIdentityStore.EVENT_PRE_PERSIST_USER) public void prePersistUserEvent(User prePersistedUser) { prePersistedUser.setEmail(registerUser.getEmail()); // other required fields can be set here too }
where registerUser is a local field with getter/setter that was backing the form (i.e. #{registerAction.registerUser.email}, etc).
-
3. Re: Using Identity Management API with User class that has other required fields
tognado Feb 11, 2009 12:43 PM (in response to hermida.leandro.hermida.gmail.com)Hello Leandro (are you Brazilian ?)
here in http://www.seamframework.org/Community/IdentityManagerUsefulForNonDefaultUseCase i asked the same thing you did, but i couldn't solve it, yet.
i want an
email
field in my user form, so i coded in userdetail.xhtml<h:outputLabel for="userEmail" value="Email" styleClass="formLabel"/> <h:inputText id="userEmail" value="#{userEmail}" readonly="#identityManager.userExists(userAction.username)}"/> <h:message for="userEmail" styleClass="validationError"/>
and in my User.java
public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } @Observer("org.jboss.seam.security.management.prePersistUser") public void onPrePersist(User prePersistedUser) { prePersistedUser.setEmail(#####); } @Observer("org.jboss.seam.security.management.userCreated") public void onUserCreated(User user) { }
As you may have noted, i don't know how to get the email value, since i
invented
this field (named userEmail) in the xhtml (naturally userAction.email doesn't exist). Should i declare userEmail somewhere ?Thanks,
Thiago