public void decode(FacesContext facesContext, UIComponent uiComponent)
{
if (uiComponent instanceof HtmlRadio)
{
HtmlRadio radio = (HtmlRadio) uiComponent;
String forAttr = radio.getFor();
if (forAttr == null)
{
throw new IllegalStateException("mandatory attribute 'for'");
}
int index = radio.getIndex();
if (index < 0)
{
throw new IllegalStateException("positive index must be given");
}
UIComponent uiSelectOne = radio.findComponent(forAttr);
if (uiSelectOne == null)
{
throw new IllegalStateException("Could not find component '" + forAttr + "' (calling findComponent on component '" + radio.getClientId(facesContext) + "')");
}
if (!(uiSelectOne instanceof UISelectOne))
{
throw new IllegalStateException("UISelectOne expected");
}
if (uiSelectOne instanceof ClientBehaviorHolder) {
ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) uiSelectOne;
Map<String, List<ClientBehavior>> clientBehaviors =
clientBehaviorHolder.getClientBehaviors();
if (clientBehaviors != null && !clientBehaviors.isEmpty()) {
Map<String, String> paramMap = facesContext.getExternalContext().
getRequestParameterMap();
String behaviorEventName = paramMap.get("javax.faces.behavior.event");
if (behaviorEventName != null) {
List<ClientBehavior> clientBehaviorList = clientBehaviors.get(behaviorEventName);
if (clientBehaviorList != null && !clientBehaviorList.isEmpty()) {
String clientId = paramMap.get("javax.faces.source");
if (radio.getClientId().equals(clientId)) {
for (ClientBehavior clientBehavior : clientBehaviorList) {
clientBehavior.decode(facesContext, radio);
}
}
}