Not exactly sure of the process but http://tapestry.apache.org/tapestry4/tapestry/apidocs/org/apache/tapestry/IComponent.html#getPage() and a component can read the page it's in... If that's not enough, http://tapestry.apache.org/tapestry4/tapestry/apidocs/org/apache/tapestry/IComponent.html#getProperty(java.lang.String) on how to read a property from a component (or page)
Daniel Jue wrote: > Here is my situation: > > I have a page that is only viewable if the user is logged in, called > SecuredPage. If the user clicks a link to get to that page, the page > protects itself with pageValidate. That is, if the user is not logged > in, pageValidate will set up a page callback variable in the Login > page like this: > > Login login = getLoginPage(); > login.setNextPage(new PageCallback("MySecuredPage")); > > then it will redirect the user to the Login page, like this: > > throw new PageRedirectException(login); > > This is based on the shopping cart example of Enjoying Web Development > with Tapestry, chapter 4. > > This worked fine when my Login.java had this definition in it: > > public abstract void setNextPage(ICallback callback); > > But now i've moved all my login logic to a component, called > LoginComponent. :-) > I've removed all java code from Login.java. > > Login.html, Login.jwc and Login.java are now just a dumb page that has > a smart LoginComponent embedded in it. > > Now we get to the problem: > > When I have my pageValidate method in my SecuredPage.java, how do I > call the setNextPage(...) that exists in the LoginComponent? > > Should I make a method in Login.java that just forwards the setting to > the component, like this?: > > pageValidate in SecuredPage.java: > ... > Login login = getLoginPage(); > login.setNextPageInComponent(new PageCallback("MySecuredPage")); > ... > > and in Login.java: > > ... > setNextPageInComponent(PageCallback p) > { > //somehow call the component's setNextPage(p) in here > } > ... > > > Or is there a more elegant way? > > I hope this is readable, I didn't want to deluge you with code. > > Eventually, I'll move my pagevalidate code into a subclass of > basepage, called securedpage. But It still seems usefull to have the > login logic be in a component. > > Dan > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Andreas Andreou - [EMAIL PROTECTED] - http://andyhot.di.uoa.gr Tapestry / Tacos developer Open Source / J2EE Consulting --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]