From 206dcfc075635005e5db057a2d405cdd44d8162c Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 16 Dec 2009 02:37:50 +0000 Subject: [PATCH] BF [2910358] - Error in context when Key field is found in different tabs. https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2910358&group_id=176962 Latest changes broke windows where first tab has no parent key (like "Unposted Documents") --- base/src/org/compiere/model/GridTable.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/base/src/org/compiere/model/GridTable.java b/base/src/org/compiere/model/GridTable.java index 85f2e5f6a0..59bbc13169 100644 --- a/base/src/org/compiere/model/GridTable.java +++ b/base/src/org/compiere/model/GridTable.java @@ -326,12 +326,18 @@ public class GridTable extends AbstractTableModel //Restore the Original Value for Key Column Name based in Tab Context Value int parentTabNo = getParentTabNo(); String parentKey = Env.getContext(m_ctx, m_WindowNo, parentTabNo, GridTab.CTX_KeyColumnName, true); - String valueKey = Env.getContext(m_ctx, m_WindowNo, parentTabNo, parentKey, true); - String currKey = Env.getContext(m_ctx, m_WindowNo, parentKey); - if (valueKey != null && valueKey.length() > 0 && parentKey != null && parentKey.length() > 0 && ! currKey.equals(valueKey)) - { - Env.setContext(m_ctx, m_WindowNo, parentKey, valueKey); - } + String valueKey = null; + String currKey = null; + if (parentKey != null && parentKey.length() > 0) { + valueKey = Env.getContext(m_ctx, m_WindowNo, parentTabNo, parentKey, true); + currKey = Env.getContext(m_ctx, m_WindowNo, parentKey); + if (currKey == null) + currKey = new String(""); + if (valueKey != null && valueKey.length() > 0 && parentKey != null && parentKey.length() > 0 && ! currKey.equals(valueKey)) + { + Env.setContext(m_ctx, m_WindowNo, parentKey, valueKey); + } + } StringBuffer where = new StringBuffer(""); // WHERE