Difference between revisions of "Scout/Tutorial/5.0/HelloWorld"
(Created page with "{{ScoutPage|cat=Tutorial 5.0}} '''Hello World''' This page shows how to create your Hello World app using the {{ScoutLink|SDK|name=Scout SDK}}. We assume that you already have...") |
(→Run the "hello world" application) |
||
(10 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{ScoutPage|cat=Tutorial 5.0}} | {{ScoutPage|cat=Tutorial 5.0}} | ||
− | + | ||
This page shows how to create your Hello World app using the {{ScoutLink|SDK|name=Scout SDK}}. We assume that you already have {{ScoutLink|HowTo/5.0|Install Scout SDK|installed Scout}}. | This page shows how to create your Hello World app using the {{ScoutLink|SDK|name=Scout SDK}}. We assume that you already have {{ScoutLink|HowTo/5.0|Install Scout SDK|installed Scout}}. | ||
Line 7: | Line 7: | ||
[[Image:CreateANewScoutProject.PNG]] | [[Image:CreateANewScoutProject.PNG]] | ||
− | Start your Eclipse with an empty workspace and Use the ''New|Project ...'' menu | + | Start your Eclipse with an empty workspace and Use the ''File | New | Project ...'' menu. |
[[Image:CreateANewScoutProject2.PNG]] | [[Image:CreateANewScoutProject2.PNG]] | ||
− | In the wizard choose Scout project and click ''Next'' | + | In the wizard choose Scout project and click ''Next''. |
− | [[Image: | + | [[Image:CreateANewScoutProject3_5.PNG]] |
− | Enter org.eclipse.scout.helloworld as an application name. The last part of the name (after the last period) will automatically be used as the project alias. Then | + | Enter org.eclipse.scout.helloworld as an application name. The last part of the name (after the last period) will automatically be used as the project alias. |
+ | For more details about the new project creation see the corresponding HowTo: {{ScoutLink|HowTo/5.0|Create_a_new_project}}. Then click ''Next''. | ||
[[Image:CreateANewScoutProject4.PNG]] | [[Image:CreateANewScoutProject4.PNG]] | ||
− | Select ''Application with a single form'' as your app template, then click ''Finish'' | + | Select ''Application with a single form'' as your app template, then click ''Finish''. |
[[Image:CreateANewScoutProject5.PNG]] | [[Image:CreateANewScoutProject5.PNG]] | ||
− | The empty application is created by {{ScoutLink|SDK|name=Scout SDK}} and if you are not already in the {{ScoutLink|SDK|Perspective|Scout perspective}} you are prompted to | + | The empty application is created by {{ScoutLink|SDK|name=Scout SDK}} and if you are not already in the {{ScoutLink|SDK|Perspective|Scout perspective}} you are prompted to switch now. Click on ''Yes''. |
==Run the Empty Scout Application in the Scout SDK == | ==Run the Empty Scout Application in the Scout SDK == | ||
Line 38: | Line 39: | ||
==Client Side: Add a Message Field to the Desktop Form == | ==Client Side: Add a Message Field to the Desktop Form == | ||
− | [[Image:Scout- | + | [[Image:Scout-NewFormField5 hello world.PNG]] |
In the {{ScoutLink|SDK|Explorer_View|Scout Explorer}} drill down to client, Forms, DesktopForm, MainBox | In the {{ScoutLink|SDK|Explorer_View|Scout Explorer}} drill down to client, Forms, DesktopForm, MainBox | ||
Line 62: | Line 63: | ||
* '''default''' The translation for the default language (usually English). More languages and text translations may be added any time (see [[Scout/Concepts/NLS-Support]]) | * '''default''' The translation for the default language (usually English). More languages and text translations may be added any time (see [[Scout/Concepts/NLS-Support]]) | ||
− | Then click ''OK'' | + | Then click ''OK''. Confirm by clicking ''Finish'' |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | Confirm by clicking ''Finish'' | + | |
− | [[Image:Scout-NewFormField6.PNG]] | + | [[Image:Scout-NewFormField6 helloworld.PNG]] |
Navigate down from the ''MainBox'' to the newly created ''MessageField''. Double click on the MessageField node to display the generated code (selected code in screenshot above) in the Java editor window. | Navigate down from the ''MainBox'' to the newly created ''MessageField''. Double click on the MessageField node to display the generated code (selected code in screenshot above) in the Java editor window. | ||
Line 82: | Line 77: | ||
Add a simple implementation for the ''load'' method: | Add a simple implementation for the ''load'' method: | ||
− | <source lang="java | + | <source lang="java"> |
− | public DesktopFormData load(DesktopFormData formData) { | + | @Override |
+ | public DesktopFormData load(DesktopFormData formData) throws ProcessingException { | ||
formData.getMessage().setValue("hello world"); | formData.getMessage().setValue("hello world"); | ||
return formData; | return formData; | ||
} | } | ||
</source> | </source> | ||
− | |||
− | On line | + | On the third line we access the message field of the {{ScoutLink|Concepts|FormData|FormData}} and set its value to <code>"hello world"</code>. The updated form data is returned and finally sent back to the client. |
==Run the "hello world" application == | ==Run the "hello world" application == | ||
Line 96: | Line 91: | ||
In the {{ScoutLink|SDK|Explorer_View|Scout Explorer}} go back to top-level node ''Scout Projects'', then click on ''org.eclipse.scout.helloworld'' to access the launch boxes in the Scout Object Properties. | In the {{ScoutLink|SDK|Explorer_View|Scout Explorer}} go back to top-level node ''Scout Projects'', then click on ''org.eclipse.scout.helloworld'' to access the launch boxes in the Scout Object Properties. | ||
* Start the server in the server box | * Start the server in the server box | ||
− | * Start the client in the SWT box | + | * Start the client in the SWT and/or Swing box |
And, "Ta Taa" | And, "Ta Taa" | ||
[[Image:Scout-Helloworld1.PNG]] | [[Image:Scout-Helloworld1.PNG]] |
Latest revision as of 13:08, 29 January 2015
Scout |
Wiki Home |
Website |
Download • Git |
Community |
Forums • Blog • Twitter • G+ |
Bugzilla |
Bugzilla |
This page shows how to create your Hello World app using the Scout SDK. We assume that you already have installed Scout.
Contents
Create a new Scout Project
Start your Eclipse with an empty workspace and Use the File | New | Project ... menu.
In the wizard choose Scout project and click Next.
Enter org.eclipse.scout.helloworld as an application name. The last part of the name (after the last period) will automatically be used as the project alias. For more details about the new project creation see the corresponding HowTo: Create_a_new_project. Then click Next.
Select Application with a single form as your app template, then click Finish.
The empty application is created by Scout SDK and if you are not already in the Scout perspective you are prompted to switch now. Click on Yes.
Run the Empty Scout Application in the Scout SDK
In the Scout Explorer open the node Scout Projects, then click on org.eclipse.scout.helloworld. This will show the Scout Object Properties for the application.
After starting first the server (1) and then the Swing client (2) from the launching boxes as shown below, the empty client will appear.
Client Side: Add a Message Field to the Desktop Form
In the Scout Explorer drill down to client, Forms, DesktopForm, MainBox
- client client part of Scout application
- Forms holding all Forms available in the client part
- DesktopForm the form created by the template chosen above: Application with a single form
- MainBox the container (a GroupBox) holding all UI components of the form
To the main box we will add a message field. Click right on MainBox and choose the menu New Form Field.
Step 1: Select field type. Here we'll use a String Field. Then click Next (you may directly click on it or use the search box as shown above)
Step 2: Add the field label, type "Message" that triggers the dropdown list. Choose New translated text... (or use an existing text)
Step 3: Fill in the default translation. Some other fields are automatically filled:
- Key Name used to retrieve the translated text in the code
- default The translation for the default language (usually English). More languages and text translations may be added any time (see Scout/Concepts/NLS-Support)
Then click OK. Confirm by clicking Finish
Navigate down from the MainBox to the newly created MessageField. Double click on the MessageField node to display the generated code (selected code in screenshot above) in the Java editor window.
Server Side: Implement the Data Loading
In the Scout Explorer navigate to the server node, then Services, and DesktopService. The DesktopService is the server side service corresponding to the DesktopForm defined on the client side. This process service was created as part of the selected application template. The load(DesktopFormData) method is defined out of the box.
Add a simple implementation for the load method:
@Override public DesktopFormData load(DesktopFormData formData) throws ProcessingException { formData.getMessage().setValue("hello world"); return formData; }
On the third line we access the message field of the FormData and set its value to "hello world"
. The updated form data is returned and finally sent back to the client.
Run the "hello world" application
In the Scout Explorer go back to top-level node Scout Projects, then click on org.eclipse.scout.helloworld to access the launch boxes in the Scout Object Properties.
- Start the server in the server box
- Start the client in the SWT and/or Swing box
And, "Ta Taa"