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/Reorganize the tree and add a webservice"

(Make it available to Scout)
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{note|Scout Tutorial|This page belongs to the {{ScoutLink|Tutorial|Minicrm Step-by-Step|Minicrm Step-by-Step Tutorial}}. It explains how reorganize the little application consisting of two pages such that you can add a webservice. You need that little {{ScoutLink|Tutorial|Write The Second Page|two page application}} in order to continue.}}
+
The Scout documentation has been moved to https://eclipsescout.github.io/.
 
+
We started out with an application having two table pages. Notice how the list of persons comes just beneath the list of companies. If we want to show different named folders such as "persons" and "search resuilts" for a company, we need to add a '''page with nodes'''.
+
 
+
{|
+
|
+
  Standard Outline
+
  │
+
  ├─Company Table Page
+
  │  │
+
  │  └─Person Table Page
+
  │
+
  └─Person Table Page
+
|⇒
+
|
+
  Standard Outline
+
  │
+
  ├─Company Table Page
+
  │  │
+
  │  └─Company Details Node Page ← new
+
  │    │
+
  │    ├─Person Table Page
+
  │    │
+
  │    └─Bing Table Page ← new
+
  │
+
  └─Person Table Page
+
|}
+
 
+
== Add a node page ==
+
 
+
In a first step, we're going to aim for the following intermediary structure:
+
 
+
  Standard Outline
+
  │
+
  ├─Company Table Page
+
  │  │
+
  │  └─Company Details Node Page ← new
+
  │    │
+
  │    └─Person Table Page
+
  │
+
  └─Person Table Page
+
 
+
Return to the '''CompanyTablePage''' and click on the red cross (<span style="color:red">✖</span>) next to '''Exec Create Child Page''' in order to delete it.
+
 
+
[[Image:Delete Create Child Page Method in Scout Minicrm.png]]
+
 
+
Once you have deleted the method, you can right-click on the '''Child Page''' folder and pick '''New Page...'''
+
 
