Resources

SAS® AppDev Studio 3.0 Developer's Site

Adding User-Defined Actions to the Multidimensional Table Model

The MultidimensionalTable model (a Java class) retrieves its pop-up actions from the underlying SAS/EIS multidimensional model. If user-defined actions have been added to a SAS/EIS application via model overrides or to a subclass of the EMDDB_M class, these actions will automatically be included in the MultidimensionalTable model. Likewise, actions removed from the list will not be included.

Actions can be removed through the SAS/EIS Application Screen Builder object by selecting the Advanced button and then the Actions button. A dual list box control displays all actions so that you can remove any unwanted actions.

To add an action, some code is required. If the action to be added is specific to one EIS application, you can use the SAS/EIS Application Screen Builder object to override the _SET_APPLICATION_ method and add the necessary code. Select the Advanced button and then the Methods button. You must add the code in a model method for it to be picked up by the thin client (that is, either webAF or webEIS).

If the actions to be added will be used with many applications, it is better to create a subclass of the SASHELP.EIS.EMDDB_M class that can be used with any application that requires the additional actions. The subclass should add the actions in an override of the _SET_APPLICATION_ method. For more information on creating and using EMDDB_M subclasses, see the webEIS example Overriding a Method.

The EMDDB_M subclass can be utilized in two ways. Individual SAS/EIS applications can have the subclass specified as the SAS/EIS application's model class. This is done by selecting the Advanced button and changing the model class name to the subclass. The subclass can also be associated with a particular datasource. This allows more generic uses of the subclass. This is accomplished by adding the MODEL attribute to the datasource's SAS/EIS repository registration. The value of this attribute is the four-level catalog entry name of the subclass.

If the action added is to be used with both the thick client (SAS/EIS) and the thin client (webEIS or webAF), it is best to follow the SAS/EIS documentation for adding actions. Note however, that the code must be added to the model and not the viewer. Again, the _SET_APPLICATION_ method of the model is recommended.

For applications running on the thin client, a convenience method, _addAction, has been added to the EMDDB_M model to facilitate adding actions. This method adds the information to the appropriate lists for you hiding the implementation details. To avoid a program halt when the code is run in SAS/EIS, it is recommend that the _HAS_METHOD_ method be called on the object before calling _addAction. Note, however, that the action will not be added when run in SAS/EIS. If you have your own subclass of EMDDB_M you can add a method similar to _addAction. In this way, the method will be present for both the thin client and for SAS/EIS.

_addAction Method Syntax

Here is the syntax for the _addAction method:

_addAction(actionName, actionLabel, methodName, <pos>)
actionName
is a unique character string identifier. This is used to identify the action leaving the label translatable for internationalization. Traditionally, SAS/EIS uses CL_<actionName> to identify its actions (for example, CL_DRILL for Drilldown). To avoid potential conflicts it is recommended that if you use a prefix select something other than CL_.
actionLabel
is the text displayed in the pop-up menu. The text is assumed to be in its internationalized form. Callers of this method should translate the text before passing it to _addAction.
methodName
is the name of the method to run when the action is selected. This method is assumed to exist on the model. If the method does not exist the action will not be added. If this method performs an action that requires a refresh of the thin client viewer this method should send the NEEDSREFRESH event. Otherwise no refresh of the thin client viewer will take place.
pos
is an optional argument indicating where in the list to add the action. By default the action will be added as the last action in the EIS list.

Example

Here is a sample of what the overridden _SET_APPLICATION_ method might look like.

_self_ = _self_;

setappl: method appl 8 optional=rc 8;

call super(_self_, '_SET_APPLICATION_', appl, rc);
call send(_self_, '_HAS_METHOD_', '_ADDACTION', hasMethod);
if ( hasMethod = 1 ) then do;

  /* If the method to be driven is an instance method      */
  /* Set the instance method here before calling _addAction */

  call send(_self_, '_SET_INSTANCE_METHOD_', 'SAVEAS',
            'SASUSER.CLASSES.MYMDDB.SCL', 'saveas');

  call send(_self_, '_addAction', 'MY_SAVE_AS', 'Save', 'SAVEAS');

  end;

 endmethod;


saveas: method optional = name $;

   appl = getnitemn(_self_, 'APPLLIST', 1, 1, 0);
   call send(_self_, '_get_application_', appl);

   if ( name = '' ) then do;
      mbrc = 0;
      mbmsg = '';
      dataattrs = makelist() ;
      _metabasei = getnitemn(envlist('L'), 'METABASE', 1, 1);
      _metabase  = getnitemc(appl, 'METABASE', 1, 1, '');
      _database  = getnitemc(appl, 'TABLE', 1, 1, '');
      call send(_metabasei,'_get_data_attr_',mbrc,mbmsg,
                         _metabase,_database,dataattrs) ;
      name = getnitemc(dataattrs,'ITABLE', 1, 1, '');
      rc = dellist(dataattrs, 'Y');
      if ( name = '' ) then
         name = 'SASUSER.SASAPPL.BOOKMARK.EIS';
      end;

   rc = savelist('CATALOG', name, appl, makelist(), 'EIS Bookmark');

endmethod;