You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Hugi Thordarson <hu...@karlmenn.is> on 2011/12/09 10:37:36 UTC
Returning an instance of a page
Hi all.
Quick newbie question: How do I return an instance of a page whose class I do not know until at runtime? Example: I have a list page, listing objects of various types. when I click an object, I want to return a page class based on the class of the object I select ("UserDetailPage" for "User", "CompanyDetailPage" for "Company" etc…).
@InjectPage requires me to specify a particular page at compile time, so I can't use that—and I cant do a plain "return UserDetailPage.class" since I need to set the selected object.
Any ideas?
Thanks,
- hugi
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Returning an instance of a page
Posted by Hugi Thordarson <hu...@karlmenn.is>.
Yes, that would work for returning the page, but I need to initialize it (with the object). In pseudocode, what I'm looking for wouls be something along the lines of:
Object onActionFromSelect() {
Class<? extends DetailPage> detailPageClass = determineDetailPageClass( currentObject );
DetailPage detailPagePage = // obtain page instance of type detailPageClass
detailPage.setSelectedObject( currentObject );
return detailPage;
}
(the detail pages all inherit from DetailPage)
Cheers,
- hugi
On 9.12.2011, at 09:43, angelochen wrote:
> how about: return "UserDetailPage"
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Returning-an-instance-of-a-page-tp5061220p5061225.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Returning an instance of a page
Posted by angelochen <an...@yahoo.com.hk>.
how about: return "UserDetailPage"
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Returning-an-instance-of-a-page-tp5061220p5061225.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org