I'm sure this subject has been discussed before many times, but would like to
revisit it to get some thoughts from the community.
Consider a Wicket TextField. The typical markup is something like,
<input type="text" wicket:id="someId" …/>
I would like to, instead, specify a span or a div in the markup and bind the
TextField to that markup instead.
I know I can achieve this by creating a new class that extends Panel (call it
TextFieldPanel) with markup similar to the following,
…
<wicket:panel>
<input type="text" wicket:id="someId"/>
</wicket:panel>
Now I can use a <div> or <span> tag as in,
<div wicket:id="editor"/>
The problem with this approach is now if I want to affect some portion of the
TextField, like adding a behavior to it, I'm almost forced to expose internal
details about the Panel impl that I shouldn't.
For example, myTextFieldPanel.addBehaviorToChildComponent(IBehavior… behavior)
which then adds the behavior to the TextField within the derived Panel.
It would be nice to be able to do something like,
public class MyTextField<T> extends TextField<T> {…}
That allows you to use a <span> or a <div> for the markup but generates valid
HTML. With this approach you would be less inclined to expose the internals of
the implementation because you are operating on an actual TextField instance.
I am using a fairly old version of Wicket, 1.4.13 but in the process of
upgrading to 6.0. So I would like some thoughts on if this is feasible for
1.4.x and if its even practical. I realize I have control over the
construction of the markup for a component but I'm concerned as well about
making sure the generated markup is valid HTML.
Thanks,
J.D.