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 Ws Log Form)
(Associate CompanyForm with CompanyTablePage)
Line 82: Line 82:
 
* Set <code>Wrap Text</code> to true
 
* Set <code>Wrap Text</code> to true
  
== Associate CompanyForm with CompanyTablePage ==
+
== Associate WsLogForm with WsLogTablePage ==
To edit and create companies, you have to add an 'EDIT' and 'NEW' menu to the <code>CompanyTablePage</code>.
+
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' | '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]:
+
On client node, go to the node 'Desktop' | 'Outlines' | 'MainOutline' | 'Child Pages' | 'WsLogTablePage' | 'Table' | 'Menus'. Right-click on the menu node to create the following menu:
  
  '''NEW menu [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_9.png]'''
+
  '''VIEW menu [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_10.png]'''
  Name: New company...
+
  Name: View WS Log...
  Class Name: NewCompanyMenu
+
  Class Name: ViewWsLogMenu
 
  Super Type: AbstractMenu
 
  Super Type: AbstractMenu
  Form to start: CompanyForm
+
  Form to start: WsLogForm
Form handler: NewHandler
+
 
+
'''EDIT menu [http://wiki.eclipse.org/Image:Org.eclipse.scout.tutorial.jaxws.CreateCompanyForm_10.png]'''
+
Name: Edit company...
+
Class Name: EditCompanyMenu
+
Super Type: AbstractMenu
+
Form to start: CompanyForm
+
 
  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:
+
Also, 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">

Revision as of 19:04, 8 November 2011

Create Ws Log Form

On the client node, go to 'Forms'. Right click on the node to create the WsLog The Scout documentation has been moved to https://eclipsescout.github.io/. [1]. As the name of the form, enter WsLog and choose to create the Form ID which is the primary key of the log entry[2]. Click next to choose from the artefacts 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 to tabs: 'Request' and 'Response'.

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 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
Name: <leave empty as no label>
Class name: StringField

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

ResponseField
Name: <leave empty as no label>
Class name: StringField

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' | 'MainOutline' | '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

Also, 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 {
  CompanyForm form = new CompanyForm();
 
  // Add the following line to set the primary key of the selected company to the form
  form.setCompanyNr(getCompanyNrColumn().getSelectedValue());
 
  form.startModify();
  form.waitFor();
  if (form.isFormStored()) {
    reloadPage();
  }
}

Load and persist company data

Scout SDK already created CompanyProcessService in order to load and persist company data. You only have to implement those CRUD operations:

For that reason, go to the server node and open the CompanyProcessService by double click on 'Process Services' | 'CompanyProcessService'. You will find the following method stubs:

 prepareCreate
 Is called by CompanyForm#NewHandler 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 CompanyForm#NewHandler to create a company record in database
 load
 Is called by CompanyForm#ModifyHandler to load a company record from database
 store
 Is called CompanyForm#ModifyHandler to update a company record in database

Please implement those method stubs as following:

public class CompanyProcessService extends AbstractService implements ICompanyProcessService {
 
  @Override
  public CompanyFormData prepareCreate(CompanyFormData 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("" +
        "SELECT NAME, " +
        "       SYMBOL " +
        "FROM   COMPANY " +
        "WHERE  COMPANY_NR = :companyNr " +
        "INTO   :name, " +
        "       :symbol "
        , 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;
  }
}


Create Company Form
Create Company Form
Create Form artefacts
Create Form Field
Set datatype for Form Field
Set properties of Form Field
Set properties of Form Field
Create menu on CompanyTablePage
File:Org.eclipse.scout.tutorial.jaxws.CreateWsLogForm 12.png
Load and persist data in CompanyProcessService

Back to the top