Error in context when Key field is found in different tabs.

https://sourceforge.net/tracker/index.php?func=detail&aid=2910358&group_id=176962&atid=879332
Error in context when IsActive field is found in different
https://sourceforge.net/tracker/?func=detail&aid=2910368&group_id=176962&atid=879332

kind regards
Victor Perez
www.e-evolution.com
This commit is contained in:
vpj-cd 2009-12-08 01:06:37 +00:00
parent bd92365e04
commit bdf3c8a5ef
3 changed files with 99 additions and 14 deletions

View File

@ -59,15 +59,22 @@ import org.compiere.util.Evaluator;
* @author Teo Sarca, teo.sarca@gmail.com * @author Teo Sarca, teo.sarca@gmail.com
* <li>BF [ 2874646 ] GridField issue when a lookup is key * <li>BF [ 2874646 ] GridField issue when a lookup is key
* https://sourceforge.net/tracker/?func=detail&aid=2874646&group_id=176962&atid=879332 * https://sourceforge.net/tracker/?func=detail&aid=2874646&group_id=176962&atid=879332
* @author victor.perez@e-evolution.com,www.e-evolution.com
* <li>BF [ 2910358 ] Error in context when a field is found in different tabs.
* https://sourceforge.net/tracker/?func=detail&aid=2910358&group_id=176962&atid=879332
* <li>BF [ 2910368 ] Error in context when IsActive field is found in different
* https://sourceforge.net/tracker/?func=detail&aid=2910368&group_id=176962&atid=879332
* @version $Id: GridField.java,v 1.5 2006/07/30 00:51:02 jjanke Exp $ * @version $Id: GridField.java,v 1.5 2006/07/30 00:51:02 jjanke Exp $
*/ */
public class GridField public class GridField
implements Serializable, Evaluatee implements Serializable, Evaluatee
{ {
/** /**
* *
*/ */
private static final long serialVersionUID = 1783359481690560938L; private static final long serialVersionUID = 1124123543602986028L;
/** /**
* Field Constructor. * Field Constructor.
@ -416,8 +423,9 @@ public class GridField
return false; return false;
} }
//BF [ 2910368 ]
// Always editable if Active // Always editable if Active
if (checkContext && "Y".equals(Env.getContext(m_vo.ctx, m_vo.WindowNo, "IsActive")) if (checkContext && "Y".equals(Env.getContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, "IsActive"))
&& ( m_vo.ColumnName.equals("Processing") && ( m_vo.ColumnName.equals("Processing")
|| m_vo.ColumnName.equals("PaymentRule") || m_vo.ColumnName.equals("PaymentRule")
|| m_vo.ColumnName.equals("DocAction") || m_vo.ColumnName.equals("DocAction")
@ -433,9 +441,9 @@ public class GridField
// IsActive field is editable, if record not processed // IsActive field is editable, if record not processed
if (m_vo.ColumnName.equals("IsActive")) if (m_vo.ColumnName.equals("IsActive"))
return true; return true;
// BF [ 2910368 ]
// Record is not Active // Record is not Active
if (checkContext && !Env.getContext(m_vo.ctx, m_vo.WindowNo, "IsActive").equals("Y")) if (checkContext && !Env.getContext(m_vo.ctx, m_vo.WindowNo,m_vo.TabNo, "IsActive").equals("Y"))
return false; return false;
// ultimately visibility decides // ultimately visibility decides
@ -1284,9 +1292,14 @@ public class GridField
{ {
backupValue(); // teo_sarca [ 1699826 ] backupValue(); // teo_sarca [ 1699826 ]
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName,
((Boolean)newValue).booleanValue()); ((Boolean)newValue).booleanValue());
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName, Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName,
m_value==null ? null : (((Boolean)m_value) ? "Y" : "N")); m_value==null ? null : (((Boolean)m_value) ? "Y" : "N"));
//BF [ 2910368 ]
if(m_vo.ColumnName.equals("IsActive"))
{
Env.setContext(m_vo.ctx, m_vo.WindowNo,m_vo.TabNo, m_vo.ColumnName, ((Boolean)newValue).booleanValue() ? "Y" : "N");
}
} }
else if (newValue instanceof Timestamp) else if (newValue instanceof Timestamp)
{ {
@ -1300,8 +1313,12 @@ public class GridField
backupValue(); // teo_sarca [ 1699826 ] backupValue(); // teo_sarca [ 1699826 ]
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName,
m_value==null ? null : m_value.toString()); m_value==null ? null : m_value.toString());
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName, //BF [ 2910358 ]
m_value==null ? null : m_value.toString()); if(isKey())
{
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName,
m_value==null ? null : m_value.toString());
}
} }
// Does not fire, if same value // Does not fire, if same value

View File

@ -84,7 +84,12 @@ import org.compiere.util.ValueNamePair;
* https://sourceforge.net/tracker/?func=detail&aid=2874109&group_id=176962&atid=879332 * https://sourceforge.net/tracker/?func=detail&aid=2874109&group_id=176962&atid=879332
* <li>BF [ 2905287 ] GridTab query is not build correctly * <li>BF [ 2905287 ] GridTab query is not build correctly
* https://sourceforge.net/tracker/?func=detail&aid=2905287&group_id=176962&atid=879332 * https://sourceforge.net/tracker/?func=detail&aid=2905287&group_id=176962&atid=879332
* @author Victor Perez , e-Evolution.SC [1877902] Implement JSR 223 Scripting APIs to Callout * @author Victor Perez , e-Evolution.SC
* <li>FR [1877902] Implement JSR 223 Scripting APIs to Callout
* <li>BF [ 2910358 ] Error in context when a field is found in different tabs.
* https://sourceforge.net/tracker/?func=detail&aid=2910358&group_id=176962&atid=879332
* <li>BF [ 2910368 ] Error in context when IsActive field is found in different
* https://sourceforge.net/tracker/?func=detail&aid=2910368&group_id=176962&atid=879332
* @author Carlos Ruiz, qss FR [1877902] * @author Carlos Ruiz, qss FR [1877902]
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1877902&group_id=176962 to FR [1877902] * @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1877902&group_id=176962 to FR [1877902]
* @author Cristina Ghita, www.arhipac.ro FR [2870645] Set null value for an ID * @author Cristina Ghita, www.arhipac.ro FR [2870645] Set null value for an ID
@ -94,6 +99,7 @@ import org.compiere.util.ValueNamePair;
*/ */
public class GridTab implements DataStatusListener, Evaluatee, Serializable public class GridTab implements DataStatusListener, Evaluatee, Serializable
{ {
/** /**
* *
*/ */
@ -619,10 +625,16 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
} }
else else
{ {
String value = Env.getContext(m_vo.ctx, m_vo.WindowNo, lc, true); //BF [ 2910358 ]
//String value = Env.getContext(m_vo.ctx, m_vo.WindowNo, lc, true);
String value = Env.getContext(m_vo.ctx, m_vo.WindowNo, this.getParentTabNo(),lc);
//BF [ 2910358 ]
// explicit parent link defined // explicit parent link defined
if ( m_parentColumnName.length() > 0 ) if ( m_parentColumnName.length() > 0 )
value = Env.getContext(m_vo.ctx, m_vo.WindowNo, m_parentColumnName, true); {
// value = Env.getContext(m_vo.ctx, m_vo.WindowNo, m_parentColumnName, true);
value = Env.getContext(m_vo.ctx, m_vo.WindowNo, this.getParentTabNo(),m_parentColumnName);
}
// Same link value? // Same link value?
if (refresh) if (refresh)
@ -3027,4 +3039,24 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
} }
return list; return list;
} }
//BF [ 2910358 ]
/**
* get Parent Tab No
* @return Tab No
*/
private int getParentTabNo()
{
int tabNo = m_vo.TabNo;
int currentLevel = Env.getContextAsInt(m_vo.ctx, m_vo.WindowNo, tabNo, GridTab.CTX_TabLevel);
int parentLevel = currentLevel-1;
if (parentLevel < 0)
return tabNo;
while (parentLevel != currentLevel)
{
tabNo--;
currentLevel = Env.getContextAsInt(m_vo.ctx, m_vo.WindowNo, tabNo, GridTab.CTX_TabLevel);
}
return tabNo;
}
} // GridTab } // GridTab

