Resources

SAS® AppDev Studio 3.0 Developer's Site

TableView: Customize the Menu Bar   About It Build It  

Data Source: Relational Information Map

This example includes the following customizations:

Please install the latest webAF template updates prior to building this example. For more information about the server-side example templates used by this example, see Web Application Example Templates and Built-in Web Application Templates and Options.

The following example is not meant to be a complete Web application, rather it is to show how to use a particular component(s). The example does not address the issue of immediately freeing up resources when the user navigates off the Web application or closes the Web browser. Any necessary resources created in the example will stay around until the associated HTTPSession times out. If this example is used in a multi-user environment, it is possible to exhaust the available resources until HTTPSessions time out and free up their associated resources.

The following assumptions are made for all SAS AppDev Studio examples that use an Information Map as a data source. Please refer to the SAS Intelligence Platform administration documentation for information about any of these topics.

Step 1: Create a project in webAF

  1. Create a new project named TableView.
  2. Select Web Application from the webAF Projects list.
  3. Accept the defaults as you go through the Web App wizard until you have reached step #4 of the wizard. At this step you will need to select Examples in the radio box titled Display list for. Choose the Information Map TableView Servlet item from the Type of initial content list box.
  4. Continue accepting defaults as you complete the Web App wizard.

Step 2: Set up access to the data source

  1. Specify the Information Map by double-clicking on the InfoMapDefaultExampleControllerServlet.java file in the Files Tab of the Project Navigator. Replace ENTER_MAP_NAME_HERE in the following code:
    String mapName = ENTER_MAP_NAME_HERE;
    with URL string for your information map.
  2. Insert the correct metadata password ( omr_password ) in the sas_metadata_source_omr.properties file located in the web-inf\conf directory. This password is used when deploying Foundation Services.
  3. Insert the correct metadata password ( metadata-password ) under the InfoMapOLAPTableViewExampleControllerServlet's initial parameters in the web.xml file located in the web-inf directory. This password is used to get a user and session context from the Foundation Services.

Step 3: Add components to the JSP file

Add the following imports to the InfoMapTableViewExampleViewer.jsp file:

<%@page import="com.sas.servlet.tbeans.dataselectors.html.ActionProviderMenuBar"%>
<%@page import="com.sas.actionprovider.ActionOrderList"%>
<%@page import="com.sas.actionprovider.BaseAction"%>
<%@page import="com.sas.actionprovider.HttpAction"%>
<%@page import="com.sas.actionprovider.HttpActionProvider"%>
<%@page import="com.sas.actionprovider.support.ActionProviderSupportTypes"%>
<%@page import="com.sas.actionprovider.support.dataselectors.RelationalMenuBarAreaInterface" %>
<%@page import="com.sas.servlet.tbeans.tableview.html.TableViewComposite"%>

Customization: Remove the Query Selector from the Edit Options menu

Add the following scriptlet code before the closing <sas:TableViewComposite> tag:

<%
{
   TableViewComposite tvc = (TableViewComposite)
      session.getAttribute("sas_TableView1_InfoMapTableViewExample");
   HttpActionProvider sas_actionProvider =
      (HttpActionProvider)session.getAttribute("sas_actionProvider_InfoMapTableViewExample");
   ActionProviderMenuBar mb =
      (ActionProviderMenuBar)tvc.getComponent(TableViewComposite.TABLEVIEW_MENUBAR);
   ActionOrderList alist = sas_actionProvider.getActionOrderList(
      ActionProviderSupportTypes.RELATIONAL_MENUBAR_SUPPORT, mb,
      RelationalMenuBarAreaInterface.SELECTOR_AREA);
   ActionOrderList editlist = (ActionOrderList)(alist.get(0));

   // Remove the query selector
   for (int i=0; i<editlist.size(); i++)
   {
      String actiontype = (String)(editlist.get(i));
      if ( actiontype != null  && actiontype.equals( "DATAITEM_SELECTOR_ACTION" ) )
      {
         editlist.remove(i);
         break;
      }
   }
}
%>

Customization: Change the menu bar to display a single level with icons

Alternately, you can add the following scriptlet code before the closing <sas:TableViewComposite> tag:

