Skip to content

Latest commit

 

History

History
52 lines (42 loc) · 3.07 KB

HelloWorldBackend.adoc

File metadata and controls

52 lines (42 loc) · 3.07 KB

The responsibility of the Scout server in our “Hello World” application is to provide an initial text content for the message field in the client’s user interface. We implement this behaviour in the load method of the server’s DesktopService. An empty stub for the load method of the DesktopService service has already been created during the initial project creation step.

To navigate to the implementation of the desktop service in the Scout SDK, we first expand the blue top-level server node in the Scout Explorer. Below the server node, we then expand the Services folder which shows the DesktopService element. Expanding this DesktopService node, the load method becomes visible as shown in Figure showing Server node.

sdk server desktopservice load
Figure 1. The Scout Explorer showing the blue server node expanded with the Services folder. In this folder the load method of DesktopService is selected and its initial implementation is shown in the editor on the right side.

The DesktopService represents the server service corresponding to the DesktopForm on the client side. This initial setup represents Scout’s default where client forms and server services typically come in pairs. Whenever the client’s user interface displays a form to the user, the client connects to the server and calls the load method of the corresponding server service. We just need to add our business logic to the load method of the server’s DesktopService.

According to the signature of the load method, a formData object is passed into this method that is then handed back in the return statement. To complete the implementation of the load method it is sufficient to assign the text 'hello world!' to the message field part of the form data. The complete implementation of the load method is provided in Listing load() implementation.

load() implementation in the DesktopService.
@Override
public DesktopFormData load(DesktopFormData formData)
  throws ProcessingException {
    formData.getMessage().setValue("Hello World!"); (1)
    return formData;
}
  1. assign a value to the value holder part of the FormData corresponding to the message field

With this last element we have completed the Scout “Hello World” application.