0

Get a session atribute inside a Eventqueue.

asked 2011-03-29 12:28:00 +0800

cawink gravatar image cawink
27 1

Hi.

Can i get a Session atribute inside a Eventqueue ?

Example:

private void refreshQueue()
{
if ( !EventQueues.exists( "longop", EventQueues.SESSION ) )
{
EventQueue eq = EventQueues.lookup( "longop", EventQueues.SESSION, true ); //create a queue

Sessions.getCurrent().setAttribute( "test", "testing...." ); // set a attribute in a Session

//subscribe async listener to handle long operation
eq.subscribe(
new EventListener()
{
public void onEvent( Event evt )
{ //asynchronous

//(String)Sessions.getCurrent().getAttribute( "test" ) ; // Here is the problem. Try to get the attribute

org.zkoss.lang.Threads.sleep( 3000 ); //simulate a long operation
}
},
new EventListener()
{ //callback

public void onEvent( Event evt )
{
EventQueues.remove( "longop",EventQueues.SESSION );
}
}
);

eq.publish( new Event( "whatever" ) ); //kick off the long operation
}

else
{
print( "It is busy. Please wait" );
}
}

delete flag offensive retag edit
Be the first one to reply this discussion!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-03-29 12:28:00 +0800

Seen: 172 times

Last updated: Mar 29 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More