<%
{
   TableViewComposite tvc = (TableViewComposite)
      session.getAttribute("sas_TableView1_InfoMapTableViewExample");
   HttpActionProvider sas_actionProvider =
      (HttpActionProvider)session.getAttribute("sas_actionProvider_InfoMapTableViewExample");

   ActionProviderMenuBar mb =
      (ActionProviderMenuBar)tvc.getComponent(TableViewComposite.TABLEVIEW_MENUBAR);
   ActionOrderList alist = sas_actionProvider.getActionOrderList(
      ActionProviderSupportTypes.RELATIONAL_MENUBAR_SUPPORT, mb,
      RelationalMenuBarAreaInterface.SELECTOR_AREA);
   ActionOrderList editlist = (ActionOrderList)(alist.get(0));
   ActionOrderList newMenuBarlist = new ActionOrderList();
   BaseAction mbaction = null;
   String actiontype = null;
   for (int i=0; i<editlist.size(); i++)
   {
      actiontype = (String)(editlist.get(i));
      mbaction = sas_actionProvider.getDefaultAction(
         ActionProviderSupportTypes.RELATIONAL_MENUBAR_SUPPORT,
         RelationalMenuBarAreaInterface.SELECTOR_AREA,actiontype);

      if ( actiontype != null )
      {
        if ( actiontype.equals( "SORT_SELECTOR_ACTION" ) )
        {
            mbaction.putValue( HttpAction.SMALL_ICON_NAME, "SortAlphaAscending.gif");
            mbaction.putValue( HttpAction.ROLLOVER_ICON_NAME, "SortAlphaAscending.gif" );
            mbaction.putValue( HttpAction.NAME, null);
        }
        else if ( actiontype.equals( "SIMPLE_CALCULATED_ITEM_SELECTOR_ACTION" ) )
        {
            mbaction.putValue( HttpAction.SMALL_ICON_NAME, "AddCalculatedItem.gif");
            mbaction.putValue( HttpAction.ROLLOVER_ICON_NAME, "AddCalculatedItem_rollover.gif" );
            mbaction.putValue( HttpAction.NAME, null);
        }
        else if ( actiontype.equals( "ADVANCED_FILTER_SELECTOR_ACTION" ) )
        {
            mbaction.putValue( HttpAction.SMALL_ICON_NAME, "Filters.gif");
            mbaction.putValue( HttpAction.ROLLOVER_ICON_NAME, "Filters_rollover.gif" );
            mbaction.putValue( HttpAction.NAME, null);
        }
        else if ( actiontype.equals( "RANKING_ACTION" ) )
        {
            mbaction.putValue( HttpAction.SMALL_ICON_NAME, "TopTen.gif");
            mbaction.putValue( HttpAction.ROLLOVER_ICON_NAME, "TopTen_rollover.gif" );
            mbaction.putValue( HttpAction.NAME, null);
        }
        else if ( actiontype.equals( "TOTALS_ACTION" ) )
        {
            mbaction.putValue( HttpAction.SMALL_ICON_NAME, "total.gif");
            mbaction.putValue( HttpAction.ROLLOVER_ICON_NAME, "total_rollover.gif" );
            mbaction.putValue( HttpAction.NAME, null);
        }
        else if ( actiontype.equals( "PERCENT_CALCULATIONS_SELECTOR_ACTION" ) )
        {
            mbaction.putValue( HttpAction.SMALL_ICON_NAME, "PercentOfTotals.gif");
            mbaction.putValue( HttpAction.ROLLOVER_ICON_NAME, "PercentOfTotals.gif" );
            mbaction.putValue( HttpAction.NAME, null);
        }
        else if ( actiontype.equals( "EXCEPTION_HIGHLIGHTING_SELECTOR_ACTION" ) )
        {
            mbaction.putValue( HttpAction.SMALL_ICON_NAME, "Pencil.gif");
            mbaction.putValue( HttpAction.ROLLOVER_ICON_NAME, "Pencil.gif" );
            mbaction.putValue( HttpAction.NAME, null);
        }
        else if ( actiontype.equals( "DATAITEM_SELECTOR_ACTION" ) )
        {
            mbaction.putValue( HttpAction.SMALL_ICON_NAME, "DataSource.gif");
            mbaction.putValue( HttpAction.ROLLOVER_ICON_NAME, "DataSource_rollover.gif" );
            mbaction.putValue( HttpAction.NAME, null);
        }
      }

      newMenuBarlist.add(actiontype);
   } // for
   newMenuBarlist.add(alist.get(1));
   sas_actionProvider.setActionOrderList(ActionProviderSupportTypes.RELATIONAL_MENUBAR_SUPPORT,
      newMenuBarlist,mb,RelationalMenuBarAreaInterface.SELECTOR_AREA);
}
%>

Step 4: Finish the project

  1. Build the project.
  2. Start the Java Web server.
  3. Execute in browser.