Hi Bas and thanks for your input! I guess this would also be my preferred way 
to deal with that task. But this also means that all "client" applications 
would have to be adapted and at least change their HTML markup which I'd like 
to avoid. I'm currently looking for a solution that avoids code changes as far 
as possible in existing client applications (and we have _several_ of those) ...

Any chance you could share some parts of your custom code?

Tom

> Gesendet: Dienstag, 03. September 2019 um 12:19 Uhr
> Von: "Bas Gooren" <b...@iswd.nl>
> An: users@wicket.apache.org, "Tom Götz" <t...@richmountain.de>
> Betreff: Re: Wrapping a FormComponent with a Border
>
> Hi Tom,
> 
> I have tried various ways to make this work: from custom markup filters and
> component tree manipulation to custom form components, which are added to a
> repeater (and thus the entire form is created programmatically, apart from
> a single div which our FormPanel connects to.
> In other projects I have experimented with rewriting the markup with a
> custom parser, implementing a custom markup cache etc.
> 
> I think, in general, the wicket-way is to not have (too) much magic; This
> also became evident for me when working with markup filters and custom
> markup caches. I got it all to work, but it’s quite complex.
> 
> In my current projects I pick (or mix) from these two strategies:
> 
> a) add the div for a border component to the layout:
> 
> <div wicket:id=“component-border”>
> <input type=“…” wicket:id=“component>
> </div>
> 
> b) use custom form components, and render them with a repeater
> 
> E.g. a TextInput<T> implements Input<T>, which contains the border, input
> component etc.
> The repeater then accepts a list of Input<?>.
> Actually, we added a FormElement base class, since we also want to have
> non-input components in our forms like tabbed panels, information boxes etc.
> 
> In both cases, in your code you know what markup and component tree you are
> dealing with.
> In other words: no magic.
> 
> My 2 cents :-)
> 
> Met vriendelijke groet,
> Kind regards,
> 
> Bas Gooren
> 
> Op 3 september 2019 bij 11:19:06, Tom Götz (t...@richmountain.de) schreef:
> 
> Well ok, I'll give the Panel solution a try. In the panel I will have a
> FormGroup Border and inside that there's my input/textfield. Only thing
> that still worries me:
> user creates the TextField in Java code with wicket:id that he has in it's
> markup file. This wicket:id can't be changed afterwards (final). But in
> MyFormGroupPanel I need markup for the input, and this markup needs an id.
> Hm, maybe I'll look into some repeater solution for that problem ...
> 
> Tom
> 
> 
> > Gesendet: Dienstag, 03. September 2019 um 09:35 Uhr
> > Von: "Martin Grigorov" <mgrigo...@apache.org>
> > An: "users@wicket.apache.org" <users@wicket.apache.org>
> > Betreff: Re: Wrapping a FormComponent with a Border
> >
> > On Tue, Sep 3, 2019 at 10:30 AM "Tom Götz" <t...@richmountain.de> wrote:
> >
> > > Thanks Martin, I will look into that. But won't it be a problem that I
> > > will add the <input/> / TextField to the Border without having any
> markup
> > > inside the Border? Won't I need my <input/> markup inside the border
> > > <div/>s?
> > >
> >
> > right! it is a Border, not a Panel (
> >
> https://github.com/l0rdn1kk0n/wicket-bootstrap/blob/wicket-8.x/bootstrap-core/src/main/java/de/agilecoders/wicket/core/markup/html/bootstrap/form/FormGroup.html#L9
> > )
> > I think it would be easier if you roll MyFormGroupPanel instead of using
> a
> > Border.
> > If you decide to stick with FormGroup then you will need to override
> > onComponentTagBody() too
> >
> >
> > >
> > > Tom
> > >
> > >
> > > > Gesendet: Dienstag, 03. September 2019 um 09:22 Uhr
> > > > Von: "Martin Grigorov" <mgrigo...@apache.org>
> > > > An: "users@wicket.apache.org" <users@wicket.apache.org>
> > > > Betreff: Re: Re: Wrapping a FormComponent with a Border
> > > >
> > > > Hi Tom,
> > > >
> > > > Since your "user" is going to add a TextField in the Java code then I
> > > > assume (s)he is going to add <input wicket:id="..."/> in the markup.
> > > > Your IComponentInitializationListener will replace all components of
> type
> > > > TextField which do not have FormGroup as a parent with a MyFormGroup.
> > > >
> > > > public class MyFormGroup extends FormGroup {
> > > > // constructor(s)
> > > >
> > > > @Override
> > > > public void onComponentTag(ComponentTag tag) {
> > > > super(tag);
> > > > tag.setName("div"); // this modifies <input> to <div>
> > > > }
> > > > }
> > > >
> > > > I am not sure, but you may also need to expand the tag from OpenClose
> > > (i.e.
> > > > <input/>) to open+close (i.e. <div></div>). See
> > > ComponentTag#isOpenClose()
> > > > and Component#afterRender();
> > > >
> > > > On Tue, Sep 3, 2019 at 10:09 AM "Tom Götz" <t...@richmountain.de>
> wrote:
> > > >
> > > > > Martin,
> > > > >
> > > > > maybe you could point me into the right direction concerning the
> markup
> > > > > manipulation part?
> > > > >
> > > > > This is what I got in my HTML:
> > > > >
> > > > > <form wicket:id="form">
> > > > > <input wicket:id="input" type="text" />
> > > > > </form>
> > > > >
> > > > > I guess this is what I need for effectively replacing the input
> with a
> > > > > FormGroup border:
> > > > >
> > > > > <form wicket:id="form">
> > > > > <div wicket:id="border">
> > > > > <input wicket:id="input" type="text" />
> > > > > </div>
> > > > > </form>
> > > > >
> > > > > Where would be the best place in the code to start looking?
> > > > >
> > > > > Thanks in advance
> > > > > Tom
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to