Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

RadioGroups contain Radio objects. The model for the RadioGroup is the object property, while the child Radio objects represent the set of values the property can be set to. Let's look at a trivial example, starting with a POJO:


  public class MyObject {
    private Integer myInt;
    public void setMyInt(Integer myInt) ...
    public Integer getMyInt() ...
  }
Code Block
Panel
Wiki Markup

Next, the relevant snippet from the Form class:

Panelcode

  MyObject bean=new MyObject();


  RadioGroup myInt = new RadioGroup("group", new PropertyModel(bean, "myInt"));


  myInt.add(new Radio("1", new Model(1)));


  myInt.add(new Radio("2", new Model(2)));


  myInt.add(new Radio("3", new Model(3)));


  myInt.add(new Radio("4", new Model(4)));


  add(myInt);

And finally, the markup:

Panelcode

  <span wicket:id="group">


    <input wicket:id="1" type="radio"/>


    <input wicket:id="2" type="radio"/>


    <input wicket:id="3" type="radio"/>


    <input wicket:id="4" type="radio"/>


  </span>

And that's all there is to using a RadioGroup with Radio instances.

...