You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Sylvain COUTANT <sc...@adviseo.fr> on 2005/09/27 14:38:50 UTC

Callbacks : how to

Hi all,

I would like to understand something about callbacks usage.

I have setup something which is very near from the example given in Tapestry's source code.

Here's the code that sets the callback :

@InjectPage("Login")
public abstract Login getLoginPage();

[...]

public void pageValidate(PageEvent event) {
	if(isAuthenticated()) {
		return;
	}
	this.getLoginPage().setCallback(new PageCallback(this));
	throw new PageRedirectException(this.getLoginPage());
} 



And in Login page's class :


private ICallback _callback;

public void setCallback(ICallback callback) {
	_callback = callback;
}

public void formLogin(IRequestCycle cycle) {

	if(_callback != null) {
		System.out.println("Login: Callback found.");
		_callback.performCallback(cycle);
		_callback = null;
	} else {
		cycle.activate("pages/manager/Main");
	}
}


This works in dev, but I wonder how it could perform when going to production with several simultaneous users. AFAIK, Tapestry uses a pool of pages instance objects. When the login page is requested by one user, any object instance of this page's class in the pool can be used to serve the request. The callback I have set is defined in one of the instances only. How can this work ? Could someone help me understand ?

Shouldn't the callback property be stored within a session's object ?


--
Sylvain COUTANT

ADVISEO
http://www.adviseo.fr/
http://www.open-sp.fr/



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


Re: Callbacks : how to

Posted by Kent Tong <ke...@cpttm.org.mo>.
Sylvain COUTANT <sco <at> adviseo.fr> writes:

> Shouldn't the callback property be stored within a session's object ?

Yes, it should.

--
Author of a book for learning Tapestry (www.agileskills2.org/EWDT)


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