Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Scout/Concepts/LookupCall"

(Input)
(Replaced content with "{{ScoutPage|cat=Shared}} Moved to new Scout documentation at http://eclipsescout.github.io/6.0/technical-guide.html#lookup-call")
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{ScoutPage|cat=Concepts}}
+
{{ScoutPage|cat=Shared}}
  
Lookup calls are mainly used by {{ScoutLink|Concepts|SmartField|SmartFields}} and {{ScoutLink|Concepts|SmartColumn|SmartColumns}} to look up single or multiple {{ScoutLink|Concepts|LookupRow|LookupRows}}.
+
Moved to new Scout documentation at http://eclipsescout.github.io/6.0/technical-guide.html#lookup-call
 
+
* Class: {{ScoutJavadoc|LookupCall|C}}
+
 
+
== 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:
+
 
+
[[Image:Schema LookupCall.png]]
+
 
+
=== Input ===
+
Lookup calls provide different method to compute the set of {{ScoutLink|Concepts|LookupRow|LookupRows}} :
+
 
+
* <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 starts to enter some text in the field.
+
* <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.
+
 
+
{{note|TODO|parameters are present to compute the set of rows: Object key, ... Master}}
+
 
+
== Type of lookup calls ==
+
===With a Lookup Service===
+
Delegation to the {{ScoutLink|Concepts|Lookup Service|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 {{ScoutLink|Concepts|LocalLookupCall|Local Lookup Calls}}
+
{{note|TODO|Explain and mention the execCreateLookupRows method}}
+
 
+
An example of this approach is when a SmartField or a SmartColumn is configured to be use with a {{ScoutLink|Concepts|CodeType|CodeType}}. A {{ScoutJavadoc|CodeLookupCall|C}} is instantiated for the CodeType. It creates the LookupRows corresponding to the {{ScoutLink|Concepts|Code|codes}}  in the CodeType.
+
 
+
== Overview ==
+
[[Image:LookupCall.png]]
+
 
+
== Properties ==
+
''Defined with {{ScoutLink|Concepts|GetConfigured Methods|getConfiguredXxxxxx()}} methods''.
+
 
+
* {{ScoutProp|Service}}: Defines which service is used to retrieve lookup rows
+
* {{ScoutProp|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 ===
+
<source lang="java">
+
public class ColorSmartField extends AbstractSmartField<String> {
+
  // other configuration of properties.
+
  @Override
+
  protected Class<? extends LookupCall<?>> getConfiguredLookupCall(){
+
    return ColorLookupCall.class;
+
  }
+
}
+
</source>
+
 
+
=== Accessing a LookupRow directly ===
+
It is possible to access a LookupRow direclty. In this example the input is a key (<code>thisKey</code>) and the method <code>getDataByKey()</code> is used.
+
Before accessing the text, we ensure that a LookupRow has been retrived.
+
 
+
<source lang="java">
+
//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();
+
}
+
</source>
+
 
+
== See Also ==
+
* {{ScoutLink|Concepts|LookupRow|Lookup Row}}
+
* {{ScoutLink|Concepts|Lookup Service|Lookup Service}}
+
* {{ScoutLink|Concepts|LocalLookupCall|Local Lookup Calls}}
+
* {{ScoutLink|Concepts|Shared Plug-In|Shared Plug-In}}
+

Revision as of 11:04, 29 June 2016

The Scout documentation has been moved to https://eclipsescout.github.io/.

Moved to new Scout documentation at http://eclipsescout.github.io/6.0/technical-guide.html#lookup-call

Back to the top