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/Tutorial/3.7/Minicrm/Code Types"

< Scout‎ | Tutorial‎ | 3.7
(Replaced content with "The Scout documentation has been moved to https://eclipsescout.github.io/.")
 
(13 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{ScoutPage|cat=Tutorial}}
+
The Scout documentation has been moved to https://eclipsescout.github.io/.
{{note|Scout Tutorial|This page belongs to the {{ScoutLink|Tutorial|Minicrm Step-by-Step|Minicrm Step-by-Step Tutorial}}. It explains how to add and use Code Types. You need to finish at least step {{ScoutLink|Tutorial|Add a form|Add a form}} in order to continue.}}
+
 
+
== How to create Code Types ==
+
Code Types always contain of an ID and a list of values.
+
 
+
Open the shared node in Eclipse Scout and expand the tree until you reach the Enumerations node. Right-click on the node and choose "New Codetype…" menu.
+
 
+
[[Image:Scout new company type codetype.jpg]]
+
 
+
The Code ID needs to be an unique number, which helps to identify the values belonging to the Code Type.
+
 
+
Always leave enough space between the Code Type's IDs, because the Code Type's values need IDs as well.
+
 
+
Idea is that the IDs of Code Types and their values are close together (e.g. Code Type 10000 and Values from 10001 to 10099, next Code Type 10100).
+
 
+
Enter the information into the Code Type form according to the picture:
+
 
+
[[Image:Scout company type codetype form.jpg]]
+
 
+
Right-click on the newly created Code Type and choose New Code…
+
 
+
[[Image:Scout company type codetype new childcode.jpg]]
+
 
+
Increase the CompanyType Code Type's ID by 1 and assign it to the Code ID field. Give it a name like Customer.
+
 
+
Repeat these last two steps for another code called Supplier (Code ID: 10002).
+
 
+
[[Image:Scout company type codetype new childcode form.jpg]]
+
 
+
 
+
== How to use Code Types ==
+
 
+
So let's use the code type inside the Company Form: we are going to add a Radio Button Group containing those two values.
+
 
+
In a Radio Button Group only one item can be selected at a time. This is exactly what we need here, as we don't like a company being both, customer and supplier.
+
 
+
Back in Scout Explorer we expand the tree like: client > Forms > CompanyForm and right-click on MainBox to choose New Form Field…
+
 
+
Choose Radio Button Group as Type, give it a name like CompanyType and press Finish.
+
 
+
[[Image:Scout company type codetype new radiobutton group.jpg]]
+
 
+
In the properties editor go to the property Code Type and choose the Code Type CompanyTypeCodeType we have previously created. That’s all we need to do to fill the Code Type's values into the Radio Button Group.
+
 
+
[[Image:Scout company type codetype radiobutton group add codetype.jpg]]
+
 
+
After adding this additional field, don't forget to update the form data: right-click on the CompanyForm and choose "Update Form Data"
+
 
+
 
+
To write and read the values provided by the Radio Button from the database, we need to adjust the
+
CompanyProcessService:
+
 
+
 
+
<source lang="java">
+
public CompanyFormData create(CompanyFormData formData) throws ProcessingException {
+
    if (!ACCESS.check(new CreateCompanyPermission())) {
+
      throw new VetoException(Texts.get("AuthorizationFailed"));
+
    }
+
    SQL.selectInto("" +
+
        "SELECT MAX(COMPANY_NR)+1 " +
+
        "FROM  COMPANY " +
+
        "INTO  :companyNr"
+
        , formData);
+
    SQL.insert("" +
+
        "INSERT INTO COMPANY (COMPANY_NR, SHORT_NAME, NAME, TYPE_UID) " +
+
        "VALUES (:companyNr, :shortName, :name, :companyTypeGroup)"
+
        , formData);
+
    return formData;
+
  }
+
 
+
  public CompanyFormData load(CompanyFormData formData) throws ProcessingException {
+
    if (!ACCESS.check(new ReadCompanyPermission())) {
+
      throw new VetoException(Texts.get("AuthorizationFailed"));
+
    }
+
    SQL.selectInto("" +
+
        "SELECT SHORT_NAME, " +
+
        "      NAME," +
+
        "      TYPE_UID " +
+
        "FROM  COMPANY " +
+
        "WHERE  COMPANY_NR = :companyNr " +
+
        "INTO  :shortName," +
+
        "      :name, " +
+
        "      :companyTypeGroup"
+
          , formData);
+
    return formData;
+
  }
+
 
+
  public CompanyFormData store(CompanyFormData formData) throws ProcessingException {
+
    if (!ACCESS.check(new UpdateCompanyPermission())) {
+
      throw new VetoException(Texts.get("AuthorizationFailed"));
+
    }
+
    SQL.update("" +
+
        "UPDATE COMPANY " +
+
        " SET SHORT_NAME = :shortName, " +
+
        "    NAME = :name, " +
+
        "    TYPE_UID = :companyTypeGroup " +
+
        "WHERE  COMPANY_NR = :companyNr "
+
        , formData);
+
 
+
    return formData;
+
  }
+
</source>
+
 
+
 
+
 
+
 
+
 
+
 
+
[[Image:Scout company rating codetype overview.jpg]]
+
[[Image:Scout company rating codetype smartcolumn.jpg]]
+
[[Image:Scout company rating codetype smartfield master.jpg]]
+
[[Image:Scout company rating new smartfield.jpg]]
+
 
+
[[Image:Scout company type rating codetype table.jpg]]
+

Latest revision as of 07:24, 18 March 2024

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

Back to the top