You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ryan Pan <pa...@gmail.com> on 2005/12/29 11:44:05 UTC
Issue of passing parameters between 2 pages
Hi all,
Is there anyone who knows how to pass parameters between 2 pages,which
would be String,Object and so on?
And I also wanna whether is there an attribute of tapestry,like session
of JSP,could store what I wanna pass?
Please kindly tell me how to do it.
Thanks,
Ryan.
Re: Issue of passing parameters between 2 pages
Posted by Ryan Pan <pa...@gmail.com>.
Thank you for your reply.
But I may not pass parameters through setters,because what I need is that
different parameters with different type and page navigation was just
through page link.
So is there any other suggestion?
Hi kiuma,
would you please provide me your solution more detail?
thanks.
2005/12/29, Andreas Idl <an...@ev-i.at>:
>
> Hi
>
> 1. session = use visit objects for session values.
> 2. parameters between to pages = you may call a setter of the destination
> page
>
> here an example of a directlink listener:
>
> Integer value= (Integer)cycle.getServiceParameters()[0];
> DestinationPage page = (DestinationPage)
> cycle.getPage("DestinationPage");
> page.setValue(value);
> cycle.activate(page);
>
> Andreas
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
Re: Issue of passing parameters between 2 pages
Posted by Alan Chandler <al...@chandlerfamily.org.uk>.
On Thursday 29 December 2005 13:14, Vincent wrote:
> Hi
>
> Will cycle.getServiceParameters/setServiceParameters meet your needs?
>
> regards,
> Vincent
>
> On 12/29/05, Alan Chandler <al...@chandlerfamily.org.uk> wrote:
> > On Thursday 29 December 2005 11:06, Andreas Idl wrote:
Not sure exactly who you are replying to here, since my mailer says you are
replying to me.
Part of the point I was trying to make, is that mucking about in the depth of
the internal workings of tapestry isn't really the way forward. What I
showed was a couple of simple ways of just setting up parameters in a page
and then activating it. No mucking about with request cycles, or other
technical jargon, just simply loading a page, setting some parameters and
then getting the page to display itself.
--
Alan Chandler
http://www.chandlerfamily.org.uk
Open Source. It's the difference between trust and antitrust.
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Issue of passing parameters between 2 pages
Posted by Vincent <vi...@gmail.com>.
Hi
Will cycle.getServiceParameters/setServiceParameters meet your needs?
regards,
Vincent
On 12/29/05, Alan Chandler <al...@chandlerfamily.org.uk> wrote:
> On Thursday 29 December 2005 11:06, Andreas Idl wrote:
> > Hi
> >
> > 1. session = use visit objects for session values.
> > 2. parameters between to pages = you may call a setter of the destination
> > page
> >
> > here an example of a directlink listener:
> >
> > Integer value= (Integer)cycle.getServiceParameters()[0];
> > DestinationPage page = (DestinationPage)
> > cycle.getPage("DestinationPage");
> > page.setValue(value);
> > cycle.activate(page);
> >
> > Andreas
>
> That seems more complex than it need be. The examples below carries an
> integer variable around between all the pages called function which is used
> to determine a high level function I am performing
>
> I do something like the following
>
> In the template
>
> <form jwcid="@Form" listener="listener:doUpdate" delegate="bean:delegate">
> <span jwcid="@Hidden" value="ognl:function" />
> ...
> </form
>
> and in the java PageClass
>
> @InjectPage("Select")
> public abstract Select getSelectPage();
>
> public abstract void setFunction(int function);
> public abstract int getFunction();
>
> public IPage doUpdate () {
> Select select = getSelectPage();
> select.setFunction(getFunction()); // Don't say done anything
> return select;
> }
>
> This shows calling a new page called "Select" with the function that I am
> carrying around in a hidden field in my form. (It was set in a similar way by
> the previous caller to this page.)
>
> This avoids the need to create a session for the user with the additional
> overhead that it needs.
>
> It is of course also possible to set a new parameter via DirectLink parameters
>
> Here is a little snippet from a table (using contrib:table) where the
> directlink has a parameter (an id) which gets passed to the listener and then
> on to the called page
>
> <td jwcid="surnameColumnValue@Block">
> <a jwcid="surnameedit@DirectLink"
> listener="listener:doEdit"
> parameters="ognl:{function,components.table.tableRow.id}"
> class="name"
> ><span jwcid="@Insert"
> value="ognl:components.table.tableRow.surname"
> >Chandler</span></a></td>
>
>
> And from the page class
>
> @InjectPage("Edit")
> public abstract Edit getEditPage();
>
> public Edit doEdit(int function, int id) {
> Edit edit = getEditPage();
> // ignore the function parameter - not using it in the html - set directly
> edit.setFunction(Function.EDIT);
> edit.setPersonId(id);
> return edit;
> }
>
>
> Again, avoiding setting up a session at this point.
>
> Just a little point about ordering on the target page. The page attach
> listener in the last example is fired at the point where I call
> getEditPage(). I use the parameter id to read the database in the edit page.
> I have to do that in the Page Validate Listener - since when the page attach
> listener is called the value is not yet set.
>
> --
> Alan Chandler
> http://www.chandlerfamily.org.uk
> Open Source. It's the difference between trust and antitrust.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Issue of passing parameters between 2 pages
Posted by Alan Chandler <al...@chandlerfamily.org.uk>.
On Thursday 29 December 2005 11:06, Andreas Idl wrote:
> Hi
>
> 1. session = use visit objects for session values.
> 2. parameters between to pages = you may call a setter of the destination
> page
>
> here an example of a directlink listener:
>
> Integer value= (Integer)cycle.getServiceParameters()[0];
> DestinationPage page = (DestinationPage)
> cycle.getPage("DestinationPage");
> page.setValue(value);
> cycle.activate(page);
>
> Andreas
That seems more complex than it need be. The examples below carries an
integer variable around between all the pages called function which is used
to determine a high level function I am performing
I do something like the following
In the template
<form jwcid="@Form" listener="listener:doUpdate" delegate="bean:delegate">
<span jwcid="@Hidden" value="ognl:function" />
...
</form
and in the java PageClass
@InjectPage("Select")
public abstract Select getSelectPage();
public abstract void setFunction(int function);
public abstract int getFunction();
public IPage doUpdate () {
Select select = getSelectPage();
select.setFunction(getFunction()); // Don't say done anything
return select;
}
This shows calling a new page called "Select" with the function that I am
carrying around in a hidden field in my form. (It was set in a similar way by
the previous caller to this page.)
This avoids the need to create a session for the user with the additional
overhead that it needs.
It is of course also possible to set a new parameter via DirectLink parameters
Here is a little snippet from a table (using contrib:table) where the
directlink has a parameter (an id) which gets passed to the listener and then
on to the called page
<td jwcid="surnameColumnValue@Block">
<a jwcid="surnameedit@DirectLink"
listener="listener:doEdit"
parameters="ognl:{function,components.table.tableRow.id}"
class="name"
><span jwcid="@Insert"
value="ognl:components.table.tableRow.surname"
>Chandler</span></a></td>
And from the page class
@InjectPage("Edit")
public abstract Edit getEditPage();
public Edit doEdit(int function, int id) {
Edit edit = getEditPage();
// ignore the function parameter - not using it in the html - set directly
edit.setFunction(Function.EDIT);
edit.setPersonId(id);
return edit;
}
Again, avoiding setting up a session at this point.
Just a little point about ordering on the target page. The page attach
listener in the last example is fired at the point where I call
getEditPage(). I use the parameter id to read the database in the edit page.
I have to do that in the Page Validate Listener - since when the page attach
listener is called the value is not yet set.
--
Alan Chandler
http://www.chandlerfamily.org.uk
Open Source. It's the difference between trust and antitrust.
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Issue of passing parameters between 2 pages
Posted by Andreas Idl <an...@ev-i.at>.
Hi
1. session = use visit objects for session values.
2. parameters between to pages = you may call a setter of the destination page
here an example of a directlink listener:
Integer value= (Integer)cycle.getServiceParameters()[0];
DestinationPage page = (DestinationPage)
cycle.getPage("DestinationPage");
page.setValue(value);
cycle.activate(page);
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org