You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Adam X <vb...@gmail.com> on 2016/09/20 16:04:27 UTC

Multiple Page activation context

I would like to have multiple (overloaded) onActivate methods in my
page but seems like Tapestry is always picking a method with fewest
arguments.

How can I achieve something like this?

TargetPage {

void onActivate(String foo, String bar) {
}

void onActivate(String foo, Long id1, Long id2) {
}
}

<t:pagelink context="['abc','def']">yo</t:pagelink>
<t:pagelink context=['xyz',10,20]>bam</t:pagelink>

Adam

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


Re: Multiple Page activation context

Posted by JumpStart <ge...@gmail.com>.
Try this:

	http://jumpstart.doublenegative.com.au/jumpstart7/examples/navigation/variableparameters1

Geoff

> On 21 Sep 2016, at 12:04 AM, Adam X <vb...@gmail.com> wrote:
> 
> I would like to have multiple (overloaded) onActivate methods in my
> page but seems like Tapestry is always picking a method with fewest
> arguments.
> 
> How can I achieve something like this?
> 
> TargetPage {
> 
> void onActivate(String foo, String bar) {
> }
> 
> void onActivate(String foo, Long id1, Long id2) {
> }
> }
> 
> <t:pagelink context="['abc','def']">yo</t:pagelink>
> <t:pagelink context=['xyz',10,20]>bam</t:pagelink>
> 
> Adam
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


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


Re: Multiple Page activation context

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 20 Sep 2016 13:46:27 -0300, Adam X <vb...@gmail.com> wrote:

> How do I create links? Can I do this:
> <t:pagelink context="['abc','def']">yo</t:pagelink>
> <t:pagelink context=['xyz',10,20]>bam</t:pagelink>

I'd go with a separate method:

<t:pagelink context="pageContext">yo</t:pagelink>


Object[] getPageContext() {
	// whatever logic you want or need.
}

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: Multiple Page activation context

Posted by Lance Java <la...@googlemail.com>.
Sorry... I spoke to soon. You want index=1 to be a string sometimes and a
long others? If you want to use @PageActivationContext you'll need to
declare as a string and parse to long yourself

On 20 Sep 2016 5:51 p.m., "Lance Java" <la...@googlemail.com> wrote:

> You don't need explicit nulls, it'll work with or without them.
>
> On 20 Sep 2016 5:46 p.m., "Adam X" <vb...@gmail.com> wrote:
>
>> Wow, you guys rock and support is great. I like
>> onActivate(EventContext eventContext). I like even better
>> @PageActivationContext annotation (I'm doing a new project on 5.4.1 so
>> I can use it).
>>
>> So in my earlier example, if I define this:
>>
>> @PageActivationContext(index=0) private String foo;
>> @PageActivationContext(index=1) private String bar;
>> @PageActivationContext(index=2) private Long id1;
>> @PageActivationContext(index=3) private Long id2;
>>
>> How do I create links? Can I do this:
>>
>> <t:pagelink context="['abc','def']">yo</t:pagelink>
>> <t:pagelink context=['xyz',10,20]>bam</t:pagelink>
>>
>> ? Or do I have to explicitly pass null to keep indexes straight?
>>
>> <t:pagelink context="['abc','def']">yo</t:pagelink>
>> <t:pagelink context=['xyz','null'10,20]>bam</t:pagelink>
>>
>> Adam
>>
>> On Tue, Sep 20, 2016 at 6:34 PM, Lance Java <la...@googlemail.com>
>> wrote:
>> > Correction: This feature was added in 5.4 (not 5.3)
>> >
>> > On 20 Sep 2016 5:29 p.m., "Lance Java" <la...@googlemail.com>
>> wrote:
>> >
>> >> @PageActivationContext supports multiple values thanks to the new index
>> >> property added in 5.3. Missing values will simply be null
>> >>
>> >> Eg:
>> >> @PageActivationContext(index=0) private String value0;
>> >> @PageActivationContext(index=1) private String value1;
>> >> @PageActivationContext(index=2) private String value2;
>> >>
>> >> More info: https://issues.apache.org/jira/browse/TAP5-2138
>> >>
>> >> On 20 Sep 2016 5:04 p.m., "Adam X" <vb...@gmail.com> wrote:
>> >>
>> >>> I would like to have multiple (overloaded) onActivate methods in my
>> >>> page but seems like Tapestry is always picking a method with fewest
>> >>> arguments.
>> >>>
>> >>> How can I achieve something like this?
>> >>>
>> >>> TargetPage {
>> >>>
>> >>> void onActivate(String foo, String bar) {
>> >>> }
>> >>>
>> >>> void onActivate(String foo, Long id1, Long id2) {
>> >>> }
>> >>> }
>> >>>
>> >>> <t:pagelink context="['abc','def']">yo</t:pagelink>
>> >>> <t:pagelink context=['xyz',10,20]>bam</t:pagelink>
>> >>>
>> >>> Adam
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >>> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>>
>> >>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>

