This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

--Calling a Server Action

Documents for the development of and with JVx.

--Calling a Server Action

Postby Development@SIB » Sun Sep 12, 2010 10:32 am



This article is outdated - please use our new system at

https://doc.sibvisions.com




A server action is a method/function that is defined in a lifecycle object at the server. Execution is initiated either by the client or directly at the server.

In short, it is any method at the business level of the application.

Server Actions are used for functions that are not/should not be executed at the client, including business logic such as mail transmission, interface requests, calculations, etc.


Example

We want to develop an application that manages purchase orders. These orders are provided by SAP via a web services interface and shown in a separate form in our application. In addition, cancellation of individual orders via SAP web services should be possible.

Cancellations are initiated by the Client via a button. The order number, as well as a PIN/confirmation code, are required for execution.

The following are examples of client-side and server-side coding:

Client

Code: Select all
...
...

/** the communication connection to the server. */
private AbstractConnection connection;

/** the orders table. */
private RemoteDataBook rdbOrder = new RemoteDataBook();

/**
 * Initializes the UI.
 */
private void init()
{
    connection = ((MasterConnection)application.getConnection()).
                 createSubConnection("apps.firstapp.frames.Orders");
    connection.open();

    ...
    ...

    rdbOrder.setDataSource(dataSource);
    rdbOrder.setName("orders");
    rdbOrder.open();

    UIButton butStorno = new UIButton("Storno");
    butStorno.eventAction().addListener(this, "doStorno");
}

/**
 * Performs the storno of an order.
 *
 * @throws Throwable if the storno is not possible or the remote system has errors
 */
public void doStorno() throws Throwable
{
    connection.callAction("storno", rdbOrder.getValue("ID"), editPin.getText());
}


The action call occurs in the next line:

Code: Select all
connection.callAction("storno", rdbOrder.getValue("ID"), editPin.getText());

The action storno is called via the server connection connection. The parameter ID and PIN are first entered by the user and passed on to the call.


Server

Code: Select all
package apps.firstapp.frames;

...
...

/**
 * The LCO for the Orders WorkScreen.
 * <p/>
 * @author René Jahn
 */
public class Orders extends Session
{
   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   // User-defined methods
   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   /**
    * Returns the orders storage.
    *
    * @return the orders storage
    * @throws Exception if the initialization throws an error
    */
   public DBStorage getOrders() throws Exception
   {
            ...
   }
   
   /**
    * Performs the storno of an order via SAP webservice.
    *
    * @param pOrderId the order ID
    * @param pPin the storno PIN
    */
   public void storno(BigDecimal pOrderId, String pPin)
   {
      //call SAP webservice with ID and PIN
   }
   
}   // Orders


If exceptions occur during execution they can easily be passed on using the throws clause, since the application independently handles errors.
User avatar
Development@SIB
 
Posts: 325
Joined: Mon Sep 28, 2009 1:54 pm

Return to Documentation