org.zkoss.bind.converter.sys.SelectboxSelectedItemConverter Maven / Gradle / Ivy
The newest version!
/* SelectedListitemConverter.java
Purpose:
Description:
History:
Aug 17, 2011 6:10:20 PM, Created by henrichen
Copyright (C) 2011 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.bind.converter.sys;
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.Selectbox;
import org.zkoss.zul.ext.Selectable;
/**
* Convert listbox selected listitem to bean and vice versa.
* @author henrichen
* @author dennis
* @since 6.0.0
*/
public class SelectboxSelectedItemConverter implements Converter, java.io.Serializable {
private static final long serialVersionUID = 201108171811L;
@SuppressWarnings("unchecked")
public Object coerceToUi(Object val, Component comp, BindContext ctx) {
Selectbox sbox = (Selectbox) comp;
final ListModel> model = sbox.getModel();
if (model == null) {
throw new UiException("no model in selectbox");
}
if (!(model instanceof Selectable)) {
throw new UiException("model doesn't implement Selectable");
}
if (val != null) {
((Selectable
© 2015 - 2025 Weber Informatics LLC | Privacy Policy