You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Martin Torre Castro <ma...@hotmail.com> on 2009/09/02 21:30:44 UTC
Newbie questions
Hello, I have some doubts I can't solve about passing values between pages and don't understand as I wish.Maybe you could help me.
1.-When I've got more than one onActivate() for a page with different kinds of arguments, for example:
onActivate() { ...some_code_here... }
onActivate(Long l) {...some_code_here...}
onActivate(String s) {...some_code_here...}
onActivate(String s1, String2) {...some_code_here...}
How can I know which one of them is going to be called? Is it possible for more than one to be called when loading the same page? If this is true, which order do they follow? When I use a PageLink t:context="numberField" it calls only one of the onActivate, but in other pages I'm finding non-predictable behaviours for me.
If I have a Object[] onPassivate() for example, can I do
Object onPassivate() {
if(condition) return new Object[] {a.toString(), b.toString()}
else return new Object[] {c} // C being a Long Object
}
and catch the different cases by separate?
2.-About catching the values from selects and texfields, I've seen some code using attributes on Java with _attributeName linking these variables to the values on the html components. This is a convention on Tapestry that makes it to find automatically the so _named fields or I'm missing something?
_________________________________________________________________
Messenger cumple 10 años ¡Descárgate ya los nuevos emoticonos!
http://www.vivelive.com/felicidades
Re: Newbie questions
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 03 Sep 2009 08:40:53 -0300, Martin Torre Castro
<ma...@hotmail.com> escreveu:
> Thank you very much Thiago.
You're welcome!
> EventContext is working ok when I'm sending data from the page to the
> same page. But if I send data from another page and I'm setting the
> EventContext parameters as before is show an error:
>
> method onActivate signature: (Lorg/apache/tapestry/EventContext;)V)
> Illegal constant pool index
This is a compilation or class manipulation issue. Try recompiling your
application.
It looks like you're trying to receive an array of EventContext in your
onActivate method: that's not correct. It should be
onActivate(EventContext context).
The context value can't be an EventContext (something I guess it's fixed
in the next Tapestry version).
> Do I have to set the onActivate parameters one by one as I usually did
> or is better to make a setContext method in the page receiving the data?
If you use a method other than onActivate to recevie data, it's a valid
choice, but you're not using the activation context.
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
RE: Newbie questions
Posted by Martin Torre Castro <ma...@hotmail.com>.
Thank you very much Thiago.
EventContext is working ok when I'm sending data from the page to the same page. But if I send data from another page and I'm setting the EventContext parameters as before is show an error:
method onActivate signature: (Lorg/apache/tapestry/EventContext;)V) Illegal constant pool index
Do I have to set the onActivate parameters one by one as I usually did or is better to make a setContext method in the page receiving the data? If so, how do I implement the setter? With a constructor of ArrayEventContext?
Thank you very much again. I really aprecciate the help of all you guys. It's saving my life!
_________________________________________________________________
Con Vodafone disfruta de Hotmail gratis en tu móvil. ¡Pruébalo!
http://serviciosmoviles.es.msn.com/hotmail/vodafone.aspx
Re: Newbie questions
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 02 Sep 2009 16:30:44 -0300, Martin Torre Castro
<ma...@hotmail.com> escreveu:
> Hello, I have some doubts I can't solve about passing values
> between pages and don't understand as I wish.Maybe you could help me.
Hi!
> 1.-When I've got more than one onActivate() for a page with different
> kinds of arguments, for example:
[...]
Use a single onActivate(EventContext context) method. It will be invoked
with any number of parameters. EventContext.getCount() will give you the
number of parameters and EventContext.get(Class typeToConvert, int index)
will return the parameter values.
> 2.-About catching the values from selects and texfields, I've seen some
> code using attributes on Java with _attributeName linking these
> variables to the values on the html components. This is a convention on
> Tapestry that makes it to find automatically the so _named fields or I'm
> missing something?
This _fieldName is a field naming convention that Howard, the framework
creator and main committer, used to follow. Tapestry doesn't treat
underscored-prefixed fields differently from non-undescored-prefixed ones.
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org