Hi, This is a perfect use case for org.apache.wicket.markup.html.panel.Fragment.
Martin Grigorov Wicket Training and Consulting On Mon, May 19, 2014 at 11:49 AM, Valentin Robert <valentin.rob...@gmx.com>wrote: > Hi > > i 'm new with wicket and after searching a solution to my problem, i > couldn't find any solution > Here is what i want to do. > > I would like to build a form where the input type can be textfields, > checkboxes, dropdown, ... > i've seen that some solutions would be to create a new conponent, or to > have multiple containers and set their visibility in java. > however i would like to have something like this : > > HTML > > <wicket:container wicket:id="listInput"> > <input wicket:id="input"id="whatever" type="text" size="40" /> > </wicket:container> > > Java > > add(new ListView<Variable<Object>>("listInput", obj.getList()) > { > > protected void populateItem(ListItem<Variable<Object>> item) > { > final Variable<Object> var = item.getModelObject(); > > if (var.getType().equals("string")) > { > item.add( new Textfield (...)); > } > else if (var.getType().equals("boolean")) > { > item.add( new Checkbox (...)); > } > ...... > > this does not work because i can't had a new checkbox on a component who > has a type=text. > > i tried to do something like add(AttributeModifier.replace("type", > "checkbox")); but i couldn't manage to do what i wanted. > If still think that if i don't want to create a component or have multiple > containers in my html, this is what i should use. > > if someone could help me to do this that would be great, i'm stuck with > this probleme and i didn't like the solutions that i found. > > thank you for taking the time to help me. >