Difference between revisions of "Scout/Concepts/LookupCall"
(→Input) |
|||
Line 16: | Line 16: | ||
Lookup calls provide different method to compute the set of {{ScoutLink|Concepts|LookupRow|LookupRows}} : | Lookup calls provide different method to compute the set of {{ScoutLink|Concepts|LookupRow|LookupRows}} : | ||
− | * <code>getDataByKey()</code> | + | * <code>getDataByKey()</code>: Retrieves a single lookup row for a specific key value. Used by SmartFields and SmatColumns to get the display text for a given key value. |
− | * <code>getDataByText()</code>: Retrieve multiple lookup rows which match a certain String. Used by SmartFields when the user | + | * <code>getDataByText()</code>: Retrieve multiple lookup rows which match a certain String. Used by SmartFields when the user starts to enter some text in the field. |
− | * <code>getDataByAll()</code>: Retrieves all available lookup rows. Used by SmartFields when the user | + | * <code>getDataByAll()</code>: Retrieves all available lookup rows. Used by SmartFields when the user clicks on the browse icon. |
− | * <code>getDataByRec()</code>: This can only be used for hierarchical lookup calls. It retrieves all available sub-tree lookup rows for a given parent. | + | * <code>getDataByRec()</code>: This can only be used for hierarchical lookup calls. It retrieves all available sub-tree lookup rows for a given parent. |
{{note|TODO|parameters are present to compute the set of rows: Object key, ... Master}} | {{note|TODO|parameters are present to compute the set of rows: Object key, ... Master}} |
Revision as of 09:56, 2 November 2011
Scout |
Wiki Home |
Website |
Download • Git |
Community |
Forums • Blog • Twitter • G+ |
Bugzilla |
Bugzilla |
Lookup calls are mainly used by SmartFields and SmartColumns to look up single or multiple LookupRows.
Contents
Description
The Lookup call mechanism is used to lookup up a set of key-text pairs. Whereas the key can be of any Java type the text must be of the type String. Each entry in this set is called LookupRow. In addition to the key and the text a LookupRow can also define and icon, font, colors and a tooltiptext.
This schema explains the role of a LookupCall in a SmartField:
Input
Lookup calls provide different method to compute the set of LookupRows :
-
getDataByKey()
: Retrieves a single lookup row for a specific key value. Used by SmartFields and SmatColumns to get the display text for a given key value. -
getDataByText()
: Retrieve multiple lookup rows which match a certain String. Used by SmartFields when the user starts to enter some text in the field. -
getDataByAll()
: Retrieves all available lookup rows. Used by SmartFields when the user clicks on the browse icon. -
getDataByRec()
: This can only be used for hierarchical lookup calls. It retrieves all available sub-tree lookup rows for a given parent.
Type of lookup calls
With a Lookup Service
Delegation to the Lookup Service on server side.
They are not necessarily restricted to a fix number of records. Instead they should be favoured if the set of records is rather large.
Directy
Principe of the Local Lookup Calls
An example of this approach is when a SmartField or a SmartColumn is configured to be use with a CodeType. A CodeLookupCall
is instantiated for the CodeType. It creates the LookupRows corresponding to the codes in the CodeType.
Overview
Properties
Defined with getConfiguredXxxxxx() methods.
- Service: Defines which service is used to retrieve lookup rows
- MasterRequired: Defines whether a master value must be set in order to query for multiple lookup rows
Code example
Using a LookupCall in a SmartField
public class ColorSmartField extends AbstractSmartField<String> { // other configuration of properties. @Override protected Class<? extends LookupCall<?>> getConfiguredLookupCall(){ return ColorLookupCall.class; } }
Accessing a LookupRow directly
It is possible to access a LookupRow direclty. In this example the input is a key (thisKey
) and the method getDataByKey()
is used.
Before accessing the text, we ensure that a LookupRow has been retrived.
//Execute the LookupCall (using DataByKey) LookupCall call = new MyLookupCall(); call.setKey(thisKey); LookupRow[] rows=call.getDataByKey(); //Get the text (with a null check) String text = null; if(rows != null && rows.length > 0) { text = rows[0].getText(); }