From f5a2d182f71023bd1884054c326b761e2e1a820b Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sun, 10 Apr 2011 01:34:42 -0500 Subject: [PATCH] Fix for zkwebui - report fields - drop down field not cleared https://sourceforge.net/projects/adempiere/forums/forum/610547/topic/4450695 --- .../webui/apps/ProcessParameterPanel.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java index ee9a9e55df..99dc9990c0 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java @@ -40,6 +40,7 @@ import org.compiere.apps.IProcessParameter; import org.compiere.model.GridField; import org.compiere.model.GridFieldVO; import org.compiere.model.MClient; +import org.compiere.model.MLookup; import org.compiere.model.MPInstancePara; import org.compiere.process.ProcessInfo; import org.compiere.util.CLogger; @@ -479,9 +480,54 @@ public class ProcessParameterPanel extends Panel implements */ public void valueChange(ValueChangeEvent evt) { + if (evt.getSource() instanceof WEditor) { + GridField changedField = ((WEditor) evt.getSource()).getGridField(); + if (changedField != null) { + processDependencies (changedField); + // future processCallout (changedField); + } + } processNewValue(evt.getNewValue(), evt.getPropertyName()); } + /** + * Evaluate Dependencies + * @param changedField changed field + */ + private void processDependencies (GridField changedField) + { + String columnName = changedField.getColumnName(); + + for (GridField field : m_mFields) { + if (field == null || field == changedField) + continue; + verifyChangedField(field, columnName); + } + for (GridField field : m_mFields2) { + if (field == null || field == changedField) + continue; + verifyChangedField(field, columnName); + } + } // processDependencies + + private void verifyChangedField(GridField field, String columnName) { + ArrayList list = field.getDependentOn(); + if (list.contains(columnName)) { + if (field.getLookup() instanceof MLookup) + { + MLookup mLookup = (MLookup)field.getLookup(); + // if the lookup is dynamic (i.e. contains this columnName as variable) + if (mLookup.getValidation().indexOf("@"+columnName+"@") != -1) + { + log.fine(columnName + " changed - " + + field.getColumnName() + " set to null"); + // invalidate current selection + field.setValue(null, true); + } + } + } + } + private void processNewValue(Object value, String name) { if (value == null) value = new String("");