View File

@ -73,14 +73,21 @@ import org.compiere.util.ValueNamePair;
* <li>BF [ 1943682 ] Copy Record should not copy IsApproved and IsGenerated * <li>BF [ 1943682 ] Copy Record should not copy IsApproved and IsGenerated
* <li>BF [ 1949543 ] Window freeze if there is a severe exception * <li>BF [ 1949543 ] Window freeze if there is a severe exception
* <li>BF [ 1984310 ] GridTable.getClientOrg() doesn't work for AD_Client/AD_Org * <li>BF [ 1984310 ] GridTable.getClientOrg() doesn't work for AD_Client/AD_Org
* @author victor.perez@e-evolution.com,www.e-evolution.com
* <li>BF [ 2910358 ] Error in context when a field is found in different tabs.
* https://sourceforge.net/tracker/?func=detail&aid=2910358&group_id=176962&atid=879332
* <li>BF [ 2910368 ] Error in context when IsActive field is found in different
* https://sourceforge.net/tracker/?func=detail&aid=2910368&group_id=176962&atid=879332
*/ */
public class GridTable extends AbstractTableModel public class GridTable extends AbstractTableModel
implements Serializable implements Serializable
{ {
/** /**
* *
*/ */
private static final long serialVersionUID = 4071601543088224064L; private static final long serialVersionUID = 4273775926021737068L;
/** /**
* JDBC Based Buffered Table * JDBC Based Buffered Table
@ -115,6 +122,8 @@ public class GridTable extends AbstractTableModel
private boolean m_withAccessControl; private boolean m_withAccessControl;
private boolean m_readOnly = true; private boolean m_readOnly = true;
private boolean m_deleteable = true; private boolean m_deleteable = true;
public static final String CTX_KeyColumnName = "KeyColumnName";
// //
/** Rowcount */ /** Rowcount */
@ -291,8 +300,16 @@ public class GridTable extends AbstractTableModel
select.append(" FROM ").append(m_tableName); select.append(" FROM ").append(m_tableName);
m_SQL_Select = select.toString(); m_SQL_Select = select.toString();
m_SQL_Count = "SELECT COUNT(*) FROM " + m_tableName; m_SQL_Count = "SELECT COUNT(*) FROM " + m_tableName;
// //BF [ 2910358 ]
//Restore the Original Value for Key Column Name based in Tab Context Value
String parentKey = Env.getContext(m_ctx, m_WindowNo, getParentTabNo(), CTX_KeyColumnName);
String valueKey = Env.getContext(m_ctx, m_WindowNo, getParentTabNo(), parentKey);
if(valueKey != null && valueKey.length() > 0)
{
Env.setContext(m_ctx, m_WindowNo, parentKey, valueKey);
}
StringBuffer where = new StringBuffer(""); StringBuffer where = new StringBuffer("");
// WHERE // WHERE
if (m_whereClause.length() > 0) if (m_whereClause.length() > 0)
@ -3227,4 +3244,23 @@ public class GridTable extends AbstractTableModel
// @TODO: configurable aggressive - compare each column with the DB // @TODO: configurable aggressive - compare each column with the DB
return false; return false;
} }
/**
* get Parent Tab No
* @return Tab No
*/
private int getParentTabNo()
{
int tabNo = m_TabNo;
int currentLevel = Env.getContextAsInt(m_ctx, m_WindowNo, tabNo, GridTab.CTX_TabLevel);
int parentLevel = currentLevel-1;
if (parentLevel < 0)
return tabNo;
while (parentLevel != currentLevel)
{
tabNo--;
currentLevel = Env.getContextAsInt(m_ctx, m_WindowNo, tabNo, GridTab.CTX_TabLevel);
}
return tabNo;
}
} }