Hi, I'm trying to obtain a page from it's name to set a property on it. I'm trying something like this:
Component page = componentSource.getPage("MyPage"); MyPage myPage = (MyPage)page; myPage.setSomething(""); This code fails in the cast, despite a System.out.println(page.getClass().getName()); prints the expected page class (com.myapp.pages.MyPage).... I assume is because all the instrumentation T5 does to the pages, but is there a way to obtain a page from its name and then set a property that the "original" class has?? The only workaround i've found is to call the method setSomething with reflection, without casting it to MyPage, but it would be really nice not to use reflection for this.... Regards. Filip S. Adamsen-2 wrote: > > Hi, > > RequestPageCache is an internal service, it's better to use > ComponentSource instead. It has methods to get a component or page by > logical name. > > http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/services/ComponentSource.html > > -Filip > > On 2008-05-05 16:01, Kristian Marinkovic wrote: >> @Inject >> private RequestPageCache pageCache; >> >> pageCache.get(logicalName) >> >> >> g, >> kris >> >> >> >> >> >> >> >> Shing Hing Man <[EMAIL PROTECTED]> >> 05.05.2008 15:53 >> Bitte antworten an >> "Tapestry users" <users@tapestry.apache.org> >> >> >> An >> tapestry Tapestry <[EMAIL PROTECTED]> >> Kopie >> >> Thema >> Tap 5.0.11 : How to get page instance from page >> >> >> >> >> >> >> >> Usually, I could use the following to inject a page >> into another page >> >> @InjectPage >> private DetailsPage details; >> >> How to retrieve an instance of a page if I am given >> the logical name of a page as a String variable ? >> >> In Tap 4, I would use RequestCycle.getPage(pageName). >> >> Thanks in advance for any asistance! >> >> Shing >> >> Home page : http://www.lombok.demon.co.uk/ >> >> >> >> ___________________________________________________________ >> Yahoo! For Good. Give and get cool things for free, reduce waste and help >> our planet. Plus find hidden Yahoo! treasure >> >> http://green.yahoo.com/uk/earth-day/ >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/Tap-5.0.11-%3A-How-to-get-page-instance--from-page-tp17062196p17611843.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]