HowTo make a Mail-Client/Server-Application with Eclipse Scout

With this HowTo you'll get a short overview how easy it is, to create a simple client/server application. The server will connect to your imap-server and send the responses to your client. It's nothing fancy but it'll work ;-)

In the Scout-Perspective

Create a scout project

Ctrl-N for a new Project.

In the wizard choose Scout->Scout Project

Choose a Project Name, Postfix and Alias.

Project Name: com.example.mail

Project Postfix: core

Project Alias: (automaticly set to mailCore)

We just want to make a swt application, so we uncheck com.example.mail.ui.swing.core and com.example.mail.ui.rap.core .

Click "Next" to go to the application template selection page

Select "Outline Tree and Table Form" as application template. Otherwise you can search hours why the Imap Folders are read but never displayed :-))

Click to "Finish" and wait a moment for the generation of the projects.Now you have 4 projects with some source to start with.

Change the perspective to "Scout".

Make your project JavaMail aware

Download JavaMail from Oracle and put it into the endorsed directory of the JRE used by Eclipse IDE. It can be downloaded from http://www.oracle.com/technetwork/java/index-138643.html. Afterwards, in order to make use of its contained classes, you have to adapt the build path of your Eclipse projects. In the build properties, you can find a tab 'JRE System library'. Click the node 'Access rules' and add a new entry with the pattern 'javax/**' and visibility 'Accessible'.

Note: This change in build path is only required for development time to compile sources referring to classes in endorsed directory. When installing the product, those Jars are either already included in the application container or must be added manually to the respective endorsed directory. Please refere to the documentation of the application server in use.

With Ctrl-Shift-O you can resolve some imports. The missing Classes you can ignore for now. You'll create them in a moment.

Create a form

Right-Click on the folder "Forms" -> "New Form..."

Name: MailUncheck "Create form ID" the other fields you can leave the default values --> Next

Now you could drag'n'drop the permissions and services if you had more than one module. In this example you have just one module (core) so you can just uncheck classes you don't need.Uncheck the handlers (you'll create an other in a moment) and the permissions (you don't need permissions in this example) -> Finish

In the "Scout Object Properties"-view change "Display Hint" to "View" and "Display View Id" to "Center"

Right-Click on Variables -> "New Property Bean..."

Name: "folderId" / Bean Type: String -> Finish

Right-Click on the MainBox under the MailForm -> "New Form Field..."

In this dialog you get a list of common used Fields. For this example you start with an "uncommon" field. So click on the checkbox at the bottom "show all fields" and enter or search "AbstractSplitBox". -> Next

Name: emptyType Name: SplitBoxField -> Finish

Click on the newly created SplitBoxField.

In the "Scout Object Properties"-view uncheck "Split Horizontal" and change the "Splitter Position" to 0.3.

Right-Click on the SplitBoxField -> "New Form Field..."

Choose the "Table Field" -> Next

Name: emptyType Name: MailTableField -> Finish

Right-Click on the SplitBoxField -> "New Form Field..."

Click on the checkbox at the bottom "show all fields" and enter or search "AbstractHtmlField". -> Next

Name: emptyType Name: MailField -> Finish

Open the MailTableField folder and the Table folder with a click on the "+".

Open the plugin.xml of the project com.example.mail.server.core, remove the filter "BasicSecurityFilter" from the extension point "org.eclipse.scout.http.servletfilter.filters" and add following filter:

<filteraliases="/process"class="com.example.mail.server.core.ImapSecurityFilter"ranking="10"><init-paramname="host"value="&lt;define in config.ini&gt;"></init-param></filter>

Open the mailCore-server-dev.product, add "javax.mail.jre16" to the dependencies and Launch this product.

Open the mailCore-swt-client-dev.product, add "javax.mail.jre16" to the dependencies and Launch this product.