Hi,
I'd like to achieve something like this:
Normal component:
<a href="...">Some text</a>
Enhanced component:
<a href="..."><span class="icon-admin" title="Admin stuff"></span>Some
Text</a>
The span would be the added component.
The link is only an example, in the end it should be possible to 'enhance'
any kind of component. So my first guess was to use a Border or
BorderBehavior- but I couldn't get it to work without extra markup and
classes for each component.
Next guess would have been a custom behavior, but unfortunately there's no
onComponentTagBody, which I would have used to insert arbitrary html code
inside the component.
Right now, I don't see an elegant solution to achieve what I want - but
maybe you could help me?
Something like this would be cool:
anyComponent.add(new IconBehavior(new IconComponent("someId"));
or
anyComponent.add(new IconBehavior(IconComponent.class);
Of course I could just manipulate the rendered HTML of the component like
this:
http://pastebin.com/ECdRmAKG
anyComponent.add(new AbstractTransformerBehavior() {
public CharSequence transform(Component component, CharSequence
output) {
// Search output for end of open tag
// Use org.apache.wicket.core.util.string.ComponentRenderer
to render IconComponent to String
// insert the rendered string
return output;
});
But this is rather quirky.
Kind regards,
Rza
I'd like to achieve something like this:
Normal component:
<a href="...">Some text</a>
Enhanced component:
<a href="..."><span class="icon-admin" title="Admin stuff"></span>Some
Text</a>
The span would be the added component.
The link is only an example, in the end it should be possible to 'enhance'
any kind of component. So my first guess was to use a Border or
BorderBehavior- but I couldn't get it to work without extra markup and
classes for each component.
Next guess would have been a custom behavior, but unfortunately there's no
onComponentTagBody, which I would have used to insert arbitrary html code
inside the component.
Right now, I don't see an elegant solution to achieve what I want - but
maybe you could help me?
Something like this would be cool:
anyComponent.add(new IconBehavior(new IconComponent("someId"));
or
anyComponent.add(new IconBehavior(IconComponent.class);
Of course I could just manipulate the rendered HTML of the component like
this:
http://pastebin.com/ECdRmAKG
anyComponent.add(new AbstractTransformerBehavior() {
public CharSequence transform(Component component, CharSequence
output) {
// Search output for end of open tag
// Use org.apache.wicket.core.util.string.ComponentRenderer
to render IconComponent to String
// insert the rendered string
return output;
});
But this is rather quirky.
Kind regards,
Rza