+
Use '''AbstractTableWithNodes''' as your template. There's ''no need to give it a name''. Use '''CompanyDetailsNodePage''' as the ''type name''.
+
 
+
{{note|No name?|Indeed, this particular ''node page'' does not need a name. That's because the ''name'' of a ''page'' is only shown if its parent is an ''outline'' or a ''page with nodes''. If the parent is a ''page with table'', '''the selected row replaces the name of the child table'''.}}
+
 
+
Now go to the newly created '''CompanyDetailsNodePage''', click through to the '''Child Pages''' folder, right-click and pick '''Add Page...''' Pick the '''PersonTablePage''' from the list and click ''Finish''.
+
 
+
{{note|Child Page or Child Pages?|Note how there is ''only child page'' for a '''page with table''' where as there are ''multiple child pages'' for a ''page with nodes''.}}
+
 
+
== Fix data flow ==
+
 
+
If you attempt to test your application, you'll notice a problem: '''Every person is listed under every company'''!
+
 
+
Why is that?
+
 
+
We interrupted "the flow data": When the user picks a company from the ''CompanyTablePage'', the appropriate child page is created. When we created {{ScoutLink|Tutorial|Write The Second Page|our second page}}, we made sure to pass the '''value''' of the ''CompanyNrColumn'' along. The newly introduced ''CompanyDetailsNodePage'' needs to be fixed!
+
 
+
Return to the '''CompanyDetailsNodePage''' and click through to '''Variables'''. Pick '''Create New Property Bean...''' from the context menu, use '''companyNr''' as the ''name'' and '''Long''' as the ''bean type''.
+
 
+
Click on the '''Exec Create Child Pages''' link on the ''Properties'' view of the '''CompanyDetailsNodePage'''. Change the code as follows:
+
 
+
<source lang="java">
+
@Override
+
protected void execCreateChildPages(Collection<IPage> pageList) throws ProcessingException {
+
PersonTablePage personTablePage = new PersonTablePage();
+
  personTablePage.setCompanyNr(getCompanyNr());
+
  pageList.add(personTablePage);
+
 
+
}
+
</source>
+
 
+
Return to the '''CompanyTablePage''' and click on the '''Exec Create Child Page''' link on the ''Properties'' view. Change the code as follows:
+
 
+
<source lang="java">
+
@Override
+
protected IPage execCreateChildPage(ITableRow row) throws ProcessingException {
+
  CompanyDetailsNodePage childPage=new CompanyDetailsNodePage();
+
  childPage.setCompanyNr(getTable().getCompanyNrColumn().getValue(row));
+
  return childPage;
+
}
+
</source>
+
 
+
We reached our goal! This is the new structure, now:
+
 
+
  Standard Outline
+
  │
+
  ├─Company Table Page
+
  │  │
+
  │  └─Company Details Node Page
+
  │    │
+
  │    └─Person Table Page
+
  │
+
  └─Person Table Page
+
 
+
Let's review how the data flows back and forth:
+
 
+
# CompanyTablePage calls execLoadTableData
+
# execLoadTableData calls the getCompanyTableData method on the StandardOutlineService
+
# StandardOutlineService returns tabular data including the primary key for every row
+
# user picks a company and clicks through
+
# the CompanyDetailsNodePage is created by execCreateChildPage; the value of the current CompanyNrColumn is copied to the node page's companyNr variable
+
# the user picks Persons and clicks through
+
# the PersonTablePage is created by execCreateChildPages; the value of the companyNr variable is copied to the table page's companyNr variable
+
# PersonTablePage calls execLoadTableData
+
# execLoadTableData calls the getPersonTableData method on the StandardOutlineService
+
# StandardOutlineService determines that the companyNr is not null, runs a SELECT statement that only selects appropriate persons from the database and returns tabular data
+
 
+
== Create Axis web service consumers ==
+
 
+
We need to create a '''web service consumer'''. We will use [http://www.bing.com/ Bing] as an example web service. See [http://www.bing.com/developers/ their developers page] for more information.
+
 
+
On the server side, right-click on '''Axis Web Service Consumers''' and pick '''New Webservice consumer…''' from the context menu. Paste
+
<code>http://api.search.live.net/search.wsdl?AppID=F1DFAE1859C73D8B105D99A78F0B027B62C64814</code>
+
into the ''WSDL URL'' field and click ''OK''.
+
 
+
Accept the import of all the generated classes.
+
 
+
{{warning|Troubleshooting|If we can access the WSDL in the browser, but receive a //Connection timed out// exception using the Scout SDK, we need to save the WSDL file locally and provide the generator with a '''file URL''' to the WSDL (e.g. <code>file:///C:/Users/bornn/Desktop/search.wsdl</code>). This problem arise because Eclipse does not necessarily share the browser's proxy settings.}}
+
 
+
Later, when '''deploying''' the application, we need to provide the proxy settings in the server's '''config.ini''' file:
+
 
+
  -Dhttp.proxyHost=proxy.example.com
+
  -Dhttp.proxyPort=3128
+
  -Dhttp.nonProxyHosts="localhost"
+
  -Dhttp.proxyUser=johndoe
+
  -Dhttp.proxyPassword=*****
+
 
+
== Make it available to Scout ==
+
 
+
We need to add a method to the ''StandardOutlineService'' which will use the classes we just created.
+
 
+
Return to the '''StandardOutlineService''' and pick '''New Service Operation...''' from the context menu. Use '''getLiveSearchTableData''' as the ''name'', '''Object[][]''' as the ''return type'', '''query''' as the first argument's ''name'', and '''String''' as it's ''type''.
+
 
+
[[Image:Scout New Service Operation.png]]
+
 
+
Use the following implementation:
+
 
+
<source lang="java">
+
public Object[][] getLiveSearchTableData(String query) throws ProcessingException {
+
  // use the ID from the URL
+
  String appId = "F1DFAE1859C73D8B105D99A78F0B027B62C64814";
+
  LiveSearchServiceLocator soapClient = new LiveSearchServiceLocator();
+
  SearchRequest request = new SearchRequest();
+
  request.setAppId(appId);
+
  request.setQuery(query);
+
  SourceType[] sources = {SourceType.Web};
+
  request.setSources(sources);
+
  SearchResponse response;
+
  try {
+
    //no idea why the indirection via SearchRequestType1
+
    //and SearchResponseType0 is necessary
+
    response = soapClient.getLiveSearchPort().search(new SearchRequestType1(request)).getParameters();
+
  }
+
  catch (Exception e) {
+
    throw new ProcessingException(e.getMessage(), e);
+
  }
+
  WebResult[] result = response.getWeb().getResults();
+
  Object[][] data = new Object[result.length][3];
+
  for (int row = 0; row < data.length; row++) {
+
    data[row][0] = result[row].getUrl();
+
    data[row][1] = result[row].getTitle();
+
    data[row][2] = result[row].getDescription();
+
  }
+
  return data;
+
}
+
</source>
+

Latest revision as of 06:22, 19 March 2024

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

Back to the top