You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Yura Tkachenko <yu...@muranosoft.com> on 2006/01/14 17:28:25 UTC

Troubles with tag span on the tapestry page

 Hi, I'm using tapestry 4.0. I have some different behavior:

> on the page Result page I have html code:
> <span jwcid="@Insert" value="ognl:userName">
> Before redirect to the Result page I'm doing :
>         IPage result  = getResultPage();
>         PropertyUtils.write(myWCadPage, "userName", "Peter Smith");
>         return result;
> After this I was redirected to result page I had seen "Peter Smith". 
> But on result page I have form component, so when I clicked some 
> button on the form my form is redirected to itself and this label 
> "Peter Smith" is cleared. I suppose that it's cause because property 
> "userName" is cleared. My question is how I can take care about 
> storing this property from one submit to another on the Result page. 
> What should I do.
>
> Here server-side code of the page:
> public abstract class MyResult extends BasePage {
>     public abstract Date getCreationDateForSearch();
>     public abstract String getUserName();
>     public abstract String getLastLogined();
>
>     public void onSearch() {
>
>     }
> }
>
>
> Thanks,
> Yura Tkachenko.
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Troubles with tag span on the tapestry page

Posted by Alan Chandler <al...@chandlerfamily.org.uk>.
On Saturday 14 January 2006 16:28, Yura Tkachenko wrote:
>  Hi, I'm using tapestry 4.0. I have some different behavior:
> > on the page Result page I have html code:
> > <span jwcid="@Insert" value="ognl:userName">
> > Before redirect to the Result page I'm doing :
> >         IPage result  = getResultPage();
> >         PropertyUtils.write(myWCadPage, "userName", "Peter Smith");

what is myWCadPage?  normally I would set the parameters in the result page 
with
	result.setUserName("Peter Smith");

> >         return result;
> > After this I was redirected to result page I had seen "Peter Smith".
> > But on result page I have form component, so when I clicked some
> > button on the form my form is redirected to itself and this label
> > "Peter Smith" is cleared. 

After the page is rendered and sent to the browser it is put back in the pool 
and the userName parameter is set back to is original value (probably null)

When the form is submitted a fresh page is retrieved from the pool and those 
parameters and (by default - there is an override parameter for the form 
component) only those components WITHIN the form are written into the page 
before you get to process the form in your listener.

If your form has not got userName as a textField in it, you have to find a way 
to carry the userName over.

There are several ways

1) Put it in a hidden field

<input jwcid="@Hidden" value="ognl:userName" />

2) Make the parameter to the page persistent  
(as per the annotation as shown below, or in your page file (I don't use page 
files so I don't know how)

3)Have userName as a Application State Object (you need to read up on the 
Managing Server Side State in the user guide section of the documentation)

> > I suppose that it's cause because property 
> > "userName" is cleared. My question is how I can take care about
> > storing this property from one submit to another on the Result page.
> > What should I do.
> >
> > Here server-side code of the page:
> > public abstract class MyResult extends BasePage {
> >     public abstract Date getCreationDateForSearch();

You can make parameters persistent with the following annotation

	@Persist()
> >     public abstract String getUserName();
> >     public abstract String getLastLogined();
> >
> >     public void onSearch() {
> >
> >     }
> > }
> >
> >
> > Thanks,
> > Yura Tkachenko.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org

-- 
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