You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Stefan Renz <s....@efonds.com> on 2013/02/20 19:20:49 UTC
How to modify markup?
Hi,
what would be the best way to modify the HTML output of a component?
Consider this:
<a wicket:id="...">Text</a>
which is backed by a Link component. By adding a behavior (I would
assume), I would like to modify this HTML to become sth like
<a ...><span ...></span><span>Text</span></a>
Please note that I want to preserve the componentTagBody.
I know how to change the tag, add an attribute, and found code to
generate something _after_ the tag (DatePicker), and for that matter,
probably also before the tag, but nothing so far to change the tags
(hierarchy) in between.
Is there a Wicket way to do that, do I have to resort to JavaScript, or
am I plainly overworked and should never try something like that anyway?
Thanks, bye
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to modify markup?
Posted by Andrea Del Bene <an...@gmail.com>.
The first solution that comes in my mind is to overwrite method
onComponentTagBody. Maybe this could work :
add(new Link("helloMessage"){
@Override
protected void onComponentTagBody(MarkupStream markupStream,
ComponentTag tag) {
getResponse().write("<span ...></span><span>");
//write the default body
super.onComponentTagBody(markupStream, tag);
getResponse().write("</span>");
}
});
> Hi,
>
> what would be the best way to modify the HTML output of a component?
>
> Consider this:
>
> <a wicket:id="...">Text</a>
>
> which is backed by a Link component. By adding a behavior (I would
> assume), I would like to modify this HTML to become sth like
>
> <a ...><span ...></span><span>Text</span></a>
>
> Please note that I want to preserve the componentTagBody.
>
> I know how to change the tag, add an attribute, and found code to
> generate something _after_ the tag (DatePicker), and for that matter,
> probably also before the tag, but nothing so far to change the tags
> (hierarchy) in between.
>
> Is there a Wicket way to do that, do I have to resort to JavaScript, or
> am I plainly overworked and should never try something like that anyway?
>
> Thanks, bye
> Stefan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to modify markup?
Posted by Zilvinas Vilutis <zi...@vilutis.lt>.
I think that is what borders are for ( read here:
https://cwiki.apache.org/WICKET/consistent-page-layout-using-borders.html )
Regards
Žilvinas Vilutis
On Wed, Feb 20, 2013 at 8:20 PM, Stefan Renz <s....@efonds.com> wrote:
> Hi,
>
> what would be the best way to modify the HTML output of a component?
>
> Consider this:
>
> <a wicket:id="...">Text</a>
>
> which is backed by a Link component. By adding a behavior (I would
> assume), I would like to modify this HTML to become sth like
>
> <a ...><span ...></span><span>Text</span></a>
>
> Please note that I want to preserve the componentTagBody.
>
> I know how to change the tag, add an attribute, and found code to
> generate something _after_ the tag (DatePicker), and for that matter,
> probably also before the tag, but nothing so far to change the tags
> (hierarchy) in between.
>
> Is there a Wicket way to do that, do I have to resort to JavaScript, or
> am I plainly overworked and should never try something like that anyway?
>
> Thanks, bye
> Stefan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>