Re: Multiple Page activation context

Posted by Lance Java <la...@googlemail.com>.
You don't need explicit nulls, it'll work with or without them.

On 20 Sep 2016 5:46 p.m., "Adam X" <vb...@gmail.com> wrote:

> Wow, you guys rock and support is great. I like
> onActivate(EventContext eventContext). I like even better
> @PageActivationContext annotation (I'm doing a new project on 5.4.1 so
> I can use it).
>
> So in my earlier example, if I define this:
>
> @PageActivationContext(index=0) private String foo;
> @PageActivationContext(index=1) private String bar;
> @PageActivationContext(index=2) private Long id1;
> @PageActivationContext(index=3) private Long id2;
>
> How do I create links? Can I do this:
>
> <t:pagelink context="['abc','def']">yo</t:pagelink>
> <t:pagelink context=['xyz',10,20]>bam</t:pagelink>
>
> ? Or do I have to explicitly pass null to keep indexes straight?
>
> <t:pagelink context="['abc','def']">yo</t:pagelink>
> <t:pagelink context=['xyz','null'10,20]>bam</t:pagelink>
>
> Adam
>
> On Tue, Sep 20, 2016 at 6:34 PM, Lance Java <la...@googlemail.com>
> wrote:
> > Correction: This feature was added in 5.4 (not 5.3)
> >
> > On 20 Sep 2016 5:29 p.m., "Lance Java" <la...@googlemail.com>
> wrote:
> >
> >> @PageActivationContext supports multiple values thanks to the new index
> >> property added in 5.3. Missing values will simply be null
> >>
> >> Eg:
> >> @PageActivationContext(index=0) private String value0;
> >> @PageActivationContext(index=1) private String value1;
> >> @PageActivationContext(index=2) private String value2;
> >>
> >> More info: https://issues.apache.org/jira/browse/TAP5-2138
> >>
> >> On 20 Sep 2016 5:04 p.m., "Adam X" <vb...@gmail.com> wrote:
> >>
> >>> I would like to have multiple (overloaded) onActivate methods in my
> >>> page but seems like Tapestry is always picking a method with fewest
> >>> arguments.
> >>>
> >>> How can I achieve something like this?
> >>>
> >>> TargetPage {
> >>>
> >>> void onActivate(String foo, String bar) {
> >>> }
> >>>
> >>> void onActivate(String foo, Long id1, Long id2) {
> >>> }
> >>> }
> >>>
> >>> <t:pagelink context="['abc','def']">yo</t:pagelink>
> >>> <t:pagelink context=['xyz',10,20]>bam</t:pagelink>
> >>>
> >>> Adam
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>
> >>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Multiple Page activation context

Posted by Adam X <vb...@gmail.com>.
Wow, you guys rock and support is great. I like
onActivate(EventContext eventContext). I like even better
@PageActivationContext annotation (I'm doing a new project on 5.4.1 so
I can use it).

So in my earlier example, if I define this:

@PageActivationContext(index=0) private String foo;
@PageActivationContext(index=1) private String bar;
@PageActivationContext(index=2) private Long id1;
@PageActivationContext(index=3) private Long id2;

How do I create links? Can I do this:

<t:pagelink context="['abc','def']">yo</t:pagelink>
<t:pagelink context=['xyz',10,20]>bam</t:pagelink>

? Or do I have to explicitly pass null to keep indexes straight?

<t:pagelink context="['abc','def']">yo</t:pagelink>
<t:pagelink context=['xyz','null'10,20]>bam</t:pagelink>

Adam

On Tue, Sep 20, 2016 at 6:34 PM, Lance Java <la...@googlemail.com> wrote:
> Correction: This feature was added in 5.4 (not 5.3)
>
> On 20 Sep 2016 5:29 p.m., "Lance Java" <la...@googlemail.com> wrote:
>
>> @PageActivationContext supports multiple values thanks to the new index
>> property added in 5.3. Missing values will simply be null
>>
>> Eg:
>> @PageActivationContext(index=0) private String value0;
>> @PageActivationContext(index=1) private String value1;
>> @PageActivationContext(index=2) private String value2;
>>
>> More info: https://issues.apache.org/jira/browse/TAP5-2138
>>
>> On 20 Sep 2016 5:04 p.m., "Adam X" <vb...@gmail.com> wrote:
>>
>>> I would like to have multiple (overloaded) onActivate methods in my
>>> page but seems like Tapestry is always picking a method with fewest
>>> arguments.
>>>
>>> How can I achieve something like this?
>>>
>>> TargetPage {
>>>
>>> void onActivate(String foo, String bar) {
>>> }
>>>
>>> void onActivate(String foo, Long id1, Long id2) {
>>> }
>>> }
>>>
>>> <t:pagelink context="['abc','def']">yo</t:pagelink>
>>> <t:pagelink context=['xyz',10,20]>bam</t:pagelink>
>>>
>>> Adam
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>

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


