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/Tutorial/4.0/Minicrm/Write the second page

< Scout‎ | Tutorial‎ | 4.0‎ | Minicrm

The Scout documentation has been moved to

Scout Tutorial
This page belongs to the Minicrm Step-by-Step Tutorial. It explains how create your second page in your project and use it as a child page for your first page. You need to have an existing table page in order to continue.

We already have a page for companies. Quickly create a second top-level page for persons. Then reuse the same page as child page for the existing company page.

A new table page

Here are some notes to guide you:

Add getPersonTableData to the StandardOutlineService (in the class in the server with the corresponding declaration in the shared interface):

public PersonTablePageData getPersonTableData() throws ProcessingException {
  PersonTablePageData pageData = new PersonTablePageData();
  SQL.selectInto("" +
      "       LAST_NAME," +
      "       FIRST_NAME" +
      " FROM  PERSON" +
      " INTO :{page.personNr}, :{page.lastName}, :{page.firstName}",
      new NVPair("page", pageData));
  return pageData;


If you edited StandardOutlineService manually, make sure to add getPersonTableData to the interface IStandardOutlineService as well.

getPersonTableData doesn't need a parameter, unless you want to create a PersonSearchForm as well; you don't need to do this for the tutorial, but it might be an excellent excercise

Add a New Page... to Child Pages of the StandardOutline; it uses the AbstractPageWithTable template, has the name Person and the type name PersonTablePage. To place the person page into the same package as the company page, enter ui.desktop.outlines.pages into the field Sub Package.

This is how the StandardOutline has two child pages, now:

protected void execCreateChildPages(List<IPage> pageList) throws ProcessingException {
  CompanyTablePage companyTablePage = new CompanyTablePage();
  PersonTablePage personTablePage = new PersonTablePage();

This is how the PersonTablePage loads data from the outline service:

protected void execLoadData(SearchFilter filter) throws ProcessingException {

Add the following columns to the table inside the PersonTablePage:

Table Column Template Name Type Name Note
Long Column (empty) PersonNrColumn not displayable, primary key
String Column Last Name LastNameColumn width 200
String Column First Name FirstNameColumn width 200

Scout.3.9.minicrm.second page.client swt.png

Using a table page as a child page to another page

Return to the CompanyTablePage, click through to Child Page, and pick Add Existing Page... (we don't need to create a new page because we want to reuse the person table page), and pick PersonTablePage.

If you test your application now, you will see the complete list of people under every single company. What you're missing is a way to pass the currently selected company to the SQL statement selecting the persons.

This is what we want, basically:

  1. when the child page is created using execCreateChildPage, the value of the CompanyNrColumn acting as the parent is copied into a variable on the PersonTablePage
  2. the PersonTablePage uses the variable as an argument in its call to getPersonTableData on the standard outline service (this requires a change to the service implementation and to the service interface)
  3. getPersonTableData will then use the variable in its WHERE clause in order to select the appropriate persons

First, return to the PersonTablePage, click through to Variables, and pick New Property Bean... from the context menu. Use CompanyNr for the Name and use Long for the Bean Type.

Scout.3.9.minicrm.second property

Scout.3.9.minicrm.second property bean.wizard.png

Scout.3.9.minicrm.second property bean.explorer.png

But how do we set it? We need to set the CompanyNr when the person table page is being created by its parent. Return to the CompanyTablePage and click on the Exec Create Child Page link in the Properties view. Change it as follows:

Scout.4.0.minicrm.second page.exec create child page.png

protected IPage execCreateChildPage(ITableRow row) throws ProcessingException {
  PersonTablePage childPage = new PersonTablePage();
  return childPage;

Notice how we get to use the row argument.

So now, as the person table page instance is created, it "knows" what its company is. It's stored in the CompanyNr variable. Now all we need to do is pass this number on to the outline service.

Go to the PersonTablePage and click on Exec Load Table Data in the Properties view. Change its definition as follows:

protected void execLoadData(SearchFilter filter) throws ProcessingException {

You'll note that this produces an error because the outline service is not yet ready to accept an extra parameter!

Scout.3.9.minicrm.second page.standard outline service.png

Return to the StandardOutlineService and click on IStandardOutlineService to change the interface for getPersonTableData as follows:

public PersonTablePageData getPersonTableData(Long companyNr) throws ProcessingException;

Now go to the StandardOutlineService and change its definition of getPersonTableData as follows:

PersonTablePageData getPersonTableData(Long companyNr) throws ProcessingException {
  PersonTablePageData pageData = new PersonTablePageData();
  if (companyNr == null || companyNr == 0) {"SELECT PERSON_NR, LAST_NAME, FIRST_NAME FROM PERSON INTO :{page.personNr}, :{page.lastName}, :{page.firstName}", new NVPair("page", pageData));
  } else {"" +
        " FROM PERSON WHERE COMPANY_NR = :companyNr" +
        " INTO :{page.personNr}, :{page.lastName}, :{page.firstName}",
        new NVPair("companyNr", companyNr), new NVPair("page", pageData));
  return pageData;


Notice how we used NVPair (org.eclipse.scout.commons.holders.NVPair) to match a bind variable with a variable value. When we wrote our first form we just used the form data object to provide the bind variables, relying on the naming conventions. Here, we can no longer do that and need to be explicit about it.

Test it. Make sure you restart the server since you changed the services.

Scout.3.9.minicrm.second page.child page.client swt.png

Back to the top