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/3.8/webservices/Create WsLogForm"

< Scout‎ | Tutorial‎ | 3.8
(Create Company Form)
m (add ScoutPage)
 
(44 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{ScoutPage|cat=Tutorial 3.8}}
 +
 
== Create Ws Log Form ==
 
== Create Ws Log Form ==
On the client node, go to 'Forms'. Right click on the node to create the WsLog {{ScoutLink|Concepts|Form}} [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_1.png]. As the name of the form, enter <code>Company</code> and choose to create the Form ID which is the primary key of the company [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_2.png]. Click next to choose from the artefacts which also should be created by Scout SDK [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_3.png]. Uncheck all permissions as {{ScoutLink|Concepts|Security|Authorization}} is not part of this tutorial.
+
On the client node, go to 'Forms'. Right click on the node to create the WsLog{{ScoutLink|Concepts|Form}} [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_1.png]. As the name of the form, enter <code>Ws Log</code> and choose to create the Form ID which is the primary key of the log entry[http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_2.png]. Click next to choose from the artifacts which also should be created by Scout SDK [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_3.png]. Uncheck all permissions as {{ScoutLink|Concepts|Security|Authorization}} is not part of this tutorial. As the WS log is read-only, also uncheck <code>NewHandler</code>.
 +
 
 +
Because the form does only display read-only data, change the <code>ModifyHandler</code> as follows:
 +
 
 +
<source lang="java">
 +
public class ModifyHandler extends AbstractFormHandler {
 +
 
 +
  @Override
 +
  public void execLoad() throws ProcessingException {
 +
    IWsLogProcessService service = SERVICES.getService(IWsLogProcessService.class);
 +
    WsLogFormData formData = new WsLogFormData();
 +
    exportFormData(formData);
 +
    formData = service.load(formData);
 +
    importFormData(formData);
 +
 
 +
    // disable whole form
 +
    setEnabledGranted(false);
 +
  }
 +
}
 +
</source>
  
 
== Create Form Fields ==
 
== Create Form Fields ==
On the <code>CompanyForm</code> node, go to the 'MainBox'. Right click on the MainBox to create the following 9 Form {{ScoutLink|Concepts|Field}}'s [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_4.png]:
+
On the <code>WsLogForm</code> node, go to the 'MainBox'. Right click on the MainBox to create the following 4 Form {{ScoutLink|Concepts|Field}}'s:
  
  '''NameField'''
+
  '''DateField'''
  Type: String Field [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_5.png]
+
  Type: Date Field
  Name: Name [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_6.png]
+
  Name: Date
  Class name: NameField [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_6.png]
+
  Class name: DateField
  
  '''SymbolField'''
+
  '''ServiceField'''
 
  Type: String Field
 
  Type: String Field
  Name: Symbol
+
  Name: Service
  Class name: SymbolField
+
  Class name: ServiceField
  
  '''TradeTimeField'''
+
  '''PortField'''
  Type: Date Field
+
  Type: String Field
  Name: Trade time
+
  Name: Port
  Class name: TradeTimeField
+
  Class name: PortField
  
  '''ValueLastField'''
+
  '''OperationField'''
  Type: Double Field
+
  Type: String Field
  Name: Value last
+
  Name: Operation
  Class name: ValueLastField
+
  Class name: OperationField
  
