Re: Passing Parameters to Pages (Newbie question)
"Malcolm Edgar" <[email protected]>
| Newsgroups | gmane.comp.java.tapestry.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi detlef,
There are a couple of options available.
The first is to use the DirectLink component to generate your action links
and then in the ActionLink event handler set the parameter on the ItemDetail
page:
public void itemSelectAction(IRequestCycle cycle) {
Object[] params = cycle.getServiceParameters();
Integer itemId = (Integer) params[0];
ItemDetailPage page = (ItemDetailPage) cycle.getPage("ItemDetail");
page.setItemId(itemId);
cycle.setPage(page);
}
The second option is to have your ItemDetail page implement the
IExternalPage interface and use the ExternalLink component instead of
DirectLink. You will need to include this type of code in your ItemDetail
page:
public void activateExternalPage(Object[] params, IRequestCycle cycle) {
Object[] params = cycle.getServiceParameters();
setItemId((Integer) params[0]);
}
Regards Malcolm
>From: "detlef schulze" <[email protected]>
>To: "tapestry-developer \(E-mail\)"
><[email protected]>
>Subject: [Tapestry-developer] Passing Parameters to Pages (Newbie question)
>Date: Fri, 15 Nov 2002 16:56:15 +0100
>
>Hi,
>
>I have a question concerning the passing of parameters to a page:
>
>Imagine two pages: ItemList and ItemDetail. ItemList basically has a
>foreach that creates some <a> tags using a number of ActionLinks. When one
>of the Links is clicked a listener method is triggered. This method then
>shows the ItemDetail using cycle.setPage("ItemDetail").
>
>Now the question: since each link on the ItemList page shall display a
>different Item (using ItemDetail) I wonder how to pass the parameter (lets
>say the id (int)) of the Item to be displayed. How do you usually do this
>with tapestry? I probably just overlook the way to do it because I am not
>used to the Request cycle that is used with tapestry.
>
>Any hint appreciated
>
>tia
>Detlef
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing
your web site with SSL, click here to get a FREE TRIAL of a Thawte
Server Certificate: http://www.gothawte.com/rd524.html