Quantcast

Recommended way to instantiate EventContext

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Recommended way to instantiate EventContext

Adam X
Howdy again!

So what's the approved Tapestry way to create an instance of this interface?

Adam

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Recommended way to instantiate EventContext

hvass
Hey again!

Are you trying to pass a value to the context parameter of an eventlink by
any chance?

You can just use any old properties in Java classes - either the Tapestry
way with an @Property attached to a field or a public getter of any old
type. If it's anything beyond standard Java types (i.e.: string, int,
double etc.) then you'll need to provide a bit of extra code to pass it in
as context. For multiple context items you would use square brackets.

i.e.:
@Property
private String somevalue;

<t:eventlink event="foo" context="somevalue">Foo</t:eventlink>

void onFoo(String someValue) {

}

----or-----

@Property
private String bar;

@Property
private Integer baz;

<t:eventlink event="foo" context="[bar, baz]">Foo</t:eventlink>

void onFoo(String bar, Integer baz) {

}

Is that sort of what you're looking for?

Thanks,
Peter



On 28 November 2016 at 19:13, Adam X <[hidden email]> wrote:

> Howdy again!
>
> So what's the approved Tapestry way to create an instance of this
> interface?
>
> Adam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Recommended way to instantiate EventContext

Adam X
I'm trying to passivate large number (and dynamic) contexts. The
signature of my activation looks like this:

    @OnEvent(value=EventConstants.ACTIVATE)
    void parseContext(EventContext ec) {

and there is a lot going on in there as far as parsing the context. So
I'm trying to do this to passivate:

    @OnEvent(value=EventConstants.PASSIVATE)
    Object restoreContext() {

trying to return an instance of EventContext but I see there are only
two implementations of this interface, both in the internal package
which Tapestry discourages from using.

Adam

On Mon, Nov 28, 2016 at 6:18 PM, Peter Hvass <[hidden email]> wrote:

> Hey again!
>
> Are you trying to pass a value to the context parameter of an eventlink by
> any chance?
>
> You can just use any old properties in Java classes - either the Tapestry
> way with an @Property attached to a field or a public getter of any old
> type. If it's anything beyond standard Java types (i.e.: string, int,
> double etc.) then you'll need to provide a bit of extra code to pass it in
> as context. For multiple context items you would use square brackets.
>
> i.e.:
> @Property
> private String somevalue;
>
> <t:eventlink event="foo" context="somevalue">Foo</t:eventlink>
>
> void onFoo(String someValue) {
>
> }
>
> ----or-----
>
> @Property
> private String bar;
>
> @Property
> private Integer baz;
>
> <t:eventlink event="foo" context="[bar, baz]">Foo</t:eventlink>
>
> void onFoo(String bar, Integer baz) {
>
> }
>
> Is that sort of what you're looking for?
>
> Thanks,
> Peter
>
>
>
> On 28 November 2016 at 19:13, Adam X <[hidden email]> wrote:
>
>> Howdy again!
>>
>> So what's the approved Tapestry way to create an instance of this
>> interface?
>>
>> Adam
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Recommended way to instantiate EventContext

Adam X
Okay, I tried @Persist(FLASH) EventContext ec storing it in activation
and simply returning in passivation and it works.

This came up as I was trying to solve a different problem which is
still haunting me. Essentially, I did a modal feature just like in the
jumpstart and it all works very nice:

http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/modal/1

The problem is that my modal zone lives in the Layout component
(imagine a switch login context feature or something similar, not
important). Like I said, the modal form works okay, but the problem is
(and I think it's because it's inside Layout) when zone is updated it
reloads entire page anyway. That is actually a desired behavior for me
except that it seems to forget whatever URL context was on the page
and it reloads the faw url.

So if I invoke my modal form on a transaction listing page:

/transactionlist/fromdate/untildate

where fromdate and untildate are url contexts, the zone reloads page with this:

/transactionlist

and I can't seem to figure out how to tell it to reload whatever URL was there.

Adam

On Mon, Nov 28, 2016 at 6:23 PM, Adam X <[hidden email]> wrote:

> I'm trying to passivate large number (and dynamic) contexts. The
> signature of my activation looks like this:
>
>     @OnEvent(value=EventConstants.ACTIVATE)
>     void parseContext(EventContext ec) {
>
> and there is a lot going on in there as far as parsing the context. So
> I'm trying to do this to passivate:
>
>     @OnEvent(value=EventConstants.PASSIVATE)
>     Object restoreContext() {
>
> trying to return an instance of EventContext but I see there are only
> two implementations of this interface, both in the internal package
> which Tapestry discourages from using.
>
> Adam
>
> On Mon, Nov 28, 2016 at 6:18 PM, Peter Hvass <[hidden email]> wrote:
>> Hey again!
>>
>> Are you trying to pass a value to the context parameter of an eventlink by
>> any chance?
>>
>> You can just use any old properties in Java classes - either the Tapestry
>> way with an @Property attached to a field or a public getter of any old
>> type. If it's anything beyond standard Java types (i.e.: string, int,
>> double etc.) then you'll need to provide a bit of extra code to pass it in
>> as context. For multiple context items you would use square brackets.
>>
>> i.e.:
>> @Property
>> private String somevalue;
>>
>> <t:eventlink event="foo" context="somevalue">Foo</t:eventlink>
>>
>> void onFoo(String someValue) {
>>
>> }
>>
>> ----or-----
>>
>> @Property
>> private String bar;
>>
>> @Property
>> private Integer baz;
>>
>> <t:eventlink event="foo" context="[bar, baz]">Foo</t:eventlink>
>>
>> void onFoo(String bar, Integer baz) {
>>
>> }
>>
>> Is that sort of what you're looking for?
>>
>> Thanks,
>> Peter
>>
>>
>>
>> On 28 November 2016 at 19:13, Adam X <[hidden email]> wrote:
>>
>>> Howdy again!
>>>
>>> So what's the approved Tapestry way to create an instance of this
>>> interface?
>>>
>>> Adam
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Recommended way to instantiate EventContext

Chris Poulsen
Normally you would return an Object[] from passivate and tapestry will
coerce it into the correct result.

--
Chris

On Mon, Nov 28, 2016 at 6:41 PM, Adam X <[hidden email]> wrote:

> Okay, I tried @Persist(FLASH) EventContext ec storing it in activation
> and simply returning in passivation and it works.
>
> This came up as I was trying to solve a different problem which is
> still haunting me. Essentially, I did a modal feature just like in the
> jumpstart and it all works very nice:
>
> http://jumpstart.doublenegative.com.au/jumpstart7/examples/
> javascript/modal/1
>
> The problem is that my modal zone lives in the Layout component
> (imagine a switch login context feature or something similar, not
> important). Like I said, the modal form works okay, but the problem is
> (and I think it's because it's inside Layout) when zone is updated it
> reloads entire page anyway. That is actually a desired behavior for me
> except that it seems to forget whatever URL context was on the page
> and it reloads the faw url.
>
> So if I invoke my modal form on a transaction listing page:
>
> /transactionlist/fromdate/untildate
>
> where fromdate and untildate are url contexts, the zone reloads page with
> this:
>
> /transactionlist
>
> and I can't seem to figure out how to tell it to reload whatever URL was
> there.
>
> Adam
>
> On Mon, Nov 28, 2016 at 6:23 PM, Adam X <[hidden email]> wrote:
> > I'm trying to passivate large number (and dynamic) contexts. The
> > signature of my activation looks like this:
> >
> >     @OnEvent(value=EventConstants.ACTIVATE)
> >     void parseContext(EventContext ec) {
> >
> > and there is a lot going on in there as far as parsing the context. So
> > I'm trying to do this to passivate:
> >
> >     @OnEvent(value=EventConstants.PASSIVATE)
> >     Object restoreContext() {
> >
> > trying to return an instance of EventContext but I see there are only
> > two implementations of this interface, both in the internal package
> > which Tapestry discourages from using.
> >
> > Adam
> >
> > On Mon, Nov 28, 2016 at 6:18 PM, Peter Hvass <[hidden email]>
> wrote:
> >> Hey again!
> >>
> >> Are you trying to pass a value to the context parameter of an eventlink
> by
> >> any chance?
> >>
> >> You can just use any old properties in Java classes - either the
> Tapestry
> >> way with an @Property attached to a field or a public getter of any old
> >> type. If it's anything beyond standard Java types (i.e.: string, int,
> >> double etc.) then you'll need to provide a bit of extra code to pass it
> in
> >> as context. For multiple context items you would use square brackets.
> >>
> >> i.e.:
> >> @Property
> >> private String somevalue;
> >>
> >> <t:eventlink event="foo" context="somevalue">Foo</t:eventlink>
> >>
> >> void onFoo(String someValue) {
> >>
> >> }
> >>
> >> ----or-----
> >>
> >> @Property
> >> private String bar;
> >>
> >> @Property
> >> private Integer baz;
> >>
> >> <t:eventlink event="foo" context="[bar, baz]">Foo</t:eventlink>
> >>
> >> void onFoo(String bar, Integer baz) {
> >>
> >> }
> >>
> >> Is that sort of what you're looking for?
> >>
> >> Thanks,
> >> Peter
> >>
> >>
> >>
> >> On 28 November 2016 at 19:13, Adam X <[hidden email]> wrote:
> >>
> >>> Howdy again!
> >>>
> >>> So what's the approved Tapestry way to create an instance of this
> >>> interface?
> >>>
> >>> Adam
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [hidden email]
> >>> For additional commands, e-mail: [hidden email]
> >>>
> >>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Recommended way to instantiate EventContext

Adam X
Thanks Chris. I got it all working.

On Mon, Nov 28, 2016 at 7:32 PM, Chris Poulsen <[hidden email]> wrote:

> Normally you would return an Object[] from passivate and tapestry will
> coerce it into the correct result.
>
> --
> Chris
>
> On Mon, Nov 28, 2016 at 6:41 PM, Adam X <[hidden email]> wrote:
>
>> Okay, I tried @Persist(FLASH) EventContext ec storing it in activation
>> and simply returning in passivation and it works.
>>
>> This came up as I was trying to solve a different problem which is
>> still haunting me. Essentially, I did a modal feature just like in the
>> jumpstart and it all works very nice:
>>
>> http://jumpstart.doublenegative.com.au/jumpstart7/examples/
>> javascript/modal/1
>>
>> The problem is that my modal zone lives in the Layout component
>> (imagine a switch login context feature or something similar, not
>> important). Like I said, the modal form works okay, but the problem is
>> (and I think it's because it's inside Layout) when zone is updated it
>> reloads entire page anyway. That is actually a desired behavior for me
>> except that it seems to forget whatever URL context was on the page
>> and it reloads the faw url.
>>
>> So if I invoke my modal form on a transaction listing page:
>>
>> /transactionlist/fromdate/untildate
>>
>> where fromdate and untildate are url contexts, the zone reloads page with
>> this:
>>
>> /transactionlist
>>
>> and I can't seem to figure out how to tell it to reload whatever URL was
>> there.
>>
>> Adam
>>
>> On Mon, Nov 28, 2016 at 6:23 PM, Adam X <[hidden email]> wrote:
>> > I'm trying to passivate large number (and dynamic) contexts. The
>> > signature of my activation looks like this:
>> >
>> >     @OnEvent(value=EventConstants.ACTIVATE)
>> >     void parseContext(EventContext ec) {
>> >
>> > and there is a lot going on in there as far as parsing the context. So
>> > I'm trying to do this to passivate:
>> >
>> >     @OnEvent(value=EventConstants.PASSIVATE)
>> >     Object restoreContext() {
>> >
>> > trying to return an instance of EventContext but I see there are only
>> > two implementations of this interface, both in the internal package
>> > which Tapestry discourages from using.
>> >
>> > Adam
>> >
>> > On Mon, Nov 28, 2016 at 6:18 PM, Peter Hvass <[hidden email]>
>> wrote:
>> >> Hey again!
>> >>
>> >> Are you trying to pass a value to the context parameter of an eventlink
>> by
>> >> any chance?
>> >>
>> >> You can just use any old properties in Java classes - either the
>> Tapestry
>> >> way with an @Property attached to a field or a public getter of any old
>> >> type. If it's anything beyond standard Java types (i.e.: string, int,
>> >> double etc.) then you'll need to provide a bit of extra code to pass it
>> in
>> >> as context. For multiple context items you would use square brackets.
>> >>
>> >> i.e.:
>> >> @Property
>> >> private String somevalue;
>> >>
>> >> <t:eventlink event="foo" context="somevalue">Foo</t:eventlink>
>> >>
>> >> void onFoo(String someValue) {
>> >>
>> >> }
>> >>
>> >> ----or-----
>> >>
>> >> @Property
>> >> private String bar;
>> >>
>> >> @Property
>> >> private Integer baz;
>> >>
>> >> <t:eventlink event="foo" context="[bar, baz]">Foo</t:eventlink>
>> >>
>> >> void onFoo(String bar, Integer baz) {
>> >>
>> >> }
>> >>
>> >> Is that sort of what you're looking for?
>> >>
>> >> Thanks,
>> >> Peter
>> >>
>> >>
>> >>
>> >> On 28 November 2016 at 19:13, Adam X <[hidden email]> wrote:
>> >>
>> >>> Howdy again!
>> >>>
>> >>> So what's the approved Tapestry way to create an instance of this
>> >>> interface?
>> >>>
>> >>> Adam
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: [hidden email]
>> >>> For additional commands, e-mail: [hidden email]
>> >>>
>> >>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...