'''ValueOpenField'''
+
To display the [http://en.wikipedia.org/wiki/SOAP SOAP message] for request and response, we create a {{ScoutLink|Concepts|TabBox}} that contains the two tabs 'Request' and 'Response', respectively.
Type: Double Field
+
Name: Value open
+
Class name: ValueOpenField
+
  
  '''ValueLowField'''
+
  '''SoapMessageBox'''
  Type: Double Field
+
  Type: Tab Box
  Name: Value low
+
  Name: <leave empty as no label>
  Class name: ValueLowField
+
  Class name: SoapMessageBox
  
'''ValueHighField'''
+
Because the tab box <code>SoapMessageBox</code> should not have a label, go to that node and uncheck the <code>Label Visible</code> property in the 'Advanced Properties' section of the Scout Property View. Next, we will create the two tabs. Therefore, right click on <code>SoapMessageBox</code>[http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_4.png] and create the following two boxes:
Type: Double Field
+
Name: Value high
+
Class name: ValueHighField
+
  
  '''VolumeField'''
+
  '''RequestBox'''
Type: Long Field
+
  Name: Request
  Name: Volume
+
  Class name: RequestBox
  Class name: VolumeField
+
  
  '''ChangeField'''
+
  '''ResponseBox'''
Type: Double Field
+
  Name: Response
  Name: Change
+
  Class name: ResponseBox
  Class name: ChangeField
+
  
Because <code>ChangeField</code> represents a procentual value, click on that field and check the property <code>Percent</code> in Scout Property View [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_7.png].
+
Finally, add two String fields to hold request and response to the boxes.
  
Furthermore, all stock quote specific fields have to be disabled as those fields cannot be modified because data is provided by a webservice. To to so, select all those fields in Scout SDK and uncheck <code>Enabled</code> in Scout Property View [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_11.png].
+
Right click on <code>RequestBox</code> to create the 'Request' String field [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_5.png]:
 +
'''RequestField'''
 +
Type: String Field
 +
Name: <leave empty as no label>
 +
Class name: RequestField
  
As the stock quote symbol can be maximal 5 characters long, this must be constrained on the <code>SymbolField</code> by selecting the field and set the <code>Max Length</code> property in Scout Property View to 5 [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_13.png].
+
Right click on <code>ResponseBox</code> to create the 'Response' String field [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_6.png]:
 +
'''ResponseField'''
 +
Type: String Field
 +
Name: <leave empty as no label>
 +
Class name: ResponseField
  
== Associate CompanyForm with CompanyTablePage ==
+
In both fields, adjust their properties in Scout Property View as following [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_7.png]:
To edit and create companies, you have to add an 'EDIT' and 'NEW' menu to the <code>CompanyTablePage</code>.
+
On client node, go to the node 'Desktop' | 'Outlines' | 'MainOutline' | 'Child Pages' | 'CompanyTablePage' | 'Table' | 'Menus'. Click on the menu node to create the following 2 menus [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_8.png]:
+
  
'''NEW menu [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_9.png]'''
+
* Set <code>Grid H</code> to 5
Name: New company...
+
* Set <code>Grid W</code> to 0 (FULL_WIDTH)
Class Name: NewCompanyMenu
+
* Set <code>Label Visible</code> to false
Super Type: AbstractMenu
+
* Set <code>Max Length</code> to inf (Integer.MAX_VALUE)
Form to start: CompanyForm
+
* Set <code>Multiline Text</code> to true
Form handler: NewHandler
+
* Set <code>Wrap Text</code> to true
 +
 
 +
== Associate WsLogForm with WsLogTablePage ==
 +
To view a log record, you have to add a 'VIEW' menu to the <code>WsLogTablePage</code>.
 +
On client node, go to the node 'Desktop' | 'Outlines' | 'StandardOutline' | 'Child Pages' | 'WsLogTablePage' | 'Table' | 'Menus'. Right-click on the menu node to create the following menu:
  
  '''EDIT menu [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_10.png]'''
+
  '''VIEW menu [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_8.png]'''
  Name: Edit company...
+
  Name: View WS Log...
  Class Name: EditCompanyMenu
+
  Class Name: ViewWsLogMenu
 
  Super Type: AbstractMenu
 
  Super Type: AbstractMenu
  Form to start: CompanyForm
+
  Form to start: WsLogForm
 
  Form handler: ModifyHandler
 
  Form handler: ModifyHandler
  
In the EDIT menu action, we also have to provide the <code>CompanyNr</code> primary key as argument to the <code>CompanyForm</code>. For that reason, double click the <code>EditCompanyMenu</code> to modify the code in <code>execAction()</code> as follows:
+
We also have to provide the <code>WsLogNr</code> primary key as argument to the <code>WsLogForm</code>. For that reason, double click the <code>ViewWsLogMenu</code> to modify the code in <code>execAction()</code> as follows:
  
 
<source lang="java">
 
<source lang="java">
 
@Override
 
@Override
 
protected void execAction() throws ProcessingException {
 
protected void execAction() throws ProcessingException {
   CompanyForm form = new CompanyForm();
+
   WsLogForm form = new WsLogForm();
 
+
       
   // Add the following line to set the primary key of the selected company to the form
+
   // Add the following line to set the primary key of the selected log record to the form
   form.setCompanyNr(getCompanyNrColumn().getSelectedValue());
+
   form.setWSLogNr(getWsLogNrColumn().getSelectedValue());
 
+
       
 
   form.startModify();
 
   form.startModify();
 
   form.waitFor();
 
   form.waitFor();
Line 92: Line 115:
 
</source>
 
</source>
  
== Load and persist company data ==
+
== Load WS Log data ==
Scout SDK already created <code>CompanyProcessService</code> in order to load and persist company data.
+
Scout SDK already created <code>WsLogProcessService</code> in order to load WS log data.
You only have to implement those [http://en.wikipedia.org/wiki/Create,_read,_update_and_delete CRUD] operations:
+
Because we are only reading but not updating log entries, you can remove all operations except <code>load</code>.
  
For that reason, go to the server node and open the <code>CompanyProcessService</code> by double click on 'Process Services' | 'CompanyProcessService'. You will find the following method stubs:
+
Please implement the load-method stub as following:
 
+
  '''prepareCreate'''
+
  Is called by <code>CompanyForm#NewHandler</code> prior to open a non-existing company. This is if a company is to be created to show some default values in the form. It is not used by this tutorial.
+
 
+
  '''create'''
+
  Is called by <code>CompanyForm#NewHandler</code> to create a company record in database
+
 
+
  '''load'''
+
  Is called by <code>CompanyForm#ModifyHandler</code> to load a company record from database
+
 
+
  '''store'''
+
  Is called <code>CompanyForm#ModifyHandler</code> to update a company record in database
+
 
+
Please implement those method stubs as following:
+
  
 
<source lang="java">
 
<source lang="java">
public class CompanyProcessService extends AbstractService implements ICompanyProcessService {
+
public class WsLogProcessService extends AbstractService implements IWsLogProcessService {
  
 
   @Override
 
   @Override
   public CompanyFormData prepareCreate(CompanyFormData formData) throws ProcessingException {
+
   public WsLogFormData load(WsLogFormData formData) throws ProcessingException {
    // nop
+
    return formData;
+
  }
+
 
+
  @Override
+
  public CompanyFormData create(CompanyFormData formData) throws ProcessingException {
+
    formData.setCompanyNr(SQL.getSequenceNextval("GLOBAL_SEQ"));
+
    SQL.insert("" +
+
        "INSERT INTO COMPANY " +
+
        "          (COMPANY_NR, " +
+
        "            NAME, " +
+
        "            SYMBOL) " +
+
        "VALUES    (:companyNr, " +
+
        "            :name, " +
+
        "            :symbol)"
+
        , formData);
+
 
+
    return formData;
+
  }
+
 
+
  @Override
+
  public CompanyFormData load(CompanyFormData formData) throws ProcessingException {
+
 
     SQL.selectInto("" +
 
     SQL.selectInto("" +
         "SELECT NAME, " +
+
         "SELECT EVT_DATE, " +
         "      SYMBOL " +
+
         "      SERVICE, " +
         "FROM  COMPANY " +
+
        "      PORT, " +
         "WHERE  COMPANY_NR = :companyNr " +
+
        "      OPERATION, " +
         "INTO  :name, " +
+
        "      REQUEST, " +
         "      :symbol "
+
        "      RESPONSE " +
 +
         "FROM  WS_LOG " +
 +
         "WHERE  WS_LOG_NR = :wSLogNr " +
 +
         "INTO  :date, " +
 +
        "      :service, " +
 +
        "      :port, " +
 +
        "      :operation, " +
 +
        "      :request, " +
 +
         "      :response"
 
         , formData);
 
         , formData);
 
     return formData;
 
     return formData;
 
   }
 
   }
 
  @Override
 
  public CompanyFormData store(CompanyFormData formData) throws ProcessingException {
 
    SQL.update("" +
 
        "UPDATE  COMPANY " +
 
        "SET      NAME = :name, " +
 
        "        SYMBOL = :symbol " +
 
        "WHERE    COMPANY_NR = :companyNr"
 
        , formData);
 
 
    return formData;
 
  }
 
}
 
 
</source>
 
</source>
  
  
[[Image:org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_1.png|thumb|Create Company Form]]
+
[[Image:org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_1.png|thumb|Create WsLogForm]]
[[Image:org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_2.png|thumb|Create Company Form]]
+
[[Image:org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_2.png|thumb|Create WsLogForm]]
[[Image:org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_3.png|thumb|Create Form artefacts]]
+
[[Image:org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_3.png|thumb|Create WsLogForm artefacts]]
[[Image:org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_4.png|thumb|Create Form Field]]
+
[[Image:org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_4.png|thumb|Create Tab Box]]
[[Image:org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_5.png|thumb|Set datatype for Form Field]]
+
[[Image:org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_5.png|thumb|Create Request tab]]
[[Image:org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_6.png|thumb|Set properties of Form Field]]
+
[[Image:org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_6.png|thumb|Create Response tab]]
[[Image:org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_8.png|thumb|Create menu on CompanyTablePage]]
+
[[Image:org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_7.png|thumb|Update properties of Request / Response fields]]
[[Image:org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_9.png|thumb|Create the NEW menu]]
+
[[Image:org.eclipse.scout.tutorial.jaxws.CreateWsLogForm_8.png|thumb|Create view menu on WsLogTablePage]]
[[Image:org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_10.png|thumb|Create the EDIT menu]]
+
[[Image:org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_11.png|thumb|Disable webservice specific fields]]
+
[[Image:org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_12.png|thumb|Load and persist data in CompanyProcessService]]
+
[[Image:org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_13.png|thumb|Set maxLength to symbol field]]
+

Latest revision as of 02:56, 17 October 2012

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

Create Ws Log Form

On the client node, go to 'Forms'. Right click on the node to create the WsLogThe Scout documentation has been moved to https://eclipsescout.github.io/. [1]. As the name of the form, enter Ws Log and choose to create the Form ID which is the primary key of the log entry[2]. Click next to choose from the artifacts which also should be created by Scout SDK [3]. Uncheck all permissions as The Scout documentation has been moved to https://eclipsescout.github.io/. is not part of this tutorial. As the WS log is read-only, also uncheck NewHandler.

Because the form does only display read-only data, change the ModifyHandler as follows:

public class ModifyHandler extends AbstractFormHandler {
 
  @Override
  public void execLoad() throws ProcessingException {
    IWsLogProcessService service = SERVICES.getService(IWsLogProcessService.class);
    WsLogFormData formData = new WsLogFormData();
    exportFormData(formData);
    formData = service.load(formData);
    importFormData(formData);
 
    // disable whole form 
    setEnabledGranted(false);
  }
}

Create Form Fields

On the WsLogForm node, go to the 'MainBox'. Right click on the MainBox to create the following 4 Form The Scout documentation has been moved to https://eclipsescout.github.io/.'s:

DateField
Type: Date Field
Name: Date
Class name: DateField
ServiceField
Type: String Field
Name: Service
Class name: ServiceField
PortField
Type: String Field
Name: Port
Class name: PortField
OperationField
Type: String Field
Name: Operation
Class name: OperationField

To display the SOAP message for request and response, we create a The Scout documentation has been moved to https://eclipsescout.github.io/. that contains the two tabs 'Request' and 'Response', respectively.

SoapMessageBox
Type: Tab Box
Name: <leave empty as no label>
Class name: SoapMessageBox

Because the tab box SoapMessageBox should not have a label, go to that node and uncheck the Label Visible property in the 'Advanced Properties' section of the Scout Property View. Next, we will create the two tabs. Therefore, right click on SoapMessageBox[4] and create the following two boxes:

RequestBox
Name: Request
Class name: RequestBox
ResponseBox
Name: Response
Class name: ResponseBox

Finally, add two String fields to hold request and response to the boxes.

Right click on RequestBox to create the 'Request' String field [5]:

RequestField
Type: String Field
Name: <leave empty as no label>
Class name: RequestField

Right click on ResponseBox to create the 'Response' String field [6]:

ResponseField
Type: String Field
Name: <leave empty as no label>
Class name: ResponseField

In both fields, adjust their properties in Scout Property View as following [7]:

  • Set Grid H to 5
  • Set Grid W to 0 (FULL_WIDTH)
  • Set Label Visible to false
  • Set Max Length to inf (Integer.MAX_VALUE)
  • Set Multiline Text to true
  • Set Wrap Text to true

Associate WsLogForm with WsLogTablePage

To view a log record, you have to add a 'VIEW' menu to the WsLogTablePage. On client node, go to the node 'Desktop' | 'Outlines' | 'StandardOutline' | 'Child Pages' | 'WsLogTablePage' | 'Table' | 'Menus'. Right-click on the menu node to create the following menu:

VIEW menu [8]
Name: View WS Log...
Class Name: ViewWsLogMenu
Super Type: AbstractMenu
Form to start: WsLogForm
Form handler: ModifyHandler

We also have to provide the WsLogNr primary key as argument to the WsLogForm. For that reason, double click the ViewWsLogMenu to modify the code in execAction() as follows:

@Override
protected void execAction() throws ProcessingException {
  WsLogForm form = new WsLogForm();
 
  // Add the following line to set the primary key of the selected log record to the form
  form.setWSLogNr(getWsLogNrColumn().getSelectedValue());
 
  form.startModify();
  form.waitFor();
  if (form.isFormStored()) {
    reloadPage();
  }
}

Load WS Log data

Scout SDK already created WsLogProcessService in order to load WS log data. Because we are only reading but not updating log entries, you can remove all operations except load.

Please implement the load-method stub as following:

public class WsLogProcessService extends AbstractService implements IWsLogProcessService {
 
  @Override
  public WsLogFormData load(WsLogFormData formData) throws ProcessingException {
    SQL.selectInto("" +
        "SELECT EVT_DATE, " +
        "       SERVICE, " +
        "       PORT, " +
        "       OPERATION, " +
        "       REQUEST, " +
        "       RESPONSE " +
        "FROM   WS_LOG " +
        "WHERE  WS_LOG_NR = :wSLogNr " +
        "INTO   :date, " +
        "       :service, " +
        "       :port, " +
        "       :operation, " +
        "       :request, " +
        "       :response"
        , formData);
    return formData;
  }


Create WsLogForm
Create WsLogForm
Create WsLogForm artefacts
Create Tab Box
Create Request tab
Create Response tab
Update properties of Request / Response fields
Create view menu on WsLogTablePage

Back to the top