tags:

views:

49

answers:

1

Hi. I have a component in Tapestry 4 that should render only when user has privileges to use it's attached business code. In Tapestry 5 I would probably use rendering phases and would return false on SetupRender in order to skip rendering of this component:

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

But how would I go about doing it in Tapestry 4? I could probably override renderComponent( IMarkupWriter writer, IRequestCycle cycle ) and suppress a call to super when one doesn't have rights to use this functionality. But this seems kind of hackish.

Is there a Tapestry 4 way to do that?

Thanks.

+1  A: 

I don't think there's anything like T5's rendering phases in T4, but you could wrap the component in an If component where you evaluate privileges.

Martin
Well, that's business logic leaking to the view layer. Not to mention you don't have any checks done by the compiler that way and you clutter your view with ugly constructs (at least for my tastes). I have decided to override renderCoponent and it works like a charm. But thanks for the answer anyway, Martin.
Michał Minicki