You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Oscar Picasso <os...@yahoo.com> on 2006/05/04 14:15:02 UTC

List of logged users

Hi,

I am looking for advises on how to implement a use case that is, think, quite common.

In my application users can log in. They can also loggout either explicitly or because of session timeout.

In one part of my application I want to display the total number of logged users and a list of each of these users.

My main problem is how to remove an user from the list when he is logged out implicitly by a  session timeout.

How would you solve this ?

Thanks

		
---------------------------------
How low will we go? Check out Yahoo! MessengerÂ’s low  PC-to-Phone call rates.

PropertyselectionModel Q

Posted by Peter Verhoye <pe...@synergetic-solutions.be>.
Hi all,

I'm trying to do the following:

We have an object (Account) which contains an other object (Language).
To edit the account, I've created an accountEdit page where I want to
have a dropdown box that shows the list of languages one can set for an
account. But, I want the list to be set to the language the account
already has if available.
So, I've already created the following:

public class LanguageSelectionModel implements IPropertySelectionModel,
Serializable {
	private static final long serialVersionUID = -3912209045599735086L;

	private List<Language> languageList;

	private String languageId;

	public LanguageSelectionModel(List<Language> languageList, String
languageId) {
		this.languageList = languageList;
		this.languageId = languageId;
	}

	public int getOptionCount() {
		return languageList.size();
	}

	public Object getOption(int index) {
		return languageList.get(index);
	}

	public String getLabel(int index) {
		return languageList.get(index).getDescription(languageId);
	}

	public String getValue(int index) {
		return Integer.toString(index);
	}

	public Object translateValue(String value) {
		 return getOption(Integer.parseInt(value));
	}
}

In the AccountEdit.page file I have this:
<component id="language" type="PropertySelection">
	<binding name="model" value="availableLanguages"/>
	<binding name="value" value="account.language"/>
</component>


In the AccountEdit.java file I have the following:
public IPropertySelectionModel getAvailableLanguages() {
	String languageId =
getVisitObject().getContactPerson().getLanguage().getId();
	return new LanguageSelectionModel(getLanguageDAO().findLanguages(),
languageId);
}

Now, this all seems to work except that the combobox does not get
initialised on the correct Language object. Now, I think I know why but
I don't know how I should initialise the PropertySelectionModel.

Anyway has an idea or so?

Thank you!!

BB
Peter



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: List of logged users

Posted by Martijn Hinten <ma...@cumquat.nl>.
Implement a HttpSessionListener. This listener will be notified of all 
sessions that are destroyed (it's sessionDestroyed() method will be 
called). In that method you can check which user is logged off en remove 
that user from the (applicationscope, I guess) list.

See code sample below.

Good luck,
Martijn

An example of a session listener that just counts sessions:

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class SessionWatcher implements HttpSessionListener {

private static final Log log = LogFactory.getLog(HttpSessionListener.class);

private static int activeSessions = 0;

/*
* @see 
javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent)
*/
public void sessionCreated(HttpSessionEvent event) {
activeSessions++;

log.debug("Session created with id:"+event.getSession().getId()
+". No of active sessions:"+activeSessions);
System.out.println("Session created with id:"+event.getSession().getId()
+". No of active sessions:"+activeSessions);


}


/*
* @see 
javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent)
*/
public void sessionDestroyed(HttpSessionEvent event) {
if(activeSessions > 0) {
activeSessions--;
}
log.debug("Session destroyed with id:"+event.getSession().getId()
+". No of active sessions:"+activeSessions);
System.out.println("Session destroyed with id:"+event.getSession().getId()
+". No of active sessions:"+activeSessions);

}


}


Add something like this to your web.xml:

<listener>
<listener-class>
com.zenz.mzz.view.listeners.SessionWatcher
</listener-class>
</listener>




Oscar Picasso wrote:

>Hi,
>
>I am looking for advises on how to implement a use case that is, think, quite common.
>
>In my application users can log in. They can also loggout either explicitly or because of session timeout.
>
>In one part of my application I want to display the total number of logged users and a list of each of these users.
>
>My main problem is how to remove an user from the list when he is logged out implicitly by a  session timeout.
>
>How would you solve this ?
>
>Thanks
>
>		
>---------------------------------
>How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.
>  
>

-- 


*Cumquat Information Technology*
De Dreef 19
3706 BR Zeist
T +31 (0)30 - 6940490
F +31 (0)10 - 6940499
http://www.cumquat.nl <http://www.cumquat.nl/>

martijn.hinten@cumquat.nl <ma...@cumquat.nl>
M +31 6 22 384 318


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: List of logged users

Posted by James Carman <ja...@carmanconsulting.com>.
You can use a session listener for this:

http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSessionListener
.html

You register it in your web.xml file.  


-----Original Message-----
From: Oscar Picasso [mailto:oscgoogle@yahoo.com] 
Sent: Thursday, May 04, 2006 8:15 AM
To: Tapestry users
Subject: List of logged users

Hi,

I am looking for advises on how to implement a use case that is, think,
quite common.

In my application users can log in. They can also loggout either explicitly
or because of session timeout.

In one part of my application I want to display the total number of logged
users and a list of each of these users.

My main problem is how to remove an user from the list when he is logged out
implicitly by a  session timeout.

How would you solve this ?

Thanks

		
---------------------------------
How low will we go? Check out Yahoo! Messenger's low  PC-to-Phone call
rates.



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org