Skip to main content

Notice: This Wiki is now read only and edits are no longer 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/3.7/Minicrm/Add a search form"

< Scout‎ | Tutorial‎ | 3.7
(Copy of the section from the Minicrm Tutorial)
 
(Replaced content with "The Scout documentation has been moved to https://eclipsescout.github.io/.")
 
(37 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
+
The Scout documentation has been moved to https://eclipsescout.github.io/.
 
+
Now since we've created a complete TablePage and implemented the service call to get the table data we can easily create a ''SearchForm'' for the ''CompanyTablePage'' using the Scout SDK (otherwise you would have to do that by hand). Go to the ''CompanyTablePage'', right click and choose ''Create Search Form''. The created Search Form will contain a field for each column of the table based on who it is created.<br/>[[Image:Newsearchform.jpg|left]]<br clear="all"/>.For the name enter ''Company''. When you click next, you will see that a ''CompanySearchFormData'' class will be created in the shared plugin. This is the data transfer object corresponding to the new form ''CompanySearchForm'' which will be holding all values entered in the ''CompanySearchForm''.<br/>[[Image:Newsearchformwizard.jpg|left]]<br clear="all"/>The search form that is generated out of our table page is already finished. It is also already set as SearchForm of the ''CompaniesTablePage'' (''getConfiguredSearchForm''). If a search is started, a ''SearchFilter'' is generated out of the SearchForm and is available in the ''execLoadTableData'' method. The Search filter contains the FormData of the SearchForm.
+
 
+
=== Adapt the outline service operation getCompanyTableData ===
+
In order to constrain the SQL statement for the Company Outline we have to adapt the service operation ''getCompanyTableData'' and add a parameter ''searchFilter'' of the type ''CompanySearchFormData'' to the method. Do that for both the service interface and service implementation (''IStandardOutlineService'' and ''StandardOutlineService'').<br/>Now simply change the SQL statement in the following way:<source lang="java">public Object[][] getCompanyTableData(CompanySearchFormData filter) throws ProcessingException {
+
  StringBuilder statement = new StringBuilder();
+
  statement.append(
+
    "SELECT COMPANY_NR, SHORT_NAME, NAME " +
+
    "FROM  COMPANY " +
+
    "WHERE  1=1 ");
+
  if(!StringUtility.isNullOrEmpty(filter.getShortname().getValue())){
+
    statement.append("AND UPPER(SHORT_NAME) LIKE UPPER(:shortname || '%')");
+
  }
+
  if(!StringUtility.isNullOrEmpty(filter.getName().getValue())){
+
    statement.append("AND UPPER(NAME) LIKE UPPER(:name || '%')");
+
  }
+
  return SQL.select(statement.toString(), filter);
+
}</source>
+
You can use ''''':<name of field in formdata>''''' to directly access the FormData object and the values that are held in its inner classes (corresponding to the field on the Form associated to the FormData). You don't need to surround the value by ' as it would have been necessary in a common SQL statement as this is already done by Scout itself.<br/>
+
 
+
Now we need to forward the ''CompanySearchFormData'' to the server. Therefore go to the method ''execLoadTableData'' in the ''CompaniesTablePage'' and add a new parameter to the service call according to its interface definition. The needed ''CompanySearchFormData'' is held in the parameter ''filter'' of type ''SearchFilter'' which is passed to the method ''execLoadTableData''.
+
<source lang="java">return SERVICES.getService(IStandardOutlineService.class).getCompanyTableData((CompanySearchFormData)filter.getFormData());</source>
+

Latest revision as of 07:24, 18 March 2024

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

Back to the top