You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Blower, Andy" <An...@proquest.co.uk> on 2008/09/17 12:30:10 UTC

Overriding a render phase method

>From the T5 documentation:

"When a sub-class overrides an render phase method of a base class, the method is only invoked once, along with any other base class methods. The subclass can change the implementation of the base class method via an override, but can't change the timing of when that method is invoked. See TAPESTRY-2311<https://issues.apache.org/jira/browse/TAPESTRY-2311>."

I want to extend the Loop component to add a 'last' parameter that's true for the last iteration of the loop, and false otherwise. Unfortunately when I extend the T5 Loop component and try to override after() so I can set the Boolean (change the implementation like the docs suggest), it cannot be overridden because the method is package private. All of the members of the T5 Loop component are private and there's no public accessors for the ones I need.

So, anyone any ideas how I can do this? The only thing I can think is asking Howard to make the render phase methods public or protected so they can be overridden. Either that or I copy the entire loop component code into my own - ugh.

Thanks,

Andy

RE: Overriding a render phase method

Posted by "Blower, Andy" <An...@proquest.co.uk>.
So I was missing an easy solution! Thanks for this Filip, although I really should have figured this out myself. I take it the index gets coerced into a Boolean for the test, I'd forgotten all about that useful feature of coercion. It gets worse, it's documented at the bottom of the if component page. D'oh.

> -----Original Message-----
> From: Filip S. Adamsen [mailto:fsa@fsadev.com]
> Sent: 23 September 2008 21:19
> To: Tapestry users
> Subject: Re: Overriding a render phase method
>
> Well... You could try this:
>
>    <t:loop t:source="source" t:value="value" t:index="var:index">
>      <t:if t:test="var:index">; </t:if>
>      ${value}
>    </t:loop>
>
> That's what I use.
>
> -Filip
>
> On 2008-09-23 21:58, Blower, Andy wrote:
> > Thanks Filip, I'll try and raise an enhancement request when I get a
> spare 10 mins.
> >
> > I've just been trying to do this using composition. I keep getting
> errors with render variables, and I really don't have time to track
> this down. It's pretty silly that I've spent probably two hours trying
> to use the T5 loop component to display a list of values separated by
> semicolons without having one at the end. This shouldn't be hard, or
> require a custom component. Maybe I'm missing some easy solution to
> this problem or something?
> >
> >> -----Original Message-----
> >> From: Filip S. Adamsen [mailto:fsa@fsadev.com]
> >> Sent: 23 September 2008 20:34
> >> To: Tapestry users
> >> Subject: Re: Overriding a render phase method
> >>
> >> Hi Andy,
> >>
> >> I totally agree on first and last parameters. As it is now, I'm
> using
> >> if-else components pretty much everywhere. =/
> >>
> >> You'd have my vote on a JIRA issue.
> >>
> >> -Filip
> >>
> >> On 2008-09-23 21:12, Blower, Andy wrote:
> >>> <snip/>
> >>> To be honest I think the standard loop component would benefit from
> >> first & last Boolean parameters that are set to true for first and
> last
> >> iterations repectively. Anyone else agree, or is this an unusual
> need?
> >>> Thanks,
> >>>
> >>> Andy.
> >> --------------------------------------------------------------------
> -
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Overriding a render phase method

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
Well... You could try this:

   <t:loop t:source="source" t:value="value" t:index="var:index">
     <t:if t:test="var:index">; </t:if>
     ${value}
   </t:loop>

That's what I use.

-Filip

On 2008-09-23 21:58, Blower, Andy wrote:
> Thanks Filip, I'll try and raise an enhancement request when I get a spare 10 mins.
> 
> I've just been trying to do this using composition. I keep getting errors with render variables, and I really don't have time to track this down. It's pretty silly that I've spent probably two hours trying to use the T5 loop component to display a list of values separated by semicolons without having one at the end. This shouldn't be hard, or require a custom component. Maybe I'm missing some easy solution to this problem or something?
> 
>> -----Original Message-----
>> From: Filip S. Adamsen [mailto:fsa@fsadev.com]
>> Sent: 23 September 2008 20:34
>> To: Tapestry users
>> Subject: Re: Overriding a render phase method
>>
>> Hi Andy,
>>
>> I totally agree on first and last parameters. As it is now, I'm using
>> if-else components pretty much everywhere. =/
>>
>> You'd have my vote on a JIRA issue.
>>
>> -Filip
>>
>> On 2008-09-23 21:12, Blower, Andy wrote:
>>> <snip/>
>>> To be honest I think the standard loop component would benefit from
>> first & last Boolean parameters that are set to true for first and last
>> iterations repectively. Anyone else agree, or is this an unusual need?
>>> Thanks,
>>>
>>> Andy.
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Overriding a render phase method

Posted by "Blower, Andy" <An...@proquest.co.uk>.
Thanks Filip, I'll try and raise an enhancement request when I get a spare 10 mins.

I've just been trying to do this using composition. I keep getting errors with render variables, and I really don't have time to track this down. It's pretty silly that I've spent probably two hours trying to use the T5 loop component to display a list of values separated by semicolons without having one at the end. This shouldn't be hard, or require a custom component. Maybe I'm missing some easy solution to this problem or something?

> -----Original Message-----
> From: Filip S. Adamsen [mailto:fsa@fsadev.com]
> Sent: 23 September 2008 20:34
> To: Tapestry users
> Subject: Re: Overriding a render phase method
>
> Hi Andy,
>
> I totally agree on first and last parameters. As it is now, I'm using
> if-else components pretty much everywhere. =/
>
> You'd have my vote on a JIRA issue.
>
> -Filip
>
> On 2008-09-23 21:12, Blower, Andy wrote:
> > <snip/>
> > To be honest I think the standard loop component would benefit from
> first & last Boolean parameters that are set to true for first and last
> iterations repectively. Anyone else agree, or is this an unusual need?
> >
> > Thanks,
> >
> > Andy.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Overriding a render phase method

Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
Hi Andy,

I totally agree on first and last parameters. As it is now, I'm using 
if-else components pretty much everywhere. =/

You'd have my vote on a JIRA issue.

-Filip

On 2008-09-23 21:12, Blower, Andy wrote:
> <snip/>
> To be honest I think the standard loop component would benefit from first & last Boolean parameters that are set to true for first and last iterations repectively. Anyone else agree, or is this an unusual need?
> 
> Thanks,
> 
> Andy.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Overriding a render phase method

Posted by "Blower, Andy" <An...@proquest.co.uk>.
Thank you Jonathan, that's very helpful - I must have seen the bug before as I've voted on it already, but I can't recall it. I hadn't even considered trying a mixin. Composition I'd discounted early because I was adding a single new parameter and never reconsidered after being unable to extend.

>From Howard's reply to the issue it looks like he has his reasons for them being package private. The thing is, for what I need to do, I can't use a mixin or extension because I still can't get at the Iterator driving the loop to do a test for the last iteration. All I thought I needed to do was to be able to override the @AfterRender after() method and call the superclass version which returns the Boolean I need to expose. Unfortunately that would be too late as the body would already have rendered.

I think my only option to avoid copying all the T5 Loop code into my own is to use composition and compare source.size() with index from the Loop component since that's the only thing exposed.

To be honest I think the standard loop component would benefit from first & last Boolean parameters that are set to true for first and last iterations repectively. Anyone else agree, or is this an unusual need?

Thanks,

Andy.

> -----Original Message-----
> From: Jonathan Barker [mailto:jonathan.theitguy@gmail.com]
> Sent: 23 September 2008 18:29
> To: 'Tapestry users'
> Subject: RE: Overriding a render phase method
>
> First, have a look at:
>
> https://issues.apache.org/jira/browse/TAP5-173
>
> and then vote for it.
>
> Sorry, no pearls of wisdom beyond that.
>
>
> > -----Original Message-----
> > From: Blower, Andy [mailto:Andrew.Blower@proquest.co.uk]
> > Sent: Tuesday, September 23, 2008 12:44
> > To: 'Tapestry users'
> > Subject: RE: Overriding a render phase method
> >
> > Sorry to 'bump' this, but I'd really like some guidance/opinions.
> >
> > > -----Original Message-----
> > > From: Blower, Andy
> > > Sent: 17 September 2008 11:30
> > > To: 'Tapestry users'
> > > Subject: Overriding a render phase method
> > >
> > > From the T5 documentation:
> > >
> > > "When a sub-class overrides an render phase method of a base class,
> the
> > > method is only invoked once, along with any other base class
> methods.
> > > The subclass can change the implementation of the base class method
> via
> > > an override, but can't change the timing of when that method is
> > > invoked. See TAPESTRY-2311
> > <https://issues.apache.org/jira/browse/TAPESTRY-2311>."
> > >
> > > I want to extend the Loop component to add a 'last' parameter
> that's
> > > true for the last iteration of the loop, and false otherwise.
> > > Unfortunately when I extend the T5 Loop component and try to
> override
> > > after() so I can set the Boolean (change the implementation like
> the
> > > docs suggest), it cannot be overridden because the method is
> package
> > > private. All of the members of the T5 Loop component are private
> and
> > > there's no public accessors for the ones I need.
> > >
> > > So, anyone any ideas how I can do this? The only thing I can think
> is
> > > asking Howard to make the render phase methods public or protected
> so
> > > they can be overridden. Either that or I copy the entire loop
> component
> > > code into my own - ugh.
> > >
> > > Thanks,
> > >
> > > Andy
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Overriding a render phase method

Posted by Jonathan Barker <jo...@gmail.com>.
First, have a look at:

https://issues.apache.org/jira/browse/TAP5-173

and then vote for it.

Sorry, no pearls of wisdom beyond that.


> -----Original Message-----
> From: Blower, Andy [mailto:Andrew.Blower@proquest.co.uk]
> Sent: Tuesday, September 23, 2008 12:44
> To: 'Tapestry users'
> Subject: RE: Overriding a render phase method
> 
> Sorry to 'bump' this, but I'd really like some guidance/opinions.
> 
> > -----Original Message-----
> > From: Blower, Andy
> > Sent: 17 September 2008 11:30
> > To: 'Tapestry users'
> > Subject: Overriding a render phase method
> >
> > From the T5 documentation:
> >
> > "When a sub-class overrides an render phase method of a base class, the
> > method is only invoked once, along with any other base class methods.
> > The subclass can change the implementation of the base class method via
> > an override, but can't change the timing of when that method is
> > invoked. See TAPESTRY-2311
> <https://issues.apache.org/jira/browse/TAPESTRY-2311>."
> >
> > I want to extend the Loop component to add a 'last' parameter that's
> > true for the last iteration of the loop, and false otherwise.
> > Unfortunately when I extend the T5 Loop component and try to override
> > after() so I can set the Boolean (change the implementation like the
> > docs suggest), it cannot be overridden because the method is package
> > private. All of the members of the T5 Loop component are private and
> > there's no public accessors for the ones I need.
> >
> > So, anyone any ideas how I can do this? The only thing I can think is
> > asking Howard to make the render phase methods public or protected so
> > they can be overridden. Either that or I copy the entire loop component
> > code into my own - ugh.
> >
> > Thanks,
> >
> > Andy
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Overriding a render phase method

Posted by "Blower, Andy" <An...@proquest.co.uk>.
Sorry to 'bump' this, but I'd really like some guidance/opinions.

> -----Original Message-----
> From: Blower, Andy
> Sent: 17 September 2008 11:30
> To: 'Tapestry users'
> Subject: Overriding a render phase method
>
> From the T5 documentation:
>
> "When a sub-class overrides an render phase method of a base class, the
> method is only invoked once, along with any other base class methods.
> The subclass can change the implementation of the base class method via
> an override, but can't change the timing of when that method is
> invoked. See TAPESTRY-2311 <https://issues.apache.org/jira/browse/TAPESTRY-2311>."
>
> I want to extend the Loop component to add a 'last' parameter that's
> true for the last iteration of the loop, and false otherwise.
> Unfortunately when I extend the T5 Loop component and try to override
> after() so I can set the Boolean (change the implementation like the
> docs suggest), it cannot be overridden because the method is package
> private. All of the members of the T5 Loop component are private and
> there's no public accessors for the ones I need.
>
> So, anyone any ideas how I can do this? The only thing I can think is
> asking Howard to make the render phase methods public or protected so
> they can be overridden. Either that or I copy the entire loop component
> code into my own - ugh.
>
> Thanks,
>
> Andy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org