org.zkoss.bind.converter.sys.RadiogroupSelectedItemConverter Maven / Gradle / Ivy
/* RadiogroupSelectedItemConverter
{{IS_NOTE
Purpose:
Description:
History:
Mon Mar 12 11:05:43 2007, Created by Henri
}}IS_NOTE
Copyright (C) 2007 Potix Corporation. All Rights Reserved.
{{IS_RIGHT
}}IS_RIGHT
*/
package org.zkoss.bind.converter.sys;
import java.util.Iterator;
import java.util.Set;
import org.zkoss.bind.BindContext;
import org.zkoss.bind.Converter;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.UiException;
import org.zkoss.zul.ListModel;
import org.zkoss.zul.Radio;
import org.zkoss.zul.Radiogroup;
import org.zkoss.zul.ext.Selectable;
/**
* Convert Radiogroup selected item to radio value and vice versa.
*
* @author Dennis
* @since 6.0.0
*/
public class RadiogroupSelectedItemConverter implements Converter, java.io.Serializable {
private static final long serialVersionUID = 200808191534L;
@SuppressWarnings("unchecked")
public Object coerceToUi(Object val, Component comp, BindContext ctx) {
Radiogroup radiogroup = (Radiogroup) comp;
final ListModel> model = radiogroup.getModel();
//ZK-762 selection of ListModelList is not correct if binding to selectedItem
if (model != null && !(model instanceof Selectable)) {
//model has to implement Selectable if binding to selectedItem
throw new UiException("model doesn't implement Selectable");
}
if (val != null) {
if (model != null) {
((Selectable