You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michele Russo <ru...@yahoo.it> on 2007/09/04 10:01:58 UTC

session variables and links

Hello,

I'm a new user of Tapestry. Please could you help me in solving the following problems:

1) I would like to extract an attribute from an url. For instance, if I've the following url:

http://foo?name=xxx

I want to extract the name and insert it as a session variable.


2) Next, I would like to create a link to an external page passing the session name to it.

I would very grateful if someone could provide me a piece of sample code.

Regards,

Michele


       
---------------------------------

---------------------------------
L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail

Re: session variables and links

Posted by Erik Vullings <er...@gmail.com>.
Hi Michele,

1. Why would you do this? For example, you would normally do something like
this in your mypage.html:

<t:actionlink t:id="name" context="xxx">Link text</t:actionlink>

and something like this in your mypage.java:
@Persist
String myName;

public void onActionFromName(String name) {
   myName = name;
}

2. You can create a page in your java app, and call an init function before
you redirect to it, e.g. see (
http://tapestry.apache.org/tapestry5/tapestry-core/index.html) or

  @InjectPage
  private Start _startPage; // this page needs to exist in the folder
myapp.pages/Start.java, often with accompanying
src/main/webapp/WEB-INF/Start.html.

private Object onActionFromGoToStarttPage() {
  _startPage.setName(name);
  return _startPage;
}

Cheers
Erik


On 9/4/07, Michele Russo <ru...@yahoo.it> wrote:
>
> Hello,
>
> I'm a new user of Tapestry. Please could you help me in solving the
> following problems:
>
> 1) I would like to extract an attribute from an url. For instance, if I've
> the following url:
>
> http://foo?name=xxx
>
> I want to extract the name and insert it as a session variable.
>
>
> 2) Next, I would like to create a link to an external page passing the
> session name to it.
>
> I would very grateful if someone could provide me a piece of sample code.
>
> Regards,
>
> Michele
>
>
>
> ---------------------------------
>
> ---------------------------------
> L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail