You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Boris Horvat <ho...@gmail.com> on 2014/09/08 23:21:42 UTC

Tapestry onActivate messes up after submitting a form

Hi all,

I have an onActivate(MyObject) method, when I go to the page for the first
time and context is present everything is triggered properly. The url is
something like

localhost:8080/mypage/1

However when I submit my form, and process it, page reloads and my id is
now treated as a String that fails to be converted into object. Is this
behaviour expected? Do I need to add something special into the form to
keep context properly passed?

Thanks

-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Lance Java <la...@googlemail.com>.
What are you hoping to achieve by returning boolean from onActivate()?

Have you tried a @PageActivationContext annotation instead on onActivate /
onPassivate?

> I don't have ValueEncoder cause I would expect that conversion works
String -> Long -> hibernate gets the id of the object and returns ->
MyObject

That's not really correct. You do have a ValueEncoder, tapestry-hibernate
contributes them for all of your entities automagically.

Re: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
I have tried it yesterday and it is working perfectly now. I have also
commentated that yesterday on the ticket.

Thanks for quick resolution

Cheers

On Wed, Sep 17, 2014 at 11:24 PM, Lance Java <la...@googlemail.com>
wrote:

> This has been fixed in tapestry-cometd 0.9.19
>
> Please give it a try
>
> On 15 September 2014 22:14, Boris Horvat <ho...@gmail.com> wrote:
>
> > Sure I will answer them. Thanks for help in identifying this
> >
> > On Mon, Sep 15, 2014 at 10:18 AM, Lance Java <la...@googlemail.com>
> > wrote:
> >
> > > I've created an issue here:
> > > https://github.com/uklance/tapestry-cometd/issues/62
> > >
> > > Not sure of an eta yet. You could help by answering the questions in
> the
> > > issue.
> > >  On 14 Sep 2014 23:27, "Boris Horvat" <ho...@gmail.com>
> wrote:
> > >
> > > > Brilliant at least we figured out the issue here :)
> > > >
> > > > Any eta on the fix? I would be happy to test the fix :)
> > > >
> > > > On Sun, Sep 14, 2014 at 11:49 PM, Lance Java <
> > lance.java@googlemail.com>
> > > > wrote:
> > > >
> > > > > Yes, looks like a bug. I assumed the ArrayEventContext would it's
> > > > > TypeCoercer reference to do the type coercion. Seems I was wrong.
> > > > >
> > > > > The workaround for now is to convert from string yourself.
> > > > >  On 14 Sep 2014 22:17, "Boris Horvat" <ho...@gmail.com>
> > > wrote:
> > > > >
> > > > > > You are right, the implementation is different between the two
> > cases.
> > > > > >
> > > > > >    - eventContext =
> > > > > >
> > {org.apache.tapestry5.internal.*URLEventContext*@10311}"EventContext:
> > > > > >    null"
> > > > > >       - valueEncoder = {$ContextValueEncoder_9660c5cdf431@10618
> }""
> > > > > >       - values = {java.lang.String[1]@10619}
> > > > > >       - values = null
> > > > > >
> > > > > >
> > > > > >    - eventContext = {org.apache.tapestry5.internal.services.
> > > > > >    *ArrayEventContext*@10795}"EventContext: null"
> > > > > >       - typeCoercer = {$TypeCoercer_9660c5cdf3af@10797}""
> > > > > >       - values = {java.lang.Object[1]@10798}
> > > > > >       - values = null
> > > > > >
> > > > > > So this is a bug?
> > > > > >
> > > > > > Thanks :)
> > > > > >
> > > > > >
> > > > > > On Sun, Sep 14, 2014 at 11:08 PM, Lance Java <
> > > > lance.java@googlemail.com>
> > > > > > wrote:
> > > > > >
> > > > > > > Hmm... Perhaps this is a bug in the way tapestry-cometd fires
> the
> > > > > > > onActivate.
> > > > > > >
> > > > > > > Can you fire up a debugger and inspect the EventContext object
> > > passed
> > > > > to
> > > > > > > onActivate() in
> > > > > > > 1. the normal page render
> > > > > > > 2. the tapestry-cometd component
> > > > > > >
> > > > > > > I think there's something preventing type coercion (which
> passes
> > > > > through
> > > > > > to
> > > > > > > ValueEncoder). I'm guessing it's a different EventContext
> > > > > implementation
> > > > > > in
> > > > > > > the 2 cases.
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Sincerely
> > > > > > *Boris Horvat*
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Sincerely
> > > > *Boris Horvat*
> > > >
> > >
> >
> >
> >
> > --
> > Sincerely
> > *Boris Horvat*
> >
>



-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Lance Java <la...@googlemail.com>.
This has been fixed in tapestry-cometd 0.9.19

Please give it a try

On 15 September 2014 22:14, Boris Horvat <ho...@gmail.com> wrote:

> Sure I will answer them. Thanks for help in identifying this
>
> On Mon, Sep 15, 2014 at 10:18 AM, Lance Java <la...@googlemail.com>
> wrote:
>
> > I've created an issue here:
> > https://github.com/uklance/tapestry-cometd/issues/62
> >
> > Not sure of an eta yet. You could help by answering the questions in the
> > issue.
> >  On 14 Sep 2014 23:27, "Boris Horvat" <ho...@gmail.com> wrote:
> >
> > > Brilliant at least we figured out the issue here :)
> > >
> > > Any eta on the fix? I would be happy to test the fix :)
> > >
> > > On Sun, Sep 14, 2014 at 11:49 PM, Lance Java <
> lance.java@googlemail.com>
> > > wrote:
> > >
> > > > Yes, looks like a bug. I assumed the ArrayEventContext would it's
> > > > TypeCoercer reference to do the type coercion. Seems I was wrong.
> > > >
> > > > The workaround for now is to convert from string yourself.
> > > >  On 14 Sep 2014 22:17, "Boris Horvat" <ho...@gmail.com>
> > wrote:
> > > >
> > > > > You are right, the implementation is different between the two
> cases.
> > > > >
> > > > >    - eventContext =
> > > > >
> {org.apache.tapestry5.internal.*URLEventContext*@10311}"EventContext:
> > > > >    null"
> > > > >       - valueEncoder = {$ContextValueEncoder_9660c5cdf431@10618}""
> > > > >       - values = {java.lang.String[1]@10619}
> > > > >       - values = null
> > > > >
> > > > >
> > > > >    - eventContext = {org.apache.tapestry5.internal.services.
> > > > >    *ArrayEventContext*@10795}"EventContext: null"
> > > > >       - typeCoercer = {$TypeCoercer_9660c5cdf3af@10797}""
> > > > >       - values = {java.lang.Object[1]@10798}
> > > > >       - values = null
> > > > >
> > > > > So this is a bug?
> > > > >
> > > > > Thanks :)
> > > > >
> > > > >
> > > > > On Sun, Sep 14, 2014 at 11:08 PM, Lance Java <
> > > lance.java@googlemail.com>
> > > > > wrote:
> > > > >
> > > > > > Hmm... Perhaps this is a bug in the way tapestry-cometd fires the
> > > > > > onActivate.
> > > > > >
> > > > > > Can you fire up a debugger and inspect the EventContext object
> > passed
> > > > to
> > > > > > onActivate() in
> > > > > > 1. the normal page render
> > > > > > 2. the tapestry-cometd component
> > > > > >
> > > > > > I think there's something preventing type coercion (which passes
> > > > through
> > > > > to
> > > > > > ValueEncoder). I'm guessing it's a different EventContext
> > > > implementation
> > > > > in
> > > > > > the 2 cases.
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Sincerely
> > > > > *Boris Horvat*
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Sincerely
> > > *Boris Horvat*
> > >
> >
>
>
>
> --
> Sincerely
> *Boris Horvat*
>

Re: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
Sure I will answer them. Thanks for help in identifying this

On Mon, Sep 15, 2014 at 10:18 AM, Lance Java <la...@googlemail.com>
wrote:

> I've created an issue here:
> https://github.com/uklance/tapestry-cometd/issues/62
>
> Not sure of an eta yet. You could help by answering the questions in the
> issue.
>  On 14 Sep 2014 23:27, "Boris Horvat" <ho...@gmail.com> wrote:
>
> > Brilliant at least we figured out the issue here :)
> >
> > Any eta on the fix? I would be happy to test the fix :)
> >
> > On Sun, Sep 14, 2014 at 11:49 PM, Lance Java <la...@googlemail.com>
> > wrote:
> >
> > > Yes, looks like a bug. I assumed the ArrayEventContext would it's
> > > TypeCoercer reference to do the type coercion. Seems I was wrong.
> > >
> > > The workaround for now is to convert from string yourself.
> > >  On 14 Sep 2014 22:17, "Boris Horvat" <ho...@gmail.com>
> wrote:
> > >
> > > > You are right, the implementation is different between the two cases.
> > > >
> > > >    - eventContext =
> > > > {org.apache.tapestry5.internal.*URLEventContext*@10311}"EventContext:
> > > >    null"
> > > >       - valueEncoder = {$ContextValueEncoder_9660c5cdf431@10618}""
> > > >       - values = {java.lang.String[1]@10619}
> > > >       - values = null
> > > >
> > > >
> > > >    - eventContext = {org.apache.tapestry5.internal.services.
> > > >    *ArrayEventContext*@10795}"EventContext: null"
> > > >       - typeCoercer = {$TypeCoercer_9660c5cdf3af@10797}""
> > > >       - values = {java.lang.Object[1]@10798}
> > > >       - values = null
> > > >
> > > > So this is a bug?
> > > >
> > > > Thanks :)
> > > >
> > > >
> > > > On Sun, Sep 14, 2014 at 11:08 PM, Lance Java <
> > lance.java@googlemail.com>
> > > > wrote:
> > > >
> > > > > Hmm... Perhaps this is a bug in the way tapestry-cometd fires the
> > > > > onActivate.
> > > > >
> > > > > Can you fire up a debugger and inspect the EventContext object
> passed
> > > to
> > > > > onActivate() in
> > > > > 1. the normal page render
> > > > > 2. the tapestry-cometd component
> > > > >
> > > > > I think there's something preventing type coercion (which passes
> > > through
> > > > to
> > > > > ValueEncoder). I'm guessing it's a different EventContext
> > > implementation
> > > > in
> > > > > the 2 cases.
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Sincerely
> > > > *Boris Horvat*
> > > >
> > >
> >
> >
> >
> > --
> > Sincerely
> > *Boris Horvat*
> >
>



-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Lance Java <la...@googlemail.com>.
I've created an issue here:
https://github.com/uklance/tapestry-cometd/issues/62

Not sure of an eta yet. You could help by answering the questions in the
issue.
 On 14 Sep 2014 23:27, "Boris Horvat" <ho...@gmail.com> wrote:

> Brilliant at least we figured out the issue here :)
>
> Any eta on the fix? I would be happy to test the fix :)
>
> On Sun, Sep 14, 2014 at 11:49 PM, Lance Java <la...@googlemail.com>
> wrote:
>
> > Yes, looks like a bug. I assumed the ArrayEventContext would it's
> > TypeCoercer reference to do the type coercion. Seems I was wrong.
> >
> > The workaround for now is to convert from string yourself.
> >  On 14 Sep 2014 22:17, "Boris Horvat" <ho...@gmail.com> wrote:
> >
> > > You are right, the implementation is different between the two cases.
> > >
> > >    - eventContext =
> > > {org.apache.tapestry5.internal.*URLEventContext*@10311}"EventContext:
> > >    null"
> > >       - valueEncoder = {$ContextValueEncoder_9660c5cdf431@10618}""
> > >       - values = {java.lang.String[1]@10619}
> > >       - values = null
> > >
> > >
> > >    - eventContext = {org.apache.tapestry5.internal.services.
> > >    *ArrayEventContext*@10795}"EventContext: null"
> > >       - typeCoercer = {$TypeCoercer_9660c5cdf3af@10797}""
> > >       - values = {java.lang.Object[1]@10798}
> > >       - values = null
> > >
> > > So this is a bug?
> > >
> > > Thanks :)
> > >
> > >
> > > On Sun, Sep 14, 2014 at 11:08 PM, Lance Java <
> lance.java@googlemail.com>
> > > wrote:
> > >
> > > > Hmm... Perhaps this is a bug in the way tapestry-cometd fires the
> > > > onActivate.
> > > >
> > > > Can you fire up a debugger and inspect the EventContext object passed
> > to
> > > > onActivate() in
> > > > 1. the normal page render
> > > > 2. the tapestry-cometd component
> > > >
> > > > I think there's something preventing type coercion (which passes
> > through
> > > to
> > > > ValueEncoder). I'm guessing it's a different EventContext
> > implementation
> > > in
> > > > the 2 cases.
> > > >
> > >
> > >
> > >
> > > --
> > > Sincerely
> > > *Boris Horvat*
> > >
> >
>
>
>
> --
> Sincerely
> *Boris Horvat*
>

Re: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
Brilliant at least we figured out the issue here :)

Any eta on the fix? I would be happy to test the fix :)

On Sun, Sep 14, 2014 at 11:49 PM, Lance Java <la...@googlemail.com>
wrote:

> Yes, looks like a bug. I assumed the ArrayEventContext would it's
> TypeCoercer reference to do the type coercion. Seems I was wrong.
>
> The workaround for now is to convert from string yourself.
>  On 14 Sep 2014 22:17, "Boris Horvat" <ho...@gmail.com> wrote:
>
> > You are right, the implementation is different between the two cases.
> >
> >    - eventContext =
> > {org.apache.tapestry5.internal.*URLEventContext*@10311}"EventContext:
> >    null"
> >       - valueEncoder = {$ContextValueEncoder_9660c5cdf431@10618}""
> >       - values = {java.lang.String[1]@10619}
> >       - values = null
> >
> >
> >    - eventContext = {org.apache.tapestry5.internal.services.
> >    *ArrayEventContext*@10795}"EventContext: null"
> >       - typeCoercer = {$TypeCoercer_9660c5cdf3af@10797}""
> >       - values = {java.lang.Object[1]@10798}
> >       - values = null
> >
> > So this is a bug?
> >
> > Thanks :)
> >
> >
> > On Sun, Sep 14, 2014 at 11:08 PM, Lance Java <la...@googlemail.com>
> > wrote:
> >
> > > Hmm... Perhaps this is a bug in the way tapestry-cometd fires the
> > > onActivate.
> > >
> > > Can you fire up a debugger and inspect the EventContext object passed
> to
> > > onActivate() in
> > > 1. the normal page render
> > > 2. the tapestry-cometd component
> > >
> > > I think there's something preventing type coercion (which passes
> through
> > to
> > > ValueEncoder). I'm guessing it's a different EventContext
> implementation
> > in
> > > the 2 cases.
> > >
> >
> >
> >
> > --
> > Sincerely
> > *Boris Horvat*
> >
>



-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Lance Java <la...@googlemail.com>.
Yes, looks like a bug. I assumed the ArrayEventContext would it's
TypeCoercer reference to do the type coercion. Seems I was wrong.

The workaround for now is to convert from string yourself.
 On 14 Sep 2014 22:17, "Boris Horvat" <ho...@gmail.com> wrote:

> You are right, the implementation is different between the two cases.
>
>    - eventContext =
> {org.apache.tapestry5.internal.*URLEventContext*@10311}"EventContext:
>    null"
>       - valueEncoder = {$ContextValueEncoder_9660c5cdf431@10618}""
>       - values = {java.lang.String[1]@10619}
>       - values = null
>
>
>    - eventContext = {org.apache.tapestry5.internal.services.
>    *ArrayEventContext*@10795}"EventContext: null"
>       - typeCoercer = {$TypeCoercer_9660c5cdf3af@10797}""
>       - values = {java.lang.Object[1]@10798}
>       - values = null
>
> So this is a bug?
>
> Thanks :)
>
>
> On Sun, Sep 14, 2014 at 11:08 PM, Lance Java <la...@googlemail.com>
> wrote:
>
> > Hmm... Perhaps this is a bug in the way tapestry-cometd fires the
> > onActivate.
> >
> > Can you fire up a debugger and inspect the EventContext object passed to
> > onActivate() in
> > 1. the normal page render
> > 2. the tapestry-cometd component
> >
> > I think there's something preventing type coercion (which passes through
> to
> > ValueEncoder). I'm guessing it's a different EventContext implementation
> in
> > the 2 cases.
> >
>
>
>
> --
> Sincerely
> *Boris Horvat*
>

Re: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
You are right, the implementation is different between the two cases.

   - eventContext =
{org.apache.tapestry5.internal.*URLEventContext*@10311}"EventContext:
   null"
      - valueEncoder = {$ContextValueEncoder_9660c5cdf431@10618}""
      - values = {java.lang.String[1]@10619}
      - values = null


   - eventContext = {org.apache.tapestry5.internal.services.
   *ArrayEventContext*@10795}"EventContext: null"
      - typeCoercer = {$TypeCoercer_9660c5cdf3af@10797}""
      - values = {java.lang.Object[1]@10798}
      - values = null

So this is a bug?

Thanks :)


On Sun, Sep 14, 2014 at 11:08 PM, Lance Java <la...@googlemail.com>
wrote:

> Hmm... Perhaps this is a bug in the way tapestry-cometd fires the
> onActivate.
>
> Can you fire up a debugger and inspect the EventContext object passed to
> onActivate() in
> 1. the normal page render
> 2. the tapestry-cometd component
>
> I think there's something preventing type coercion (which passes through to
> ValueEncoder). I'm guessing it's a different EventContext implementation in
> the 2 cases.
>



-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Lance Java <la...@googlemail.com>.
Hmm... Perhaps this is a bug in the way tapestry-cometd fires the
onActivate.

Can you fire up a debugger and inspect the EventContext object passed to
onActivate() in
1. the normal page render
2. the tapestry-cometd component

I think there's something preventing type coercion (which passes through to
ValueEncoder). I'm guessing it's a different EventContext implementation in
the 2 cases.

Re: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
True the form is not ajax, do you think it would help if it was?

But even if the PushTarget is triggered with the old data I dont get why
the exception is thrown. I would understand if it loads wrong object...but
not to get coercion exception, right?

What would be the best way to resolve this issue then?

Thanks

On Sun, Sep 14, 2014 at 9:24 PM, Lance Java <la...@googlemail.com>
wrote:

> When a PushTarget renders, it fires up a cometd connection to receive
> updates. At this point it registers the page activation context.
>
> serverside push events fire a component event. But before this, tapestry
> first fires the onActivate with the push target's page activation context.
>
> From your earlier comments, the form submission is not ajax. So I can only
> assume a new page render occurs after onSuccess (with a new PushTarget).
>
> There's likely a situation where the serverside is attempting to push to
> the old PushTarget (with the old page activation context value) before the
> page refreshes.
>



-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Lance Java <la...@googlemail.com>.
When a PushTarget renders, it fires up a cometd connection to receive
updates. At this point it registers the page activation context.

serverside push events fire a component event. But before this, tapestry
first fires the onActivate with the push target's page activation context.

>From your earlier comments, the form submission is not ajax. So I can only
assume a new page render occurs after onSuccess (with a new PushTarget).

There's likely a situation where the serverside is attempting to push to
the old PushTarget (with the old page activation context value) before the
page refreshes.

Re: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
Yea, I didn't expect that this would mess with the event context to be
honest (and I am not sure how it does) but as I was excluding line by line
and managed to find the issue.
Indeed you are correct this belongs to the cometd.

What details are you interested in?

The use case is that a user uses a form to create a new object and this
sends a notification to the header (which is a component in the page).
Header has a notificatoin system in page and it refreshes this.

The code looks something like this

Push relevant code on the page

   @Inject
    private PushManager pushManager;

    //inside a form success method

    pushManager.broadcast(catalogue.format("push.channel.menu_items",
studioAccountUser.getId()), MenuProfile.ProfilePage.SOCIAL);

In the header

  <t:cometd.PushTarget topic="prop:channelMenuItems"
event="updateMenuItems" update="replace" session="true"/>
  <t:block t:id="blockGroupNotificationNumber">
 </t:block>

    @OnEvent("updateMenuItems")
    Block onUpdateMenuItems(ProfilePage profilePage) {
        this.updatedProfilePage = profilePage;
        // Added script for updating menu items badges because of push
notification
        ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
            public void run(JavaScriptSupport jss) {
                jss.addInitializerCall("removeElementById", "menuItemsDiv");
            }
        });
        return blockGroupNotificationNumber;
    }


    public String getChannelMenuItems() {
        return cataloge.format("push.channel.menu_items", user.getId());
    }

Let me know what else would you need from the info...

Thanks

On Sun, Sep 14, 2014 at 8:47 PM, Lance Java <la...@googlemail.com>
wrote:

> Ok, that's a bit of a bombshell you've just dropped there. For those
> playing along at home it seems that you're using tapestry-cometd. Care to
> share how you're using it?
>  On 13 Sep 2014 14:49, "Boris Horvat" <ho...@gmail.com> wrote:
>
> > Ok, so I was able to isolate the problem, but still not sure how to fix
> it
> > :)
> >
> > The form submission creates a new object (a new Shot) and as part of that
> > logic I also brodcast a message. Basically a signal to notify the header
> to
> > refresh a part of itself in order to show an increases in size (think of
> it
> > as a counter). The code is simple
> >
> >     @Inject
> >     private PushManager pushManager;
> >
> >     pushManager.broadcast(catalogue.format("push.channel.menu_items",
> > studioAccountUser.getId()), MenuProfile.ProfilePage.SOCIAL);
> >
> > Lance any ideas why would this cause the issue?
> >
> > When I comment out this line I can see correct event context being passed
> > around
> >
> >
> >    - values = {java.lang.*String*[1]@10926}
> >    - [0] = {java.lang.String@10940}"4"
> >
> > with the line active I see
> >
> >
> >    - values = {java.lang.*Object*[1]@10926}
> >    - [0] = {java.lang.String@10940}"4"
> >
> > Thanks
> >
> > On Sat, Sep 13, 2014 at 3:24 PM, Boris Horvat <ho...@gmail.com>
> > wrote:
> >
> > > From what I can see the fact that context becomes and array of Objects
> in
> > > the end causes the issue, anyone seen something like this before?
> > >
> > > On Sat, Sep 13, 2014 at 3:20 PM, Boris Horvat <
> horvat.z.boris@gmail.com>
> > > wrote:
> > >
> > >> Hi Lance,
> > >>
> > >> yea it finds the encoder. As previously mentioned the first time I hit
> > >> the url I can see that data is properly set, but after I submit the
> form
> > >> this is broken.
> > >>
> > >> Thiago, by "doesn't" work, I mean the same thing as before. The same
> > >> error.
> > >>
> > >>
> > >>    - org.apache.tapestry5.runtime.ComponentEventException
> > >>    Could not find a coercion from type java.lang.String to type
> > >>    com.thefloorabove.kove.blackbox.domain.project.shot.Scene.
> > >>    context
> > >>       - 4
> > >>    eventTypeactivate
> > >>
> > >> The events happen as this. I first hit the url
> > >> http://localhost:8080/shots/3 all 3 selectedObjects are set (the
> first
> > >> one selectedScene is set based on the context, the other 2 default to
> > some
> > >> object value), then I submit the form and I can see that onActivate is
> > >> properly triggered as the conetxt now contains all 3 objects
> > >>
> > >>
> > >>    - values = {java.lang.String[3]@10890}
> > >>    - [0] = {java.lang.String@10908}"4"
> > >>    - [1] = {java.lang.String@10909}"19"
> > >>    - [2] = {java.lang.String@10910}"88"
> > >>
> > >>
> > >> Following this is the form success event, and then again onActivate
> > event
> > >> is triggered but this time with wrong context
> > >>
> > >>
> > >>    - values = {java.lang.Object[1]@10926}
> > >>    - [0] = {java.lang.String@10940}"4"
> > >>
> > >>  And there we triggered the exception that is shown above
> > >>
> > >> Thanks for all of the help you guys try as I am really confused by
> this
> > >> now :)
> > >>
> > >> On Fri, Sep 12, 2014 at 3:24 PM, Lance Java <
> lance.java@googlemail.com>
> > >> wrote:
> > >>
> > >>> tapestry-hibernate will only create ValueEncoder's for entities that
> > are
> > >>> in
> > >>> the "basepackage.entities" package (configurable). What packages are
> > your
> > >>> entities in?
> > >>>
> > >>> Try @Inject ValueEncoderSource and call getValueEncoder(Scene.class)
> > >>>
> > >>> Does it find a ValueEncoder?
> > >>>
> > >>
> > >>
> > >>
> > >> --
> > >> Sincerely
> > >> *Boris Horvat*
> > >>
> > >
> > >
> > >
> > > --
> > > Sincerely
> > > *Boris Horvat*
> > >
> >
> >
> >
> > --
> > Sincerely
> > *Boris Horvat*
> >
>



-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Lance Java <la...@googlemail.com>.
Ok, that's a bit of a bombshell you've just dropped there. For those
playing along at home it seems that you're using tapestry-cometd. Care to
share how you're using it?
 On 13 Sep 2014 14:49, "Boris Horvat" <ho...@gmail.com> wrote:

> Ok, so I was able to isolate the problem, but still not sure how to fix it
> :)
>
> The form submission creates a new object (a new Shot) and as part of that
> logic I also brodcast a message. Basically a signal to notify the header to
> refresh a part of itself in order to show an increases in size (think of it
> as a counter). The code is simple
>
>     @Inject
>     private PushManager pushManager;
>
>     pushManager.broadcast(catalogue.format("push.channel.menu_items",
> studioAccountUser.getId()), MenuProfile.ProfilePage.SOCIAL);
>
> Lance any ideas why would this cause the issue?
>
> When I comment out this line I can see correct event context being passed
> around
>
>
>    - values = {java.lang.*String*[1]@10926}
>    - [0] = {java.lang.String@10940}"4"
>
> with the line active I see
>
>
>    - values = {java.lang.*Object*[1]@10926}
>    - [0] = {java.lang.String@10940}"4"
>
> Thanks
>
> On Sat, Sep 13, 2014 at 3:24 PM, Boris Horvat <ho...@gmail.com>
> wrote:
>
> > From what I can see the fact that context becomes and array of Objects in
> > the end causes the issue, anyone seen something like this before?
> >
> > On Sat, Sep 13, 2014 at 3:20 PM, Boris Horvat <ho...@gmail.com>
> > wrote:
> >
> >> Hi Lance,
> >>
> >> yea it finds the encoder. As previously mentioned the first time I hit
> >> the url I can see that data is properly set, but after I submit the form
> >> this is broken.
> >>
> >> Thiago, by "doesn't" work, I mean the same thing as before. The same
> >> error.
> >>
> >>
> >>    - org.apache.tapestry5.runtime.ComponentEventException
> >>    Could not find a coercion from type java.lang.String to type
> >>    com.thefloorabove.kove.blackbox.domain.project.shot.Scene.
> >>    context
> >>       - 4
> >>    eventTypeactivate
> >>
> >> The events happen as this. I first hit the url
> >> http://localhost:8080/shots/3 all 3 selectedObjects are set (the first
> >> one selectedScene is set based on the context, the other 2 default to
> some
> >> object value), then I submit the form and I can see that onActivate is
> >> properly triggered as the conetxt now contains all 3 objects
> >>
> >>
> >>    - values = {java.lang.String[3]@10890}
> >>    - [0] = {java.lang.String@10908}"4"
> >>    - [1] = {java.lang.String@10909}"19"
> >>    - [2] = {java.lang.String@10910}"88"
> >>
> >>
> >> Following this is the form success event, and then again onActivate
> event
> >> is triggered but this time with wrong context
> >>
> >>
> >>    - values = {java.lang.Object[1]@10926}
> >>    - [0] = {java.lang.String@10940}"4"
> >>
> >>  And there we triggered the exception that is shown above
> >>
> >> Thanks for all of the help you guys try as I am really confused by this
> >> now :)
> >>
> >> On Fri, Sep 12, 2014 at 3:24 PM, Lance Java <la...@googlemail.com>
> >> wrote:
> >>
> >>> tapestry-hibernate will only create ValueEncoder's for entities that
> are
> >>> in
> >>> the "basepackage.entities" package (configurable). What packages are
> your
> >>> entities in?
> >>>
> >>> Try @Inject ValueEncoderSource and call getValueEncoder(Scene.class)
> >>>
> >>> Does it find a ValueEncoder?
> >>>
> >>
> >>
> >>
> >> --
> >> Sincerely
> >> *Boris Horvat*
> >>
> >
> >
> >
> > --
> > Sincerely
> > *Boris Horvat*
> >
>
>
>
> --
> Sincerely
> *Boris Horvat*
>

Re: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
Ok, so I was able to isolate the problem, but still not sure how to fix it
:)

The form submission creates a new object (a new Shot) and as part of that
logic I also brodcast a message. Basically a signal to notify the header to
refresh a part of itself in order to show an increases in size (think of it
as a counter). The code is simple

    @Inject
    private PushManager pushManager;

    pushManager.broadcast(catalogue.format("push.channel.menu_items",
studioAccountUser.getId()), MenuProfile.ProfilePage.SOCIAL);

Lance any ideas why would this cause the issue?

When I comment out this line I can see correct event context being passed
around


   - values = {java.lang.*String*[1]@10926}
   - [0] = {java.lang.String@10940}"4"

with the line active I see


   - values = {java.lang.*Object*[1]@10926}
   - [0] = {java.lang.String@10940}"4"

Thanks

On Sat, Sep 13, 2014 at 3:24 PM, Boris Horvat <ho...@gmail.com>
wrote:

> From what I can see the fact that context becomes and array of Objects in
> the end causes the issue, anyone seen something like this before?
>
> On Sat, Sep 13, 2014 at 3:20 PM, Boris Horvat <ho...@gmail.com>
> wrote:
>
>> Hi Lance,
>>
>> yea it finds the encoder. As previously mentioned the first time I hit
>> the url I can see that data is properly set, but after I submit the form
>> this is broken.
>>
>> Thiago, by "doesn't" work, I mean the same thing as before. The same
>> error.
>>
>>
>>    - org.apache.tapestry5.runtime.ComponentEventException
>>    Could not find a coercion from type java.lang.String to type
>>    com.thefloorabove.kove.blackbox.domain.project.shot.Scene.
>>    context
>>       - 4
>>    eventTypeactivate
>>
>> The events happen as this. I first hit the url
>> http://localhost:8080/shots/3 all 3 selectedObjects are set (the first
>> one selectedScene is set based on the context, the other 2 default to some
>> object value), then I submit the form and I can see that onActivate is
>> properly triggered as the conetxt now contains all 3 objects
>>
>>
>>    - values = {java.lang.String[3]@10890}
>>    - [0] = {java.lang.String@10908}"4"
>>    - [1] = {java.lang.String@10909}"19"
>>    - [2] = {java.lang.String@10910}"88"
>>
>>
>> Following this is the form success event, and then again onActivate event
>> is triggered but this time with wrong context
>>
>>
>>    - values = {java.lang.Object[1]@10926}
>>    - [0] = {java.lang.String@10940}"4"
>>
>>  And there we triggered the exception that is shown above
>>
>> Thanks for all of the help you guys try as I am really confused by this
>> now :)
>>
>> On Fri, Sep 12, 2014 at 3:24 PM, Lance Java <la...@googlemail.com>
>> wrote:
>>
>>> tapestry-hibernate will only create ValueEncoder's for entities that are
>>> in
>>> the "basepackage.entities" package (configurable). What packages are your
>>> entities in?
>>>
>>> Try @Inject ValueEncoderSource and call getValueEncoder(Scene.class)
>>>
>>> Does it find a ValueEncoder?
>>>
>>
>>
>>
>> --
>> Sincerely
>> *Boris Horvat*
>>
>
>
>
> --
> Sincerely
> *Boris Horvat*
>



-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
>From what I can see the fact that context becomes and array of Objects in
the end causes the issue, anyone seen something like this before?

On Sat, Sep 13, 2014 at 3:20 PM, Boris Horvat <ho...@gmail.com>
wrote:

> Hi Lance,
>
> yea it finds the encoder. As previously mentioned the first time I hit the
> url I can see that data is properly set, but after I submit the form this
> is broken.
>
> Thiago, by "doesn't" work, I mean the same thing as before. The same error.
>
>
>    - org.apache.tapestry5.runtime.ComponentEventException
>    Could not find a coercion from type java.lang.String to type
>    com.thefloorabove.kove.blackbox.domain.project.shot.Scene.
>    context
>       - 4
>    eventTypeactivate
>
> The events happen as this. I first hit the url
> http://localhost:8080/shots/3 all 3 selectedObjects are set (the first
> one selectedScene is set based on the context, the other 2 default to some
> object value), then I submit the form and I can see that onActivate is
> properly triggered as the conetxt now contains all 3 objects
>
>
>    - values = {java.lang.String[3]@10890}
>    - [0] = {java.lang.String@10908}"4"
>    - [1] = {java.lang.String@10909}"19"
>    - [2] = {java.lang.String@10910}"88"
>
>
> Following this is the form success event, and then again onActivate event
> is triggered but this time with wrong context
>
>
>    - values = {java.lang.Object[1]@10926}
>    - [0] = {java.lang.String@10940}"4"
>
>  And there we triggered the exception that is shown above
>
> Thanks for all of the help you guys try as I am really confused by this
> now :)
>
> On Fri, Sep 12, 2014 at 3:24 PM, Lance Java <la...@googlemail.com>
> wrote:
>
>> tapestry-hibernate will only create ValueEncoder's for entities that are
>> in
>> the "basepackage.entities" package (configurable). What packages are your
>> entities in?
>>
>> Try @Inject ValueEncoderSource and call getValueEncoder(Scene.class)
>>
>> Does it find a ValueEncoder?
>>
>
>
>
> --
> Sincerely
> *Boris Horvat*
>



-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
Hi Lance,

yea it finds the encoder. As previously mentioned the first time I hit the
url I can see that data is properly set, but after I submit the form this
is broken.

Thiago, by "doesn't" work, I mean the same thing as before. The same error.


   - org.apache.tapestry5.runtime.ComponentEventException
   Could not find a coercion from type java.lang.String to type
   com.thefloorabove.kove.blackbox.domain.project.shot.Scene.
   context
      - 4
   eventTypeactivate

The events happen as this. I first hit the url http://localhost:8080/shots/3
all 3 selectedObjects are set (the first one selectedScene is set based on
the context, the other 2 default to some object value), then I submit the
form and I can see that onActivate is properly triggered as the conetxt now
contains all 3 objects


   - values = {java.lang.String[3]@10890}
   - [0] = {java.lang.String@10908}"4"
   - [1] = {java.lang.String@10909}"19"
   - [2] = {java.lang.String@10910}"88"


Following this is the form success event, and then again onActivate event
is triggered but this time with wrong context


   - values = {java.lang.Object[1]@10926}
   - [0] = {java.lang.String@10940}"4"

 And there we triggered the exception that is shown above

Thanks for all of the help you guys try as I am really confused by this now
:)

On Fri, Sep 12, 2014 at 3:24 PM, Lance Java <la...@googlemail.com>
wrote:

> tapestry-hibernate will only create ValueEncoder's for entities that are in
> the "basepackage.entities" package (configurable). What packages are your
> entities in?
>
> Try @Inject ValueEncoderSource and call getValueEncoder(Scene.class)
>
> Does it find a ValueEncoder?
>



-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Lance Java <la...@googlemail.com>.
tapestry-hibernate will only create ValueEncoder's for entities that are in
the "basepackage.entities" package (configurable). What packages are your
entities in?

Try @Inject ValueEncoderSource and call getValueEncoder(Scene.class)

Does it find a ValueEncoder?

Re: Tapestry onActivate messes up after submitting a form

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 12 Sep 2014 03:44:00 -0300, Boris Horvat  
<ho...@gmail.com> wrote:

> I suppose I could accept String in the context and then manually load the
> object...but that just sounds wrong as tapestry should be able to handle
> this, right?

Yes if you have a configured ValueEncoder for each of the Scene, Shot and  
ShotComponent classes. tapestry-hibernate-provided ValueEncoder apply  
here. You still didn't describe what you mean for "doesn't work". Just one  
context value is received? What's the URL after the form submission or  
event?

-- 
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: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
Nope, still the same issue

    public void onActivate(EventContext eventContext) {
        selectedScene = eventContext.getCount() > 0 ?
eventContext.get(Scene.class, 0) : null;
        selectedShot = eventContext.getCount() > 1 ?
eventContext.get(Shot.class, 1) : null;
        selectedComponent = eventContext.getCount() > 2 ?
eventContext.get(ShotComponent.class, 2) : null;
    }

    public void onPrepare() {
        if (!selectedScene.getProject().equals(user.getSelectedProject())) {
            user.setSelectedProject(selectedScene.getProject());
        }

        shotComponents = systemManager.getComponents(selectedShot, filter);
        CollectionUtils.sortComponents(shotComponents);
    }

    public Object[] onPassivate() {
        return new Object[]{selectedScene, selectedShot, selectedComponent};
    }


I suppose I could accept String in the context and then manually load the
object...but that just sounds wrong as tapestry should be able to handle
this, right?

On Thu, Sep 11, 2014 at 9:25 AM, Lance Java <la...@googlemail.com>
wrote:

> Try again:
>
> public void onActivate(EventContext eventContext) {
>    selectedScene = eventContext.getCount() > 0 ?
> eventContext.get(Scene.class, 0) : null;
>    selectedShot = eventContext.getCount() > 1 ?
> eventContext.get(Shot.class, 1) : null;
>    selectedComponent = eventContext.getCount() > 2 ?
> eventContext.get(ShotComponent.class, 2) : null;
> }
>
> public void onPrepare() {
>    if (!scene.getProject().equals(user.getSelectedProject())) {
>       user.setSelectedProject(scene.getProject());
>    }
>
>    shotComponents = systemManager.getComponents(selectedShot, filter);
>    CollectionUtils.sortComponents(shotComponents);
> }
>



-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Lance Java <la...@googlemail.com>.
Try again:

public void onActivate(EventContext eventContext) {
   selectedScene = eventContext.getCount() > 0 ?
eventContext.get(Scene.class, 0) : null;
   selectedShot = eventContext.getCount() > 1 ?
eventContext.get(Shot.class, 1) : null;
   selectedComponent = eventContext.getCount() > 2 ?
eventContext.get(ShotComponent.class, 2) : null;
}

public void onPrepare() {
   if (!scene.getProject().equals(user.getSelectedProject())) {
      user.setSelectedProject(scene.getProject());
   }

   shotComponents = systemManager.getComponents(selectedShot, filter);
   CollectionUtils.sortComponents(shotComponents);
}

Re: Tapestry onActivate messes up after submitting a form

Posted by Lance Java <la...@googlemail.com>.
Perhaps you're doing too much in onActivate(), it's called more often than
you might think. Perhaps you should split the initialization logic into
onPrepare() more info here
http://jumpstart.doublenegative.com.au/jumpstart/examples/navigation/onactivateandonpassivate/3

eg:

public void onActivate(EventContext eventContext) {
selectedScene = eventContext.getCount() > 0 ?
activate(eventContext.get(Scene.class, 0) : null;
selectedShot = eventContext.getCount() > 1 ?
activate(eventContext.get(Shot.class, 1) : null;
selectedComponent = eventContext.getCount() > 2 ?
eventContext.get(ShotComponent.class, 2) : null;
}

public void onPrepare() {
if (!scene.getProject().equals(user.getSelectedProject())) {
user.setSelectedProject(scene.getProject());
}

shotComponents = systemManager.getComponents(selectedShot, filter);
CollectionUtils.sortComponents(shotComponents);
}

Re: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
I know :) as I wrote in the previous mail I have tried both ways, but still
not working

On Wed, Sep 10, 2014 at 9:09 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Wed, 10 Sep 2014 15:40:25 -0300, Boris Horvat <ho...@gmail.com>
> wrote:
>
>  public String[] onPassivate() {
>>
>>         String[] a = new String[3];
>>         a[0] = selectedScene != null ? selectedScene.getId().toString() :
>> null;
>>         a[1] = selectedShot != null ? selectedShot.getId().toString() :
>> null;
>>         a[2] = selectedComponent != null ?
>> selectedComponent.getId().toString() : null;
>>         return a;
>>     }
>>
>
> I said Object[], not String[]. ;)
>
> public Object[] onPassivate() {
>         return new Object[] {selectedScene, selectedShot,
> selectedComponent}
>
> }
>
> --
> 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
>
>


-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 10 Sep 2014 15:40:25 -0300, Boris Horvat  
<ho...@gmail.com> wrote:

> public String[] onPassivate() {
>
>         String[] a = new String[3];
>         a[0] = selectedScene != null ? selectedScene.getId().toString() :
> null;
>         a[1] = selectedShot != null ? selectedShot.getId().toString() :
> null;
>         a[2] = selectedComponent != null ?
> selectedComponent.getId().toString() : null;
>         return a;
>     }

I said Object[], not String[]. ;)

public Object[] onPassivate() {
	return new Object[] {selectedScene, selectedShot, selectedComponent}
}

-- 
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: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
Sadly still the same when I tried.

 public Object[] onPassivate() {

        List a = new ArrayList();
        a.add(selectedScene);
        a.add(selectedShot);
        a.add(selectedComponent);
        return a.toArray();
    }

Also I tried

public String[] onPassivate() {

        String[] a = new String[3];
        a[0] = selectedScene != null ? selectedScene.getId().toString() :
null;
        a[1] = selectedShot != null ? selectedShot.getId().toString() :
null;
        a[2] = selectedComponent != null ?
selectedComponent.getId().toString() : null;
        return a;
    }

in order to force array of Strings but I can still see onActivate after
form success


   - values = {java.lang.*Object*[1]@13228}
   - [0] = {java.lang.String@13237}"2"

and this breaks, but when I first go to the page and instead of array of
Objects I have String it works properly

On Wed, Sep 10, 2014 at 7:37 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Wed, 10 Sep 2014 14:14:01 -0300, Boris Horvat <ho...@gmail.com>
> wrote:
>
>      public List onPassivate() {
>>
>>         List a = new ArrayList();
>>         a.add(selectedScene);
>>         a.add(selectedShot);
>>         a.add(selectedComponent);
>>         return a;
>>     }
>>
>
> onPassivate() doesn't work returning a List. Return an Object[] instead
> and it'll work.
>
>
> --
> 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
>
>


-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 10 Sep 2014 14:14:01 -0300, Boris Horvat  
<ho...@gmail.com> wrote:

>     public List onPassivate() {
>
>         List a = new ArrayList();
>         a.add(selectedScene);
>         a.add(selectedShot);
>         a.add(selectedComponent);
>         return a;
>     }

onPassivate() doesn't work returning a List. Return an Object[] instead  
and it'll work.

-- 
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: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
I have tried with EventContext


    public void onActivate(EventContext eventContext) {
        if (eventContext.getCount() == 3) {
            activate(eventContext.get(Scene.class, 0),
eventContext.get(Shot.class, 1), eventContext.get(ShotComponent.class, 2));
        } else if (eventContext.getCount() == 2) {
            activate(eventContext.get(Scene.class, 0),
eventContext.get(Shot.class, 1), null);
        } else if (eventContext.getCount() == 1) {
            activate(eventContext.get(Scene.class, 0), null, null);
        }
    }

    public void activate(Scene scene, Shot shot, ShotComponent component) {
        selectedScene = scene;
        selectedShot = shot;
        selectedComponent = component;

        if (!scene.getProject().equals(user.getSelectedProject())) {
            user.setSelectedProject(scene.getProject());
        }

        shotComponents = systemManager.getComponents(selectedShot, filter);
        CollectionUtils.sortComponents(shotComponents);
    }

    public List onPassivate() {

        List a = new ArrayList();
        a.add(selectedScene);
        a.add(selectedShot);
        a.add(selectedComponent);
        return a;
    }

And this is what I could see. When I first go to the url
http://localhost:8080/shots/2 I can see that onActivate method is called
and in the EventContext object we have


   - values = {java.lang.String[1]@13004}
   - [0] = {java.lang.String@13007}"2"

This is all good, and my objects are properly initialized. By this I mean
that we select Scene with id 2 (field selectedScene) and others default to
some objects, but by end we also have selectedShot and selectedComponent).
After this method we go into the onPassivate few dozen times as well.

Then I trigger the form submission and at first it looks ok. onActivate is
triggered and I can see proper data in context object

   - values = {java.lang.*String*[3]@13101}
   - [0] = {java.lang.String@13102}"2"
   - [1] = {java.lang.String@13103}"19"
   - [2] = {java.lang.String@13104}"87"

After this method onSuccess from the form submission is triggered and new
element is created (this new element will now be called selectedShot that
is present in passivate method) and then onActivate method is triggered
again


   - values = {java.lang.*Object*[1]@13228}
   - [0] = {java.lang.String@13237}"2"

with wrong context. I would assume that this array of Objects somehow
confuses the coercer and it fails to get proper element from the DB.

Any new ideas and thanks for help :)


On Wed, Sep 10, 2014 at 11:16 AM, Chris Poulsen <ma...@nesluop.dk>
wrote:

> I think I've seen messages on the mailing lists about problems related to
> multiple onActivate's a long time ago.
>
> https://issues.apache.org/jira/browse/TAPESTRY-1730 seems to suggest that
> the method with the most parameters is called first, but whether the
> execution stops here or continues to the next onActivate I don't know...
>
> In any case I would go with Lance' suggestion and stick with a single
> onActivate; in that case it is clear what the method does and evaluation
> order is not an issue (if it ever was).
>
> --
> Chris
>
> On Wed, Sep 10, 2014 at 11:01 AM, Lance Java <la...@googlemail.com>
> wrote:
>
> > No, this is a new feature.
> >
> > Your onActivate methods are very complex. Have you considered a single
> > onActivate(EventContext)?
> >
> > Perhaps the '-' in '-3' is just a presentation issue.
> >
> > I think the main culprit is likely to be your onPassivate(). Does it
> return
> > all 3 objects (when populated).
> >
>



-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Chris Poulsen <ma...@nesluop.dk>.
I think I've seen messages on the mailing lists about problems related to
multiple onActivate's a long time ago.

https://issues.apache.org/jira/browse/TAPESTRY-1730 seems to suggest that
the method with the most parameters is called first, but whether the
execution stops here or continues to the next onActivate I don't know...

In any case I would go with Lance' suggestion and stick with a single
onActivate; in that case it is clear what the method does and evaluation
order is not an issue (if it ever was).

-- 
Chris

On Wed, Sep 10, 2014 at 11:01 AM, Lance Java <la...@googlemail.com>
wrote:

> No, this is a new feature.
>
> Your onActivate methods are very complex. Have you considered a single
> onActivate(EventContext)?
>
> Perhaps the '-' in '-3' is just a presentation issue.
>
> I think the main culprit is likely to be your onPassivate(). Does it return
> all 3 objects (when populated).
>

Re: Tapestry onActivate messes up after submitting a form

Posted by Lance Java <la...@googlemail.com>.
No, this is a new feature.

Your onActivate methods are very complex. Have you considered a single
onActivate(EventContext)?

Perhaps the '-' in '-3' is just a presentation issue.

I think the main culprit is likely to be your onPassivate(). Does it return
all 3 objects (when populated).

Re: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
Yea -3 is not propet db id, but what could have changed it into negative
number...strange

Is this partbof the 5.3.7 or 5.4 as I am still on the old offucial version.
I can try it out tonight and see what happen

Thanks
On 10 Sep 2014 09:16, "Lance Java" <la...@googlemail.com> wrote:

> >  Exception in method null, parameter #1: Could not find a coercion from
> type java.lang.String to type Scene. context - 3
>
> It looks like the context is -3? Is this primary key in the database?
>
> > Also annotation wont, really work for me as I have more then one field
>
> You might be interested in this new feature
> https://issues.apache.org/jira/browse/TAP5-2138
>

Re: Tapestry onActivate messes up after submitting a form

Posted by Lance Java <la...@googlemail.com>.
>  Exception in method null, parameter #1: Could not find a coercion from
type java.lang.String to type Scene. context - 3

It looks like the context is -3? Is this primary key in the database?

> Also annotation wont, really work for me as I have more then one field

You might be interested in this new feature
https://issues.apache.org/jira/browse/TAP5-2138

Re: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
Using the annotation triggers slightly different exception.

   - org.apache.tapestry5.runtime.ComponentEventException
   Exception in method null, parameter #1: Could not find a coercion from
   type java.lang.String to type Scene.
   context
      - 3
   eventTypeactivate


Also annotation wont, really work for me as I have more then one field

    public void onActivate(Scene scene, Shot shot, ShotComponent component,
ShotDataSection section) {
        selectedScene = scene;
        selectedShot = shot;
        selectedComponent = component;
        selectedSection = section;

        if (!scene.getProject().equals(user.getSelectedProject())) {
            user.setSelectedProject(scene.getProject());
        }

        shotComponents = systemManager.getComponents(selectedShot, filter);
        CollectionUtils.sortComponents(shotComponents);
    }

    public void onActivate(Scene scene, Shot shot, ShotComponent component)
{
        onActivate(scene, shot, component, null);
    }

    public void onActivate(Scene scene, Shot shot) {
        onActivate(scene, shot, null);
    }

    public void onActivate(Scene scene) {
        onActivate(scene, null);
    }

And all of those select* fields are marked with

    @Property
    @Persist

So the question still remains, how come that tapestry fails to pick up that
context is a number and then it fails to user hibernate ValueEncoder.

Thanks for the help guys

On Tue, Sep 9, 2014 at 8:38 PM, Boris Horvat <ho...@gmail.com>
 wrote:

