You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mindaugas Genutis <mi...@elinara.ktu.lt> on 2003/08/27 17:05:09 UTC
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
Re: Setting a property for a page at runtime
Posted by Mark Rose <mr...@docent.com>.
Paul Ferraro wrote:
> It sounds like you want mAction to be a persistent page property?
> Check out:
> http://jakarta.apache.org/tapestry/doc/TapestryUsersGuide/state.page-properties.html
>
> Paul
>
> On Wed, 2003-08-27 at 08:05, Mindaugas Genutis wrote:
>
>>Hello,
>>
>>In my page which I inherited from BasePage I have an 'action' property
>>(String mAction member with set/get methods).
[...]
>>Thus, perhaps I don't understand the page properties lifecycle idea. How
>>to make my page property stay persistent till the formSubmit method?
Or, if you don't want to make the property persistent, then you can save
the property state in a Hidden component. Put a <hidden> HTML element in
the form, then bind the value to your property:
<component jwcid="theHiddenValue" type="Hidden">
<binding name="value" expression="action"/>
</component>
Mark
--
Mark Rose
650.962.5665
mailto:mrose@docent.com
Re: Setting a property for a page at runtime
Posted by Paul Ferraro <pa...@softhome.net>.
It sounds like you want mAction to be a persistent page property?
Check out:
http://jakarta.apache.org/tapestry/doc/TapestryUsersGuide/state.page-properties.html
Paul
On Wed, 2003-08-27 at 08:05, Mindaugas Genutis wrote:
> 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,
Re: Setting a property for a page at runtime
Posted by Jesús Ramos <jr...@legosoft.com.mx>.
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" <mi...@elinara.ktu.lt>
To: <ta...@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
>