[jboss-user] [JBoss Seam] - Re: login & logout options
caye
do-not-reply at jboss.com
Mon Jul 30 08:59:37 EDT 2007
I have been working with it and the login works perfectly with the solution that Ricardo gave me (thanks a lot!), but the logout is a little bit more difficult, it looks like its impossible to persist the object if i try to do it using the org.jboss.seam.preDestroyContext.SESSION. I have been reading one post of you Ricardo and it seems that you fixed making a stateless session bean and changing the entityManager to @PersistenceContext instead of @In.
But for me i dont know why doesn't work, is it possible to check out somewhere the events that occur when someone login/out? Then i can try to use the @Observer that seems a better way
This is the code:
components.xml
<event type="org.jboss.seam.preDestroyContext.SESSION">
| <action expression="#{userHandler.setLogoutDate(authenticatedUser)}"/>
| </event>
UserHandler
public void setLogoutDate(CustomUser user) {
| int numberDates = user.getUserstatistics().getLoginDates().size();
| CustomDate loginDates = user.getUserstatistics().getLoginDates().get(numberDates-1);
| em.merge(loginDates);
| loginDates.setLoggedOut(new Date());
| Date timeBetween = new Date(); timeBetween.setTime(loginDates.getLoggedIn().getTime()-loginDates.getLoggedOut().getTime());
| loginDates.setTimeBetween(timeBetween);
| em.persist(loginDates);
| em.flush();
| log.info("User logged out at "+loginDates.getLoggedOut().toString());
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068710#4068710
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4068710
More information about the jboss-user
mailing list