List selectedList = (List) getSelectedListBinding().getObject("selectedList", List.class);
if (selectedList == null)
throw Tapestry.createRequiredParameterException(this, "selectedList");
IPropertySelectionModel model = getModel();
if (model == null)
throw Tapestry.createRequiredParameterException(this, "model");
// Handle the form processing first.
if (rewinding)
{
// If disabled, ignore anything that comes up from the client.
if (isDisabled())
return;
// get all the values
String[] optionValues = cycle.getRequestContext().getParameters(name);
// Clear the list
selectedList.clear();
// Nothing was selected
if (optionValues != null)
{
// Go through the array and translate and put back in the list
for (int i = 0; i < optionValues.length; i++)
{
// Translate the new value
Object selectedValue = model.translateValue(optionValues[i]);
// Add this element in the list back
selectedList.add(selectedValue);
}
}
return;
}
IMultiplePropertySelectionRenderer renderer = getRenderer();
// Start rendering
renderer.beginRender(this, writer, cycle);
int count = model.getOptionCount();
for (int i = 0; i < count; i++)
{
Object option = model.getOption(i);
// Try to find the option in the list and if yes, then it is checked.
boolean optionSelected = selectedList.contains(option);
renderer.renderOption(this, writer, cycle, model, option, i, optionSelected);