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 <mailingl...@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 <lance.j...@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*

Reply via email to