* @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext,
* javax.faces.component.UIComponent)
*/
public void encodeEnd(FacesContext context, UIComponent component) throws IOException
{
HtmlTreeCheckbox checkbox = (HtmlTreeCheckbox) component;
String forAttr = checkbox.getFor();
if (forAttr == null)
{
throw new IllegalStateException("Mandatory attribute 'for'");
}
UIComponent uiComponent = checkbox.findComponent(forAttr);
if (uiComponent == null)
{
throw new IllegalStateException("Could not find component '" + forAttr
+ "' (calling findComponent on component '" + checkbox.getClientId(context) + "')");
}
if (!(uiComponent instanceof UISelectMany))
{
throw new IllegalStateException("UISelectMany expected");
}
UISelectMany uiSelectMany = (UISelectMany) uiComponent;
Converter converter;
try
{
converter = RendererUtils.findUISelectManyConverter(context, uiSelectMany);
}
catch (FacesException e)
{
converter = null;
}
Set lookupSet = RendererUtils.getSelectedValuesAsSet(context, component, converter, uiSelectMany);
Object itemValue = checkbox.getItemValue();
String itemStrValue = null;
if (converter == null)
{
if (null != itemValue)
{
itemStrValue = itemValue.toString();
}
}
else
{
itemStrValue = converter.getAsString(context, uiSelectMany, itemValue);
}
renderCheckbox(context, uiSelectMany, itemStrValue, checkbox.getItemLabel(), lookupSet.contains(itemStrValue),
true);
}