8.5.3  Enabling Server-Side Update for a Dashboard

To force a Viewsheet to refresh its data at a specified interval, simply select the 'Server-Side Update' option in the 'Viewsheet Options' dialog box. (See Setting Viewsheet Options in Dashboard Design for more details.)

You can further customize the update behavior by configuring the Viewsheet to refresh in response to a particular external event. For example, your database can issue a refresh command to a Viewsheet in response to a database event such as a data update.

To customize server-side update, follow the steps below:

1. Add the following line into the sree.properties file:

assetMonitor.enabled=true

2. Start the Style Intelligence server, and open Enterprise Manager.

3. In Enterprise Manager, open the 'Server' page under the 'Log' node (on the Server tab). Verify that the following lines (or equiva­lent) appear in the log:

Start RMI registry at: 1099

Rebind RMI Call thread.

DataChange server bound in RMI registry.

This indicates that the DataChange server (responsible for server-side updates) is correctly running.

4. If you do not see the above output in the log, this may indicate a port conflict. In this case, set the dataChange.rmi.port property in sree.properties to a different port number.

5. Open the desired Viewsheet in Visual Composer. Open the 'Views­heet Options' dialog box, and select the 'Server-Side Update' option. (See Setting Viewsheet Options in Dashboard Design.) In the 'Refresh Interval' field, enter the period (in seconds) at which the server should check for the external trigger event.

6. Create a DataChangeClient class that can be executed by an exter­nal program (for example, by the database) to trigger a particular Viewsheet to update. An example of such a class is shown below:

import java.rmi.*;

import inetsoft.report.composition.AssetMonitor;

import inetsoft.uql.asset.AssetRepository;

 

public class DataChangeClient {

  public DataChangeClient(String usr, String pwd, int scope, String vs, String rmi) {

    this.usr = usr;

    this.pwd = pwd;

    this.scope = scope;

    this.vs = vs;

    this.rmi = rmi;

  }

  private boolean dataChange() {

    AssetMonitor engine = null;

    try {

      engine = (AssetMonitor) Naming.lookup(rmi);

    }

    catch(Exception e) {

      System.err.println("Can't find the rmi server at: " + rmi);

      e.printStackTrace();

      return false;

    }

    String ticket = null;

    try {

      ticket = engine.login(usr, pwd);

    }

    catch(RemoteException e) {

      System.err.println("Login failed with " + usr + "/" + pwd);

      e.printStackTrace();

      return false;

    }

    try {

      engine.dataChanged(vs, scope, usr, ticket);

    }

    catch(RemoteException e) {

      System.err.println("fire data change failed");

      e.printStackTrace();

      return false;

    }

    try {

      engine.logout(ticket);

    }

    catch(RemoteException e) {

    }

    return true;

  }

  public static void main(String[] args) {

    if(args.length != 5) {

      System.err.println("Usage: java DataChangeClient usr pwd scope viewsheetPath rmi");

      System.err.println("@param user: the usr for login");

      System.err.println("@param pwd: the password of the user");

      System.err.println("@param scope: 1 - global scope, other - user scope");

      System.err.println("@param viewsheetPath: the path of the viewsheet");

      System.err.println("@param rmi: the rmi data change server url");

      System.exit(0);

    }

    int scope = AssetRepository.USER_SCOPE;

    if("1".equals(args[2])) {

      scope = AssetRepository.GLOBAL_SCOPE;

    }

    new DataChangeClient(args[0], args[1], scope, args[3], args[4]).dataChange();

  }

  private String usr, pwd, vs, rmi;

  private int scope;

}

7. Compile the DataChangeClient class. (The classpath should include the Style Intelligence server files, bisuite.jar and etools.jar.)

8. Execute the DataChangeClient class to update the desired Views­heet. For example:

java DataChangeClient admin admin 1 ViewsheetName "rmi://localhost:1099/DataChangeServer"

This will update the specified Viewsheet after the interval specified by the 'Refresh delay' field in the 'Viewsheet Options' dialog box.

Example: Custom Server-Side Update  >>

In the following example, you will create a Viewsheet that receives its data from an embedded Table in a Data Worksheet. You will then configure the Viewsheet to automatically update when the DataChangeClient is triggered.

Before beginning the example, compile the DataChangeClient class as described previously. Then follow the steps below:

1. Add the following line into the sree.properties file:

assetMonitor.enabled=true

2. Create a new Data Worksheet, and add the following Embedded Table. (See Creating an Embedded Table in Data Mashup for detailed instructions.)

 

3. Right-click the 'col1' header, and select 'Column Type' from the context menu. This opens the 'Column Type' dialog box.

4. Select 'Double' from the 'Type' menu, and click 'OK'.

5. Save the Worksheet with the name 'EmbeddedData'. (See Saving a Data Worksheet in Data Mashup.)

6. Create a new Viewsheet based on the 'EmbeddedData' Worksheet. (See Quick Start: Creating a Viewsheet in Dashboard Design.)

7. Add a Chart to the Viewsheet to display the data from the Work­sheet as follows. (See Creating a Chart in Dashboard Design.)

 

8. Click the 'Options' button in the Viewsheet toolbar. This opens the 'Viewsheet Options' dialog box.

9. In the 'Deployment' panel at the bottom, enable the 'Server-Side Update' option, and set the 'Refresh Interval' to 10 seconds.

 

10. Click 'OK' to close the dialog box.

11. Save the Viewsheet with the name 'UserDashboard'. (See Saving a Viewsheet in Dashboard Design.)

12. Launch the User Portal, and open the 'UserDashboard' Viewsheet in the Portal.

 

13. Return to the 'EmbeddedData' Worksheet in Visual Composer.

14. Make some changes to the data in the Embedded table, and click the 'Save' button.

 

15. Return to the User Portal. (Do not reload the Viewsheet.) Note that the Viewsheet remains the same, even though the underlying data has changed.

16. Trigger an automatic Viewsheet update by running the DataChange­Client class from the command line:

java DataChangeClient admin admin 1 UserDashboard "rmi://localhost:1099/DataChangeServer"

17. Return to the User Portal. (Do not reload the Viewsheet.) Observe that the Viewsheet updates automatically after the specified delay.

 

<< 8.5.2 Creating a Dashboard © 1996-2013 InetSoft Technology Corporation (v11.5) 8.5.4 Editing or Deleting a Dashboard >>