[
https://issues.apache.org/jira/browse/TAPESTRY-1805?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12557242#action_12557242
]
Kristian Marinkovic commented on TAPESTRY-1805:
-----------------------------------------------
my use case: i use (or at least i'd like to:)) mixins is for enable/disable
handling and user rights handling within forms
therefore i have a Editable Mixin that has a boolean parameter that shortcuts
the rendering of a field and only renders/displays the value of the field (btw.
because i can not determine the value of the components value parameter i have
to pass the value to the Editable Mixin as well). furthermore i have a
RoleWarrant Mixin that prevents rendering of page parts the users roles are not
sufficient. both Mixins essentially shortcut the rendering of the components
they are applied to. sometimes they both are applied to the same component
so i shortcut the rendering in Mixin.setupRender because i want to prevent the
rendering. but shortcutting setupRender does not prevent calling
Component.cleanupRender although expected (at least by me). because
Component.setupRender has not been called and therefore has not been able to
initialize its state, exceptions can occur if Component.cleanupRender relies on
the state set in Component.setupRender.
for example this happens if you try to shortcut a Form component because during
the cleanup event it tries to remove a service from the environment it should
have set in the beginRender event. this is a very unsatisfying situation if
many components from different sources are used.
i hope this example helps
> Reverse ordering/exceution of page render phase methods (afterXXX and
> cleanupRender) incorrect when short-circuiting
> --------------------------------------------------------------------------------------------------------------------
>
> Key: TAPESTRY-1805
> URL: https://issues.apache.org/jira/browse/TAPESTRY-1805
> Project: Tapestry
> Issue Type: Bug
> Components: tapestry-core
> Affects Versions: 5.0.6
> Environment: Tapestry 5.0.6-SNAPSHOT
> Reporter: Kristian Marinkovic
> Assignee: Howard M. Lewis Ship
> Priority: Critical
>
> ComponentPageElementImpl is responsible for calling the render
> phase methods of the components. It calls the setupRender method
> on the attached Mixins then the components and then the Mixins that
> have a @MixinAfter annotation. If in this phase the setupRender of a
> Mixin returns a boolean value that will be saved into the Event object and
> in case of a "false" the setupRender calls of the subsequent components
> will be aborted.
> During the "inverse" lifecycle the order is simply reversed and the render
> phase method of the Mixin with @MixinAfter annotation is called, then
> the render phase method of the component and then the method of the
> Mixin is called. The problem is now that the "inverse" render phase
> methods are getting called without checking whether the corresponding
> other render phase methods have been executed.
> So in my case the cleanupRender method of the Form component gets
> called although i have short-circuited the beginRender method with my
> Mixin because there is no state available that indicates that the beginRender
> method of the Form component has NOT been executed.
> private void invoke(boolean reverse, ComponentCallback callback)
> {
> ....
> Iterator<Component> i = reverse ?
> InternalUtils.reverseIterator(_components)
> : _components.iterator();
> while (i.hasNext())
> callback.run(i.next());
> A possible solution would be to create a List that contains those
> components whose render phase methods really have been
> executed. This list is then used in the "inverse" lifecycle.
> see also:
> http://www.nabble.com/T5%3A-Mixin-on-Form-does-not-work-as-expected-tf4562001.html
> http://www.nabble.com/T5%3A-Mixin-on-Form-does-not-work-as-expected-tf4562724.html
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]