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/Template"

m (Category changed)
(Form Field template)
Line 9: Line 9:
  
 
== Form Field template ==
 
== Form Field template ==
{{note|TODO|Explain and example. Description of the class. Some Code}}
+
 
 +
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.
 +
 
 +
A new abstract class is created containing the code of BillingAddressBox.
 +
 
 +
Now the correspondance address field can be created by choosing the template as type for the new field.
  
 
<!--
 
<!--

Revision as of 12:51, 28 March 2012

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 The Scout documentation has been moved to https://eclipsescout.github.io/..

Overview

The templates are visible in the The Scout documentation has been moved to https://eclipsescout.github.io/. under your scout project > Client > Templates

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.

A new abstract class is created containing the code of BillingAddressBox.

Now the correspondance address field can be created by choosing the template as type for the new field.


Note.png
TODO
The Scout documentation has been moved to https://eclipsescout.github.io/. annotation in the Form.


Note.png
TODO
Template and SQL binding (in Process Service). Merge with this post: Process Service and Templates


See also

Back to the top