Skip to main content

Notice: This Wiki is now read only and edits are no longer 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/Template"

(Form Field template)
(Replaced content with "The Scout documentation has been moved to https://eclipsescout.github.io/.")
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{ScoutPage|cat=Client}}
+
The Scout documentation has been moved to https://eclipsescout.github.io/.
 
+
A template is some portion of code (a class) that is defined to be used many times in the {{ScoutLink|Concepts|Client Plug-In|Client}}.
+
 
+
== Overview ==
+
The templates are visible in the {{ScoutLink|SDK|Explorer View|Explorer View}} under '''your scout project > Client > Templates'''
+
 
+
[[Image:ScoutExplorer Templates.png]]
+
 
+
== Form Field template ==
+
 
+
An easy way to reuse form field code is to use templates.
+
 
+
Consider the following example: A group box for the billing address containing some fields.
+
    @Order(10.0)
+
    public class BillingAddressBox extends AbstractGroupBox {
+
      @Override
+
      protected String getConfiguredLabel() {
+
        return TEXTS.get("BillingAddress");
+
      }
+
      @Order(10.0)
+
      public class StreetField extends AbstractStringField {
+
        @Override
+
        protected String getConfiguredLabel() {
+
          return TEXTS.get("Street");
+
        }
+
      }
+
      @Order(20.0)
+
      public class CityField extends AbstractSmartField<Long> {
+
        @Override
+
        protected Class<? extends ICodeType<?>> getConfiguredCodeType() {
+
          return CityCodeType.class;
+
        }
+
        @Override
+
        protected String getConfiguredLabel() {
+
          return TEXTS.get("City");
+
        }
+
      }
+
    }
+
 
+
Now let's assume you would like to create a similar box for the correspondence address without copying the code. This is possible by selecting "Create template..." on the group box.
+
 
+
[[Image:Scout_createNewTemplate.jpg]]
+
 
+
[[Image:Scout_createTemplateDialog.jpg]]
+
 
+
A new abstract class is created containing the code of BillingAddressBox.
+
...
+
@FormData(value = AbstractAddressBoxData.class, sdkCommand = SdkCommand.CREATE, defaultSubtypeSdkCommand = DefaultSubtypeSdkCommand.CREATE)
+
public abstract class AbstractAddressBox extends AbstractGroupBox {
+
  @Override
+
  protected String getConfiguredLabel() {
+
    return TEXTS.get("BillingAddress");
+
  }
+
  public CityField getCityField() {
+
    return getFieldByClass(CityField.class);
+
  }
+
...
+
 
+
 
+
 
+
 
+
Now the correspondance address field can be created by choosing the template as type for the new field.
+
 
+
<!--
+
Form
+
In some cases you have the  GroupBox that is displayed in multiple forms, you might be interested in
+
-->
+
 
+
{{note|TODO| {{ScoutLink|Concepts|FormData|FormData}} annotation in the Form.}}
+
 
+
{{note|TODO|Template and SQL binding (in Process Service). Merge with this post: [http://www.eclipse.org/forums/index.php/t/261235/ Process Service and Templates]}}
+
 
+
== See also ==
+
* {{ScoutLink|SDK|Explorer View|Explorer View}}
+

Latest revision as of 04:56, 14 March 2024

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

Back to the top