[ 2610044 ] Can't save Shipments

- reset zero to null if it is not in list
This commit is contained in:
Heng Sin Low 2009-02-24 02:31:12 +00:00
parent 3d55c83dd0
commit 05730e876e
2 changed files with 43 additions and 8 deletions

View File

@ -99,6 +99,23 @@ public class Combobox extends org.zkoss.zul.Combobox
}
}
/**
*
* @param value
* @return boolean
*/
public boolean isSelected(Object value)
{
if (value == null)
return false;
Comboitem item = getSelectedItem();
if (item == null)
return false;
return item.getValue().equals(value);
}
/** Returns RS_NO_WIDTH|RS_NO_HEIGHT.
*/
protected int getRealStyleFlags() {

View File

@ -179,23 +179,41 @@ ContextMenuListener, IZoomableEditor
{
if (value != null && (value instanceof Integer || value instanceof String))
{
getComponent().setValue(value);
if (getComponent().getSelectedIndex() == -1 && lookup != null)
getComponent().setValue(value);
if (!getComponent().isSelected(value))
{
if (isReadWrite())
if (isReadWrite() && lookup != null)
lookup.refresh();
Object curValue = oldValue;
oldValue = value;
refreshList();
//still not in list, reset to zero
if (!getComponent().isSelected(value))
{
if (value instanceof Integer && (Integer)value == 0)
{
getComponent().setValue(null);
if (curValue == null)
curValue = value;
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), curValue, null);
super.fireValueChange(changeEvent);
oldValue = null;
}
}
}
else
{
oldValue = value;
}
}
else
{
getComponent().setValue(null);
}
oldValue = value;
}
}
@Override
public Combobox getComponent() {