I had a look into TAP5-1527. The issue in short: using BeanEditForm
component on a page, your handler method for the prepare event is invoked
twice during rendering.

For more details see:https://issues.apache.org/jira/browse/TAP5-1527

As you can see in the following example, BeanEditForm re-triggers Form's
prepare event without to abort the original event. The consequence is that
onPrepare() method on the page is called twice as both Form's and
BeanEditForm's events are handled.


    void onPrepareFromForm()
    {
        resources.triggerEvent(EventConstants.PREPARE, null, null);

        if (model == null)
        {
            Class beanType = resources.getBoundType("object");

            model = beanModelSource.createEditModel(beanType,
resources.getContainerMessages());

            BeanModelUtils.modify(model, add, include, exclude, reorder);
        }
    }

Honestly I'm puzzled how this ever worked before 5.2. According to how
BeanEditForm handles the prepare event, the described behavior is expected.
I don't what changed the behavior in 5.2, but now it works as expected.

In order to make onPrepare() handler to be invoked only once, we should
abort the original prepare event triggered by Form.

    boolean onPrepareFromForm()
    {
        resources.triggerEvent(EventConstants.PREPARE, null, null);

        if (model == null)
        {
            Class beanType = resources.getBoundType("object");

            model = beanModelSource.createEditModel(beanType,
resources.getContainerMessages());

            BeanModelUtils.modify(model, add, include, exclude, reorder);
        }

        return true;
    }

Am I missing something?

-- 
Best regards,

Igor Drobiazko
http://tapestry5.de

Reply via email to