We would like to implement a mixin 'IsVisible' that can be applied

to an existing component to specify whether or not the component

should be displayed. Basically, it should evaluate its parameter

and

   1) if false, it should skip all rendering phases of the component

   2) if true, it should continue rendering the component normally

 

This seems to be an ideal use for mixins, I can't seem to find a way

to get it to work that conforms to the documentation at

http://tapestry.apache.org/tapestry5/tapestry-core/guide/rendering.html.

 

The naive implementation 

public class IsVisible {

   @Parameter(required = true)

   private boolean isVisible;

                

   @SetupRender

   boolean setupRender() {

      return isVisible;

   }

}

 

Works for the most part when returning 'false', but as of Tapestry

5.0.15 returning 'true' causes the component's 'setupRender' to be

skipped. Changing the 'setupRender' signature to

 

Boolean setupRender()

 

and returning 'null' to continue instead of 'true' seemed to work,

but the documentation doesn't indicate that this is allowed, so I

wasn't sure that it is intended behavior and will be supported in

the future.

 

There is another slight problem when returning 'false', in that the

component's 'cleanupRender' will be called even when its

'setupRender' was skipped (similar problem to what was reported in

TAP5-126). This means that the 'IsVisible' cannot be applied to any

component, only those whose 'cleanupRender' was implemented in such

a way that it protects against 'setupRender' not having been called.

This is one instance of a general problem with writing mixins that

are intended to be applied to arbitrary components, in that if a

forward phase is short-circuited by a mixin, that render phase

method is not called for the component, but the corresponding reverse

phase of the component is still called.

 

Regards,

Doug

 

Reply via email to