tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesús Ramos <jra...@legosoft.com.mx>
Subject Re: Setting a property for a page at runtime
Date Wed, 27 Aug 2003 17:29:07 GMT
If I understand your question correctly, that is not the way you set
parameters for a page.
First, you have to declare a property in your page spec, like so:
<property-specification name='myProperty' type='com.foo.bar.MyBar'
persistent='yes' [initial-value="new com.foo.bar.MyBar()"]/>

Then, in your page, to retrieve and set page properties you use the methods:

(MyBar) getProperty("myProperty");

or setProperty("myProperty", new MyBar());

On the other hand, if you wish to set/retrieve parameters from the very
cycle, the way to do such thing is:

cycle.getRequestContext().getRequest().getParameter("param"));

This retrieves a parameter directly from the HTTP req.

Hope this was useful.

Best regards.

J. Ramos


----- Original Message ----- 
From: "Mindaugas Genutis" <mindaugas@elinara.ktu.lt>
To: <tapestry-user@jakarta.apache.org>
Sent: Wednesday, August 27, 2003 10:05
Subject: Setting a property for a page at runtime


> Hello,
>
> In my page which I inherited from BasePage I have an 'action' property
> (String mAction member with set/get methods).
>
> I implemented the IExternalPage interface and in the activateExternalPage
> I set this 'action' property:
>
> public void activateExternalPage(Object[] parameters, IRequestCycle cycle)
> {
>   Object[] params = cycle.getServiceParameters();
>   setAction((String) params[0]);
> }
>
> Thus, the 'action' property is set. However, when I submit my page, in the
> formSubmit() method my action property is null:
>
> public void formSubmit(IRequestCycle requestCycle)
> {
>   if(mAction.equals("Add")) // NullPointerException thrown here.
>   {
>   }
> }
>
> Thus, perhaps I don't understand the page properties lifecycle idea. How
> to make my page property stay persistent till the formSubmit method?
>
> Thanks,
>
> -- 
> Kaunas Regional Distance Education Center
> Programmer
> Phone: +370 674 05232
> WWW: http://distance.ktu.lt
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


Mime
View raw message