> It is a hibernate entity so yea it gets a ValueEncoder from hibernate. As
> mentioned when I first navigate to the page, it works fine, but after form
> submit it breaks...
>
> I will remove return type and try annotation and see if that helps
>
> On Tue, Sep 9, 2014 at 2:33 PM, Thiago H de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
>
>> On Tue, 09 Sep 2014 04:10:22 -0300, Boris Horvat <
>> horvat.z.boris@gmail.com> wrote:
>>
>> Hi my methods look like this
>>>
>>>     public boolean onActivate(Scene scene) {
>>>         selectedScene =
>>> scene;//systemManager.getScene(Long.parseLong(scene.toString()));
>>>         return selectedScene != null;
>>>     }
>>>
>>>     public Scene onPassivate() {
>>>         return selectedScene;
>>>     }
>>>
>>> I don't have ValueEncoder cause I would expect that conversion works
>>> String
>>> -> Long -> hibernate gets the id of the object and returns -> MyObject
>>> (i.e. Scene in this case).
>>>
>>
>> I don't think your assumption is correct. For onActivate(Scene) to work,
>> you need a ValueEncoder for Scene or at least String to Scene coercion.
>> Same for onActivate(). As Lance said, if you're using tapestry-hibernate
>> and Scene is a Hibernate entity, Scene already has a ValueEncoder
>> automatically contributed.
>>
>> As Lance said, you should never return boolean in onActivate(). It's not
>> a component render phase event handler.
>>
>> I can add one but I would not expect that I needed it, especially since
>>> when I first navigate to the page it works without a problem, but when I
>>> submit a form it breaks
>>> org.apache.tapestry5.ioc.util.UnknownValueException
>>> Could not find a coercion from type java.lang.String to type
>>> domain.Scene.
>>>
>>
>> This matches what I said above.
>>
>>
>> --
>> 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
>>
>>
>
>
> --
> Sincerely
> *Boris Horvat*
>



-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
It is a hibernate entity so yea it gets a ValueEncoder from hibernate. As
mentioned when I first navigate to the page, it works fine, but after form
submit it breaks...

I will remove return type and try annotation and see if that helps

On Tue, Sep 9, 2014 at 2:33 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Tue, 09 Sep 2014 04:10:22 -0300, Boris Horvat <ho...@gmail.com>
> wrote:
>
>  Hi my methods look like this
>>
>>     public boolean onActivate(Scene scene) {
>>         selectedScene =
>> scene;//systemManager.getScene(Long.parseLong(scene.toString()));
>>         return selectedScene != null;
>>     }
>>
>>     public Scene onPassivate() {
>>         return selectedScene;
>>     }
>>
>> I don't have ValueEncoder cause I would expect that conversion works
>> String
>> -> Long -> hibernate gets the id of the object and returns -> MyObject
>> (i.e. Scene in this case).
>>
>
> I don't think your assumption is correct. For onActivate(Scene) to work,
> you need a ValueEncoder for Scene or at least String to Scene coercion.
> Same for onActivate(). As Lance said, if you're using tapestry-hibernate
> and Scene is a Hibernate entity, Scene already has a ValueEncoder
> automatically contributed.
>
> As Lance said, you should never return boolean in onActivate(). It's not a
> component render phase event handler.
>
>  I can add one but I would not expect that I needed it, especially since
>> when I first navigate to the page it works without a problem, but when I
>> submit a form it breaks
>> org.apache.tapestry5.ioc.util.UnknownValueException
>> Could not find a coercion from type java.lang.String to type domain.Scene.
>>
>
> This matches what I said above.
>
>
> --
> 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
>
>


-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 09 Sep 2014 04:10:22 -0300, Boris Horvat  
<ho...@gmail.com> wrote:

> Hi my methods look like this
>
>     public boolean onActivate(Scene scene) {
>         selectedScene =
> scene;//systemManager.getScene(Long.parseLong(scene.toString()));
>         return selectedScene != null;
>     }
>
>     public Scene onPassivate() {
>         return selectedScene;
>     }
>
> I don't have ValueEncoder cause I would expect that conversion works  
> String
> -> Long -> hibernate gets the id of the object and returns -> MyObject
> (i.e. Scene in this case).

I don't think your assumption is correct. For onActivate(Scene) to work,  
you need a ValueEncoder for Scene or at least String to Scene coercion.  
Same for onActivate(). As Lance said, if you're using tapestry-hibernate  
and Scene is a Hibernate entity, Scene already has a ValueEncoder  
automatically contributed.

As Lance said, you should never return boolean in onActivate(). It's not a  
component render phase event handler.

> I can add one but I would not expect that I needed it, especially since
> when I first navigate to the page it works without a problem, but when I
> submit a form it breaks
> org.apache.tapestry5.ioc.util.UnknownValueException
> Could not find a coercion from type java.lang.String to type  
> domain.Scene.

This matches what I said above.

-- 
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: Tapestry onActivate messes up after submitting a form

Posted by Boris Horvat <ho...@gmail.com>.
Hi my methods look like this

    public boolean onActivate(Scene scene) {
        selectedScene =
scene;//systemManager.getScene(Long.parseLong(scene.toString()));
        return selectedScene != null;
    }

    public Scene onPassivate() {
        return selectedScene;
    }

I don't have ValueEncoder cause I would expect that conversion works String
-> Long -> hibernate gets the id of the object and returns -> MyObject
(i.e. Scene in this case).
I can add one but I would not expect that I needed it, especially since
when I first navigate to the page it works without a problem, but when I
submit a form it breaks
org.apache.tapestry5.ioc.util.UnknownValueException
Could not find a coercion from type java.lang.String to type domain.Scene.

If I replace Scene with String or Object and use that to manually query the
db everything works as expected (even without onPassivate method - the only
thing is that my url changes and it losses the context but onActivate is
still triggered)

Thanks

On Tue, Sep 9, 2014 at 12:36 AM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Mon, 08 Sep 2014 18:21:42 -0300, Boris Horvat <ho...@gmail.com>
> wrote:
>
>  Hi all,
>>
>
> Hi!
>
>
>  I have an onActivate(MyObject) method, when I go to the page for the
>> first time and context is present everything is triggered properly. The url
>> is
>> something like
>>
>> localhost:8080/mypage/1
>>
>> However when I submit my form, and process it, page reloads and my id is
>> now treated as a String that fails to be converted into object. Is this
>> behaviour expected? Do I need to add something special into the form to
>> keep context properly passed?
>>
>
> Have you contributed a ValueEncoder for MyObject? What's the page's
> onPassivate() method? Or are you using @PageActivationContext?
>
> --
> 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
>
>


-- 
Sincerely
*Boris Horvat*

Re: Tapestry onActivate messes up after submitting a form

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 08 Sep 2014 18:21:42 -0300, Boris Horvat  
<ho...@gmail.com> wrote:

> Hi all,

Hi!

> I have an onActivate(MyObject) method, when I go to the page for the  
> first time and context is present everything is triggered properly. The  
> url is
> something like
>
> localhost:8080/mypage/1
>
> However when I submit my form, and process it, page reloads and my id is
> now treated as a String that fails to be converted into object. Is this
> behaviour expected? Do I need to add something special into the form to
> keep context properly passed?

Have you contributed a ValueEncoder for MyObject? What's the page's  
onPassivate() method? Or are you using @PageActivationContext?

-- 
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