Fix problem in zkwebui - resource assignment cannot be created.

Steps to reproduce:
- Create a Sales Order
- Create a line selling Mary Consultant product
- Try to create a resource assignment
a Null Pointer Exception was thrown
This commit is contained in:
Carlos Ruiz 2011-03-25 19:54:10 -05:00
parent f80fdada3b
commit de8c0de43e
3 changed files with 32 additions and 13 deletions

View File

@ -30,10 +30,10 @@ import org.compiere.util.ValueNamePair;
*/
public class ListItem extends org.zkoss.zul.Listitem
{
/**
/**
*
*/
private static final long serialVersionUID = -3445426943414051896L;
private static final long serialVersionUID = -8052056834118074979L;
private PropertyChangeSupport m_propertyChangeListeners = new PropertyChangeSupport(this);
public ListItem(String label, Object value)
@ -59,4 +59,10 @@ public class ListItem extends org.zkoss.zul.Listitem
public ValueNamePair toValueNamePair() {
return new ValueNamePair((String)getValue(), getLabel());
}
@Override
public String toString() {
return getValue().toString();
}
}

View File

@ -37,10 +37,10 @@ import org.zkoss.zul.Listitem;
*/
public class Listbox extends org.zkoss.zul.Listbox implements EventListener
{
/**
/**
*
*/
private static final long serialVersionUID = -411510408730815382L;
private static final long serialVersionUID = 2102597724705225997L;
private List<EventListener> doubleClickListeners = new ArrayList<EventListener>();
private List<EventListener> onDropListeners = new ArrayList<EventListener>();
private boolean draggable;
@ -327,4 +327,17 @@ public class Listbox extends org.zkoss.zul.Listbox implements EventListener
oddRowSclass = scls;
super.setOddRowSclass(scls);
}
@Override
public String toString() {
StringBuffer items = new StringBuffer("[");
for (ListItem item : getItems()) {
if (items.length() > 1)
items.append(", ");
items.append(item.toString());
}
items.append("]");
return items.toString();
}
}

View File

@ -221,16 +221,14 @@ public class WAssignmentDialog extends Window implements EventListener
// Set Resource
int S_Resource_ID = m_mAssignment.getS_Resource_ID();
KeyNamePair[] resources = new KeyNamePair[m_lookup.size()];
m_lookup.keySet().toArray(resources);
for (int i = 0; i < resources.length; i++)
{
if (resources[i].getKey() == S_Resource_ID)
{
fResource.setSelectedIndex(i);
for (ListItem item : fResource.getItems()) {
if ( (Integer)item.getValue() == S_Resource_ID) {
fResource.setSelectedItem(item);
break;
}
}
ListItem listItem = fResource.getSelectedItem();
KeyNamePair check = new KeyNamePair((Integer)listItem.getValue(), listItem.getLabel());
if (check == null || check.getKey() != S_Resource_ID)
@ -284,7 +282,9 @@ public class WAssignmentDialog extends Window implements EventListener
getDateAndTimeFrom(date);
Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis());
BigDecimal qty = fQty.getValue();
KeyNamePair uom = (KeyNamePair)m_lookup.get(fResource.getSelectedItem());
ListItem listItem = fResource.getSelectedItem();
KeyNamePair resource = listItem != null ? new KeyNamePair((Integer)listItem.getValue(), listItem.getLabel()) : null;
KeyNamePair uom = (KeyNamePair)m_lookup.get(resource);
int minutes = MUOMConversion.convertToMinutes(Env.getCtx(), uom.getKey(), qty);
Timestamp assignDateTo = TimeUtil.addMinutess(assignDateFrom, minutes);
m_mAssignment.setAssignDateTo (assignDateTo);
@ -367,7 +367,7 @@ public class WAssignmentDialog extends Window implements EventListener
// Resource - Look up UOM
if (e.getTarget() == fResource)
{
Object o = m_lookup.get(fResource.getSelectedItem());
Object o = m_lookup.get(resource);
if (o == null)
lUOM.setValue(" ? ");
else