IDEMPIERE-377 Improve current search dialog box. Fixed can't search using invisible lookup field ( for e.g, CreatedBy and UpdatedBy ).

This commit is contained in:
Heng Sin Low 2012-10-23 06:48:06 +08:00
parent b0b209ce89
commit afb50f10e0
3 changed files with 46 additions and 21 deletions

View File

@ -178,9 +178,7 @@ public class GridField
m_vo.lookupInfo.DisplayType = DisplayType.Search; m_vo.lookupInfo.DisplayType = DisplayType.Search;
} }
// //
m_vo.lookupInfo.IsKey = isKey(); loadLookupNoValidate();
MLookup ml = new MLookup (m_vo.lookupInfo, m_vo.TabNo);
m_lookup = ml;
} }
else if (m_vo.displayType == DisplayType.Location) // not cached else if (m_vo.displayType == DisplayType.Location) // not cached
{ {
@ -209,6 +207,21 @@ public class GridField
} }
} // m_lookup } // m_lookup
/***
* bypass isdisplay validation, used by findwindow
*/
public void loadLookupNoValidate() {
if (m_vo.lookupInfo == null) {
m_vo.loadLookupInfo();
}
if (m_vo.lookupInfo == null) {
return;
}
m_vo.lookupInfo.IsKey = isKey();
MLookup ml = new MLookup (m_vo.lookupInfo, m_vo.TabNo);
m_lookup = ml;
}
/** /**
* Wait until Load is complete * Wait until Load is complete
*/ */

View File

@ -582,24 +582,32 @@ public class GridFieldVO implements Serializable
// Create Lookup, if not ID // Create Lookup, if not ID
if (DisplayType.isLookup(displayType) && IsDisplayed) if (DisplayType.isLookup(displayType) && IsDisplayed)
{ {
try loadLookupInfo();
{
lookupInfo = MLookupFactory.getLookupInfo (ctx, WindowNo, AD_Column_ID, displayType,
Env.getLanguage(ctx), ColumnName, AD_Reference_Value_ID,
IsParent, ValidationCode);
if (lookupInfo == null)
displayType = DisplayType.ID;
else
lookupInfo.InfoFactoryClass = this.InfoFactoryClass;
}
catch (Exception e) // Cannot create Lookup
{
CLogger.get().log(Level.SEVERE, "No LookupInfo for " + ColumnName, e);
displayType = DisplayType.ID;
}
} }
} // initFinish } // initFinish
/**
* load lookup info.
* used by findwindow to loadlookupinfo for invisible field
*/
public void loadLookupInfo() {
try
{
lookupInfo = MLookupFactory.getLookupInfo (ctx, WindowNo, AD_Column_ID, displayType,
Env.getLanguage(ctx), ColumnName, AD_Reference_Value_ID,
IsParent, ValidationCode);
if (lookupInfo == null)
displayType = DisplayType.ID;
else
lookupInfo.InfoFactoryClass = this.InfoFactoryClass;
}
catch (Exception e) // Cannot create Lookup
{
CLogger.get().log(Level.SEVERE, "No LookupInfo for " + ColumnName, e);
displayType = DisplayType.ID;
}
}
/** /**
* Clone Field. * Clone Field.
* @param Ctx ctx * @param Ctx ctx

View File

@ -1626,7 +1626,11 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
} }
else else
{ {
editor = WebEditorFactory.getEditor(field, true); //lookupinfo is null for invisible field
if (DisplayType.isLookup(field.getDisplayType()) && field.getLookup() == null) {
field.loadLookupNoValidate();
}
editor = WebEditorFactory.getEditor(field, true);
} }
if (editor == null) if (editor == null)
editor = new WStringEditor(field); editor = new WStringEditor(field);
@ -1634,8 +1638,8 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
field.addPropertyChangeListener(editor); field.addPropertyChangeListener(editor);
editor.addValueChangeListener(this); editor.addValueChangeListener(this);
editor.setValue(null); editor.setValue(null);
editor.setReadWrite(enabled); editor.setReadWrite(true);
editor.setVisible(enabled); editor.setVisible(true);
editor.dynamicDisplay(); editor.dynamicDisplay();
// //
return editor.getComponent(); return editor.getComponent();