-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi forum!
Few days ago I show the problem with the explorers about the event closing. I think about this because it's a problem to control the session of users in our programs.
I try to create a class to control it and I want that you tell to me the possibles warnings or problems to use it.
Say this:
Everytime that we open a new desktop we add attribute called live, and we add the desktop into a List<Desktop> and this List into the scope of Sessions. Then, a timer call a method to check if every Desktop has this attribute. If one of this desktops answer affirmatively, we keep the session, but if anyone answer we invalidate de session.
This works, but i want know what problems can make.
This is the code:
public void onCreate$Window(){ //setAtrtribue to Desktop Executions.getCurrent().getDesktop().setAttribute("live", "ok"); //add desktop to list if(Executions.getCurrent().getSession().hasAttribute("lista")){ lista = (List<Desktop>) Executions.getCurrent().getSession().getAttribute("lista"); lista.add(Executions.getCurrent().getDesktop()); Executions.getCurrent().getSession().setAttribute("lista", lista); } else{ lista= new ArrayList<Desktop>(); lista.add(Executions.getCurrent().getDesktop()); Executions.getCurrent().getSession().setAttribute("lista", lista); } } public boolean comprueba() { lista = (List<Desktop>)Executions.getCurrent().getSession().getAttribute("lista"); for(Desktop desktop : lista){ escritorio = desktop; if(escritorio.hasAttribute("live")){ return false; } } return true; } public void darVuelta(){ if(comprueba()){ Executions.getCurrent().getSession().invalidate(); } }
then a timer from tomcat calls darVuelta()
is it feasible?
Thanks for all,
Marky
Sorry, I forget this declaration:
private Desktop escritorio ; private List<Desktop> lista;
If anybody has other form to detect the end of sessions please write it!
Thanks all!
Marky
Asked: 2011-06-22 02:46:44 +0800
Seen: 380 times
Last updated: Jun 22 '11