Re: Multiple Page activation context

Posted by Lance Java <la...@googlemail.com>.
Correction: This feature was added in 5.4 (not 5.3)

On 20 Sep 2016 5:29 p.m., "Lance Java" <la...@googlemail.com> wrote:

> @PageActivationContext supports multiple values thanks to the new index
> property added in 5.3. Missing values will simply be null
>
> Eg:
> @PageActivationContext(index=0) private String value0;
> @PageActivationContext(index=1) private String value1;
> @PageActivationContext(index=2) private String value2;
>
> More info: https://issues.apache.org/jira/browse/TAP5-2138
>
> On 20 Sep 2016 5:04 p.m., "Adam X" <vb...@gmail.com> wrote:
>
>> I would like to have multiple (overloaded) onActivate methods in my
>> page but seems like Tapestry is always picking a method with fewest
>> arguments.
>>
>> How can I achieve something like this?
>>
>> TargetPage {
>>
>> void onActivate(String foo, String bar) {
>> }
>>
>> void onActivate(String foo, Long id1, Long id2) {
>> }
>> }
>>
>> <t:pagelink context="['abc','def']">yo</t:pagelink>
>> <t:pagelink context=['xyz',10,20]>bam</t:pagelink>
>>
>> Adam
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>

Re: Multiple Page activation context

Posted by Lance Java <la...@googlemail.com>.
@PageActivationContext supports multiple values thanks to the new index
property added in 5.3. Missing values will simply be null

Eg:
@PageActivationContext(index=0) private String value0;
@PageActivationContext(index=1) private String value1;
@PageActivationContext(index=2) private String value2;

More info: https://issues.apache.org/jira/browse/TAP5-2138

On 20 Sep 2016 5:04 p.m., "Adam X" <vb...@gmail.com> wrote:

> I would like to have multiple (overloaded) onActivate methods in my
> page but seems like Tapestry is always picking a method with fewest
> arguments.
>
> How can I achieve something like this?
>
> TargetPage {
>
> void onActivate(String foo, String bar) {
> }
>
> void onActivate(String foo, Long id1, Long id2) {
> }
> }
>
> <t:pagelink context="['abc','def']">yo</t:pagelink>
> <t:pagelink context=['xyz',10,20]>bam</t:pagelink>
>
> Adam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Multiple Page activation context

Posted by Lance Java <la...@googlemail.com>.
FYI one bonus of using @PageActivationContext is that you automatically
have onPassivate() generated for you. If you declare onActivate() you'll
need to do this yourself

On 20 Sep 2016 5:56 p.m., "Thiago H de Paula Figueiredo" <th...@gmail.com>
wrote:

> On Tue, 20 Sep 2016 13:24:08 -0300, Nathan Quirynen <
> nathan@pensionarchitects.be> wrote:
>
> |You can do something like the following: void onActivate(EventContext
>> eventContext) { |
>> ||if(eventContext.getCount() == 1) { ... } ||||if(eventContext.getCount()
>> == 2) { ... } ||||if(eventContext.getCount() == 3) { ... } ... |||||
>>
>> } |
>>
>
> Exactly. If you end up having more than one onActivate() in the same page
> class, you should instead have just one with a single EventContenxt
> parameter.
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Multiple Page activation context

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 20 Sep 2016 13:24:08 -0300, Nathan Quirynen  
<na...@pensionarchitects.be> wrote:

> |You can do something like the following: void onActivate(EventContext
> eventContext) { |
> ||if(eventContext.getCount() == 1) { ... }  
> ||||if(eventContext.getCount() == 2) { ... }  
> ||||if(eventContext.getCount() == 3) { ... } ... |||||
>
> } |

Exactly. If you end up having more than one onActivate() in the same page  
class, you should instead have just one with a single EventContenxt  
parameter.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: Multiple Page activation context

Posted by Nathan Quirynen <na...@pensionarchitects.be>.
|You can do something like the following: void onActivate(EventContext 
eventContext) { |
||if(eventContext.getCount() == 1) { ... } ||||if(eventContext.getCount() == 2) { ... } ||||if(eventContext.getCount() == 3) { ... } ... |||||

} |

On 20/09/16 18:04, Adam X wrote:
> I would like to have multiple (overloaded) onActivate methods in my
> page but seems like Tapestry is always picking a method with fewest
> arguments.
>
> How can I achieve something like this?
>
> TargetPage {
>
> void onActivate(String foo, String bar) {
> }
>
> void onActivate(String foo, Long id1, Long id2) {
> }
> }
>
> <t:pagelink context="['abc','def']">yo</t:pagelink>
> <t:pagelink context=['xyz',10,20]>bam</t:pagelink>
>
> Adam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>