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/17 13:18:12 UTC

Multiple Context Parameters

Hi,

I have the following event link which works (with single context parameter)

<t:eventlink event="doAjax" t:context="literal:true"
zone="payloadZone">raw</t:eventlink>

In my page class I have the associated handler:

    public void onDoAjax(boolean format) {
        log.debug("{}", format);
    }

Now, I'd like to add a second (dynamic) context parameter. By dynamic
I mean a property from the Page class. What's the best way to do this?

Adam

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


Re: Multiple Context Parameters

Posted by Adam X <vb...@gmail.com>.
Thank you guys :) This is a very valuable knowledge and it's great to
know alternatives.

As a feedback, the jumpstart is a wonderful tool to get started
quickly, but it would be even better if it incorporated some more
scenarios, such as this one. All I could find was several examples
with literal context, thus my question.

Thanks again!

On Sun, Sep 18, 2016 at 12:17 PM, Lance Java <la...@googlemail.com> wrote:
> Assuming foo is a property you could also do
>
> t:context="[foo,'true']" or t:context="[foo,true]"
>
> https://tapestry.apache.org/property-expressions.html
>
> On 18 Sep 2016 11:13 a.m., "Bob Harner" <bo...@gmail.com> wrote:
>
>> Yes, that's the correct way to do it. I think you could also do
>> t:context="foo,bar" if both foo and bar are properties (e.g. a getter for
>> each).
>> On Sep 17, 2016 3:24 PM, "Adam X" <vb...@gmail.com> wrote:
>>
>> > I'm not sure if I did this right but I introduced a getter in my page
>> > class returning object array like this:
>> >
>> > public Object[] getFoo() {
>> >  return new Object[] { tx.id, true };
>> > }
>> >
>> > So this allows me to have a context that is partially dynamic
>> > (transaction id) and partially static (literal):
>> >
>> > public void onAjax(String txId, String fmt) {
>> > }
>> >
>> > This works.
>> >
>> > Adam
>> >
>> > On Sat, Sep 17, 2016 at 3:18 PM, Adam X <vb...@gmail.com> wrote:
>> > > Hi,
>> > >
>> > > I have the following event link which works (with single context
>> > parameter)
>> > >
>> > > <t:eventlink event="doAjax" t:context="literal:true"
>> > > zone="payloadZone">raw</t:eventlink>
>> > >
>> > > In my page class I have the associated handler:
>> > >
>> > >     public void onDoAjax(boolean format) {
>> > >         log.debug("{}", format);
>> > >     }
>> > >
>> > > Now, I'd like to add a second (dynamic) context parameter. By dynamic
>> > > I mean a property from the Page class. What's the best way to do this?
>> > >
>> > > 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 Context Parameters

Posted by Lance Java <la...@googlemail.com>.
Assuming foo is a property you could also do

t:context="[foo,'true']" or t:context="[foo,true]"

https://tapestry.apache.org/property-expressions.html

On 18 Sep 2016 11:13 a.m., "Bob Harner" <bo...@gmail.com> wrote:

> Yes, that's the correct way to do it. I think you could also do
> t:context="foo,bar" if both foo and bar are properties (e.g. a getter for
> each).
> On Sep 17, 2016 3:24 PM, "Adam X" <vb...@gmail.com> wrote:
>
> > I'm not sure if I did this right but I introduced a getter in my page
> > class returning object array like this:
> >
> > public Object[] getFoo() {
> >  return new Object[] { tx.id, true };
> > }
> >
> > So this allows me to have a context that is partially dynamic
> > (transaction id) and partially static (literal):
> >
> > public void onAjax(String txId, String fmt) {
> > }
> >
> > This works.
> >
> > Adam
> >
> > On Sat, Sep 17, 2016 at 3:18 PM, Adam X <vb...@gmail.com> wrote:
> > > Hi,
> > >
> > > I have the following event link which works (with single context
> > parameter)
> > >
> > > <t:eventlink event="doAjax" t:context="literal:true"
> > > zone="payloadZone">raw</t:eventlink>
> > >
> > > In my page class I have the associated handler:
> > >
> > >     public void onDoAjax(boolean format) {
> > >         log.debug("{}", format);
> > >     }
> > >
> > > Now, I'd like to add a second (dynamic) context parameter. By dynamic
> > > I mean a property from the Page class. What's the best way to do this?
> > >
> > > Adam
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>

Re: Multiple Context Parameters

Posted by Bob Harner <bo...@gmail.com>.
Yes, that's the correct way to do it. I think you could also do
t:context="foo,bar" if both foo and bar are properties (e.g. a getter for
each).
On Sep 17, 2016 3:24 PM, "Adam X" <vb...@gmail.com> wrote:

> I'm not sure if I did this right but I introduced a getter in my page
> class returning object array like this:
>
> public Object[] getFoo() {
>  return new Object[] { tx.id, true };
> }
>
> So this allows me to have a context that is partially dynamic
> (transaction id) and partially static (literal):
>
> public void onAjax(String txId, String fmt) {
> }
>
> This works.
>
> Adam
>
> On Sat, Sep 17, 2016 at 3:18 PM, Adam X <vb...@gmail.com> wrote:
> > Hi,
> >
> > I have the following event link which works (with single context
> parameter)
> >
> > <t:eventlink event="doAjax" t:context="literal:true"
> > zone="payloadZone">raw</t:eventlink>
> >
> > In my page class I have the associated handler:
> >
> >     public void onDoAjax(boolean format) {
> >         log.debug("{}", format);
> >     }
> >
> > Now, I'd like to add a second (dynamic) context parameter. By dynamic
> > I mean a property from the Page class. What's the best way to do this?
> >
> > Adam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Multiple Context Parameters

Posted by Adam X <vb...@gmail.com>.
I'm not sure if I did this right but I introduced a getter in my page
class returning object array like this:

public Object[] getFoo() {
 return new Object[] { tx.id, true };
}

So this allows me to have a context that is partially dynamic
(transaction id) and partially static (literal):

public void onAjax(String txId, String fmt) {
}

This works.

Adam

On Sat, Sep 17, 2016 at 3:18 PM, Adam X <vb...@gmail.com> wrote:
> Hi,
>
> I have the following event link which works (with single context parameter)
>
> <t:eventlink event="doAjax" t:context="literal:true"
> zone="payloadZone">raw</t:eventlink>
>
> In my page class I have the associated handler:
>
>     public void onDoAjax(boolean format) {
>         log.debug("{}", format);
>     }
>
> Now, I'd like to add a second (dynamic) context parameter. By dynamic
> I mean a property from the Page class. What's the best way to do this?
>
> Adam

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