That seems a very complicated way to do it. public interface AuthService() { public boolean authenticate(User user); }
publlic class AuthServiceImpl() { public boolean authenticate (User user) { // authenticate and return true on success } } In your appmodule binder.bind(AuthService.class, AuthServiceImpl.class); // at the appropriate place In your page @Inject private AuthService authService; Object onSuccessFromLoginForm() { User candidate = new User(..); if( ! authService .authenticate(candidate)) return authenticationErrorPage; else return authenticationSuccessPage; } Or did I get you totally wrong? 2009/6/9 Neo Anderson <javadeveloper...@yahoo.co.uk> > > What I want to do is to perform authentication function; but would like > auth > logic to be separated from Page file. So the auth function can be reused > next time if other front end client needs it. > > Then I searched on the tapestry website and found that seemingly it is > achieved by using Dispatcher > (http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher). That's > why I use this mechanism trying to accomplish my task. > > What is the best practice if I want to achieve such goal? > > Or is there any resource/ guideline telling about this? > > Thank you very much. > > > Thiago H. de Paula Figueiredo wrote: > > > > Em Mon, 08 Jun 2009 19:42:14 -0300, Neo Anderson > > <javadeveloper...@yahoo.co.uk> escreveu: > > > >> I run the code and request.getAttribute(USER) returns null in dispatch() > >> function. So I output the Request to see what happens; then notice that > >> they (Request in Login.java Page and AccessController.java) are two > >> difference objects. > > > > That's not what I've asked. Anyway, Tapestry uses proxies a lot, so it is > > very likely that the two objects are functionally the same. > > > >> Now it looks like I can obtain the User data by marking the User object > >> as SessionState in Login.java Page. > >> > >> public class Login{ > >> ... > >> @SessionState > >> private User user; > >> ... > >> Object onSubmitFromLogin(){ > >> user = new User(...); > >> } > >> } > >> > >> Then retrieve User object from dispatch() in AccessController.java > >> > >> public boolean dispatch(Request request, Response response) throws > >> IOException{ > >> ... > >> if(asm.exists(User.class)){ > >> User u = asm.get(User.class); > >> ... > >> } > >> } > >> > >> However, this rise another question for me - is this a recommended way > >> to obtain a temporary User object (because User object in Login Page is > >> only constructed temporarily and passed to the backend side for > >> verification)? > > > > If you'll need that object in a different request, yes. > > Why are you using a dispatcher here? I can't see how a dispatcher would > be > > invoked in the same request after a page was rendered. > > > >> Also, how if I have other User object which holds different information > >> (e.g. User object obtained from database), but needs to exist at the > >> same time as that temporarily constructed User object? Will the later > >> override the one that is constructed temporarily (I read Tapestry > >> website saying if I have the same type marked with SessionState > >> annotation, they will use the same reference regardless of their > >> variable name)? > > > > Yes, it will override. > > > > I suggest you to tell use what you're trying to accomplish instead of > > asking details of how to do it. > > > > -- > > Thiago H. de Paula Figueiredo > > Independent Java consultant, developer, and instructor > > http://www.arsmachina.com.br/thiago > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > > For additional commands, e-mail: users-h...@tapestry.apache.org > > > > > > > > -- > View this message in context: > http://n2.nabble.com/Obtain-the-data-inside-RequestGlobals-question-tp3032702p3048582.html > Sent from the Tapestry Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >