use a behavior to render all the html. if you want to render using
wicket components and not html use a border

-igor

On Mon, Dec 13, 2010 at 9:47 PM, Sam Zilverberg <[email protected]> wrote:
> I realize my last post was a mess so here is an attempt to summarize it:
>
> I'm trying to turn
> <input wicket:id="name"/>
> which renders as
> <input name="name" id="some_generated_wicked_id"/>
> to something that will render like this:
> <label for="generated_id">label</label> * <-FormComponentLabel*
> <input name="name" id="generated_id"/>* <-Original FormComponent*
> <div></div> *<-ComponentFeedbackPanel*
>
> I managed to accomplish this using a panel, but its still not perfect.
> Here is what I have so far:
>
> The panel code:
>
> public class FormComponentLabelAndFeedbackWrapper<T> extends Panel {
>
>    public static final String COMP_ID = "comp";
>
>    public FormComponentLabelAndFeedbackWrapper(String id, FormComponent<T>
> comp) {
>        super(id);
>
>        if (!COMP_ID.equals(comp.getId())) {
>            throw new IllegalArgumentException("formcomponent id must be " +
> COMP_ID);
>        }
>        setDefaultModel(comp.getModel());
>        add(new FormComponentLabel("compLabel", comp));
>        add(comp);
>        add(new ComponentFeedbackPanel("compFeedback", comp));
>    }
>
>   �...@override
>    protected void onComponentTag(ComponentTag tag) {
>        tag.setName("div");
>        super.onComponentTag(tag);
>    }
> }
>
> Associated markup:
> <wicket:panel>
>    <label wicket:id="compLabel">[label for]</label>
>    <input wicket:id="comp"></input>
>    <div wicket:id="compFeedback">[feedback for comp]</div>
> </wicket:panel>
>
> example of use in code:
> form.add(new FormComponentLabelAndFeedbackWrapper<String>("name", new
> TextField<String>(FormComponentLabelAndFeedbackWrapper.COMP_ID, new
> PropertyModel<String>(user, "firstName"))));
>
> The problem is that I can only use form components that are related to
> <input> tag because if I use <wicket:container> instead of <input> the form
> component onComponentTag will throw an exception when checking the tag.
>
> -Is there anyway to somehow use <wicket:container> and change the tag
> somehow before the form component onComponentTag method is called?
> -This feels kind of hacky, can anyone suggest another method to achieve the
> original goal?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to