--How to use Client Actions
1 post
• Page 1 of 1
--How to use Client Actions
This article is outdated - please use our new system at
https://doc.sibvisions.com
Client actions are defined as methods/functions that are automatically called at the client at a predetermined time, such as the click of a button, a switch between lines in a table, the insertion of a table, etc.
The action concept is based on Java´s listener concept and simplifies listener handling.
In JVx, the methods/functions used to define actions begin with event (e.g. eventAction). This facilitates the search for possible actions in javadoc and with IDE.
Usage
The definition of an action can be accomplished in two different ways. First, through the combination of object and method name:
- Code: Select all
/**
* Initializes the UI components.
*/
private void init()
{
UIButton butCancel = new UIButton();
butCancel.setText("Cancel");
butCancel.eventAction().addListener(this, "doCancel");
}
/**
*
*
public void doCancel()
{
dispose();
}
The following line
- Code: Select all
butCancel.eventAction().addListener(this, "doCancel");
defines that the method doCancel in the object this is executed upon clicking the cancel button.
In this example, the method
- Code: Select all
public void doCancel()
is defined without parameters and without a throws clause, since there are no respective requirements. However, the method could also be defined as follows:
- Code: Select all
public void doCancel(UIActionEvent pEvent) throws Exception
The paramater will only be passed on by JVx if it is included in the parameter description. If the throws clause is used, exceptions are caught by JVx and sent to the error dialogue. However, if specific error handling is required, a try/catch block has to be used and the throws clause has to be removed.
Since our action concept is based on the Java listener concept, it is also possible to use listeners:
- Code: Select all
butCancel.eventAction().addListener(new IActionListener()
{
public void action(UIActionEvent pActionEvent)
{
dispose();
}
});
or
- Code: Select all
public class MyFrame implements IActionListener
{
public void action(UIActionEvent pActionEvent)
}
-
Development@SIB - Posts: 325
- Joined: Mon Sep 28, 2009 1:54 pm
1 post
• Page 1 of 1