You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Kiril Valev <va...@gmail.com> on 2013/09/07 17:53:04 UTC
LinkDecorator with custom link text
Hi,
is it possible to use a LinkDecorator and still get the link text from
the DataProvider without overriding the render method in Decorator?
The examples show only static text when using LinkDecorator (Either
"Edit" or "Delete"). Can I get the link text by property?
Thanks!
Re: LinkDecorator with custom link text
Posted by Kiril Valev <va...@gmail.com>.
Hi,
I solved the problem. Maybe my solution will be a better a explanation
to the problem:
I checked the source of the LinkDecorator and found this method:
[code]
/**
* Render the link to the specified buffer.
* <p/>
* If this method is overridden to add extra parameters to the link,
* remember to invoke <tt>super.renderActionLink</tt> so default rendering
* can continue.
*
* @param buffer the specified buffer to render the link output to
* @param link the link to render
* @param context the request context
* @param row the table row being rendered
* @param value the value of the link
*/
protected void renderActionLink(HtmlStringBuffer buffer, AbstractLink link,
Context context, Object row, Object value) {
link.render(buffer);
}
[/code]
Thus I solved my problem by overriding the renderActionLink in LinkDecorator:
[code]
public class LinkDecoratorWithDataProviderContent {
@Override
protected void renderActionLink(HtmlStringBuffer buffer, AbstractLink link,
Context context, Object row, Object value) {
if(row instanceof Post) {
// Set the TEXT, which is displayed by <a href>TEXT</a>.
Otherwise the name attribute of the link is written to <a href></a>
link.setLabel(post.getTitle());
}
super.enderActionLink(buffer, link, context, row, value);
}
}
[/code]
Cheers
2013/9/9 Bob Schellink <sa...@gmail.com>:
> Hi,
>
> The "edit"/"delete" text is normally set on an ActionLink control. You can
> set the text of the ActionLinks to anything you like.
>
> regards
>
> Bob
>
>
> On 2013/09/09 15:59, Gilberto wrote:
>
> Hi, Kiril! Welcome to Click community!
>
> Can you better elaborate your question? I did not understand it. Do you
> understand the Decorator Design Pattern' idea[1]?
>
> Regards,
>
> Gilberto
>
> [1]
> http://click.apache.org/docs/extras-api/org/apache/click/extras/control/LinkDecorator.html
>
>
>
> 2013/9/7 Kiril Valev <va...@gmail.com>
>>
>> Hi,
>>
>> is it possible to use a LinkDecorator and still get the link text from
>> the DataProvider without overriding the render method in Decorator?
>> The examples show only static text when using LinkDecorator (Either
>> "Edit" or "Delete"). Can I get the link text by property?
>>
>> Thanks!
>
>
>
Re: LinkDecorator with custom link text
Posted by Bob Schellink <sa...@gmail.com>.
Hi,
The "edit"/"delete" text is normally set on an ActionLink control. You can set the text of the
ActionLinks to anything you like.
regards
Bob
On 2013/09/09 15:59, Gilberto wrote:
> Hi, Kiril! Welcome to Click community!
>
> Can you better elaborate your question? I did not understand it. Do you understand the Decorator
> Design Pattern' idea[1]?
>
> Regards,
>
> Gilberto
>
> [1] http://click.apache.org/docs/extras-api/org/apache/click/extras/control/LinkDecorator.html
>
>
>
> 2013/9/7 Kiril Valev <valevkiril@gmail.com <ma...@gmail.com>>
>
> Hi,
>
> is it possible to use a LinkDecorator and still get the link text from
> the DataProvider without overriding the render method in Decorator?
> The examples show only static text when using LinkDecorator (Either
> "Edit" or "Delete"). Can I get the link text by property?
>
> Thanks!
>
>
Re: LinkDecorator with custom link text
Posted by Gilberto <gi...@gmail.com>.
Hi, Kiril! Welcome to Click community!
Can you better elaborate your question? I did not understand it. Do you
understand the Decorator Design Pattern' idea[1]?
Regards,
Gilberto
[1]
http://click.apache.org/docs/extras-api/org/apache/click/extras/control/LinkDecorator.html
2013/9/7 Kiril Valev <va...@gmail.com>
> Hi,
>
> is it possible to use a LinkDecorator and still get the link text from
> the DataProvider without overriding the render method in Decorator?
> The examples show only static text when using LinkDecorator (Either
> "Edit" or "Delete"). Can I get the link text by property?
>
> Thanks!
>