Versions Compared

Key

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

...

Also note that the Radio components do not need to be direct children of the radio group, they can be anywhere in the component hierarchy below the RadioGroup component.

Using RadioGroup within table rows

Sometimes it is useful to have a RadioGroup that encompasses each row. This can be accomplished by using a wicket encloser. In your web page (example uses a data view, but any view will do):

Code Block

final DataView dataView = new DataView("profile-rows", dp) {
	private static final long serialVersionUID = 1L;

	/**
	* {@inheritDoc}
	*/
	@Override
	protected void populateItem(final Item item) {
		Person person = (Person) item.getModelObject();
		item.add(new Label("first-name", person.getFirstName()));
		item.add(new Label("last-name", person.getLastName()));

		// add the radio group to select system or department (organizational) administrators
		final RadioGroup adminRadioGroup = new RadioGroup("radio-admin", new Model());
		item.add(adminRadioGroup);
		adminRadioGroup.add(new Radio("radio-sys-admin", new Model()));
		adminRadioGroup.add(new Radio("radio-dept-admin", new Model()));
	}
};

And finally, the markup:

Code Block

<table>
	<thead>
		<tr>
			<th>
				First Name
			</th>
			<th>
				Last Name
			</th>
			<th>
				Sys. Admin
			</th>
			<th>
				Dept. Admin
			</th>
		</tr>
	</thead>
	<tbody>
		<tr wicket:id="profile-rows">
			<td><span wicket:id="first-name">[First Name]</span></td>
			<td><span wicket:id="last-name">[Last Name]</span></td>
			<wicket:container wicket:id="radio-admin">
				<td><input wicket:id="radio-sys-admin" type="radio" /></td>
				<td><input wicket:id="radio-dept-admin" type="radio" /></td>
			</wicket:container>
		</tr>
	</tbody>
</table>