Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search

Scout/HowTo/3.8/Open a Form in a View

< Scout‎ | HowTo‎ | 3.8

The Scout documentation has been moved to

When starting a newly created form you will notice that the form is opened in a new window. You may have also noticed that some forms like the "Outline Tree Form" don't open in a new window, instead they are shown inline in the main application window. Those inline forms are referred to as views. In this howto you will learn how to create such views and how to arrange them in the application window.

Changing the display style

In fact it is very easy to open a form in a view instead of a dialog. You only need to change the display style from dialog to view and define the viewId which should be used.

protected int getConfiguredDisplayHint() {
protected String getConfiguredDisplayViewId() {
  return VIEW_ID_CENTER;

This is how it is done for the outline forms like DefaultOutlineTreeForm or the DesktopForm.

Arranging the views

To specify where the view should be placed inside the application window the displayViewId needs to be set. There are several orientations available like North, South, East etc. Try to set one of those values and see what happens.
If you start the swt client and the form is not there although you started it correctly the viewId probably is not mapped. Have a look at the client log to verify that.

!MESSAGE org.eclipse.scout.rt.ui.swt.AbstractSwtEnvironment.showStandaloneForm(null:-1) no view defined for scoutViewId: E

Linking the eclipse views with the scout forms (SWT)

In order to make a form which should be opened in a view visible in the swt client you need to define a mapping between the displayViewId and the actual eclipse view. You will find that mapping in the SwtEnvironment. When creating a new scout application there are several default mappings defined:

registerPart(IForm.VIEW_ID_OUTLINE, OutlineView.class.getName());
registerPart(IForm.VIEW_ID_PAGE_DETAIL, DetailView.class.getName());
registerPart(IForm.VIEW_ID_PAGE_SEARCH, SearchView.class.getName());
registerPart(IForm.VIEW_ID_E, EastView.class.getName());

Only the mapped displayViewIds will work out of the box. To map another IDs simply add a new line with the desired ID and map it to an eclipse view id. The eclipse view id itself needs to be specified in the plugin.xml by using the extension point org.eclipse.ui.views.
Doing this will show up the view but likely in the wrong position.

Arranging the eclipse view (SWT)

It is not sufficient to only create an eclipse view. It is also necessary to specify where the view should be placed. You can do this with the extension point org.eclipse.ui.perspectiveExtensions. Since this is pure eclipse RCP and has nothing to do with Scout it won't be explained in this Howto. As a start you can have a look at the already existing perspective extensions for the built in views.

Opening the views

Basically opening a view is the same as opening a dialog, you only have to open the form with the appropriate form handler. That's it!

Opening the views in exclusive mode

What you need to be aware of is that the user now has the possibility to open the same form multiple times and even the same record. To make sure that modifing the same record does not open two different views but activate the already opened one instead, you need to start the form in exclusive mode and compute an exclusive key. The following code shows how to achieve this:

public class ViewHandler extends AbstractFormHandler {
    protected void execLoad() throws ProcessingException {
      //open form code
    protected boolean getConfiguredOpenExclusive() {
      return true;
  public void startView() throws ProcessingException {
    startInternalExclusive(new DesktopForm.ViewHandler());
  public Object computeExclusiveKey() throws ProcessingException {

The exclusive key (YOUR_EXCLUSIVE_KEY) typically is the primary key of the entity but doesn't have to. With this enhancement opening forms with different exclusive keys leads to multiple views and openening forms with the same exclusive keys leads to only one view.

Setting the property allowMultiple (SWT)

If you would like to start your view multiple times you need to set the property allowMultiple of your ViewPart to true. This makes sure that a secondaryViewId is generated every time you open the view. Otherwise only one instance of the view is possible and opening the form leads to a warning similar to this:

!MESSAGE org.eclipse.scout.rt.ui.swt.window.desktop.view.AbstractScoutView.showForm(null:-1) The view 'ID=org.eclipse.scout.demo.view.ui.swt.views.CenterView' is already open. 
The form 'Center (org.eclipse.scout.demo.view.client.ui.forms.DesktopForm)' can not be opened!

Demo Project

The demo project consists of three views: The main desktop view, a bottom and a right view.

Example View Layout (SWT)


Demo Project

See also

Back to the top