Sun logo      Previous      Contents      Index      Next     

Sun ONE Portal Server 6.2 Developer's Guide

Chapter 5
Using the Container Providers

Containers are simply channels that include in their output the content of one or more other channels. The container providers present containment metaphors for channel aggregation including single, table, tab, and framed.

This chapter discusses the out-of-the-box extensible set of container providers that implement various metaphors for aggregating content and includes instructions for:

This chapter also contains the following sections:


The ContainerProvider Architecture

Figure 5-1 shows the relationship between the various interfaces and classes discussed in this chapter. The JSPProvider (see Chapter 4, "Using Leaf Providers" for more information) and ContainerProviderAdapter classes extend ProfileProviderAdapter (see Chapter 2, "Using Provider API (PAPI)" for more information).

The ContainerProvider interface defines the interface for implementing a container provider. A container provider is a provider that generates its views primarily by being a client of other provider objects.

The ContainerProviderAdapter provides default implementations of the following methods in the ContainerProvider: get/setSelectedChannels(), get/setAvailableChannels(), get/setWindowState(), and getSupportedWindowStates(). For more information on all the methods in this class, see the Javadocs.

The ContainerProviderContext extends ProviderContext and adds container functionality to the ProviderContext interface. The ContainerProviderAdapter uses the ContainerProviderContext object as the persistent store.

The JSPContainerProviderAdapter extends the JSPProvider (see Chapter 4, "Using Leaf Providers" for more information) and provides implementations of methods in the ContainerProvider interface to facilitate the execution of JavaServer Pages™ (JSP™).

The JSPTabContainerProvider extends the JSPContainerProviderAdapter and provides default implementation for methods in the TabContainer interface. The JSPSingleContainerProvider and the JSPTableContainerProvider also extend the JSPContainerProviderAdapter.

Figure 5-1  The ContainerProvider Architecture

This figure shows the container provider architecture.


Overview of the ContainerProviders

To support the container providers, the PAPI includes three APIs, the ContainerProvider interface, the ContainerProviderAdapter class, and the ContainerProviderContext interface. This section provides an overview of these three APIs.

ContainerProvider

The ContainerProvider interface defines the interface for implementing a container provider and is the programmatic entity for generating container channels.

A container provider has a selected and available channels list, and allows getting and setting of these lists. Selected channels are those that are considered active on the Desktop. Available channels are those that are available to be activated on the Desktop. That is, selected channels are those that are available and selected for display on the Desktop by the user; available channels are those that are available for display on the Desktop, but not selected for display on the Desktop by the user.

The Desktop container providers (such as JSPSingleContainerProvider, JSPTableContainerProvider, and JSPTabContainerProvider) discussed in this chapter extend the JSPContainerProviderAdapter that implements the ContainerProvider interface.

The ContainerProvider includes interfaces to get/setAvailableChannels and get/setSelectedChannels. See the Javadocs for more information.

ContainerProviderContext

The ContainerProviderContext interface provides an environment for container provider execution. More formally, this class adds container channel functionality to the ProviderContext interface (see Chapter 2, "Using Provider API (PAPI)" for more information). That is, where provider object can obtain access to a ProviderContext object, container providers obtain access to a ContainerProviderContext object.

A ContainerProviderContext object has a superset of the functionality exposed in ProviderContext. The additions are related to managing contained providers. For example, container channel functionality includes getting provider objects, fetching content, content caching, adding clients, creating channels and containers, and getting and setting selected and available channels list.

The ContainerProviderContext is the object to get the container channel properties from the store at run time. The ContainerProviderContext can also be used to getProvider() on another channel or container and getContent() on another channel or container.

ContainerProviderAdapter

The ContainerProviderAdapter class extends ProfileProviderAdapter. ContainerProviderAdapter can be used as the base class for any container provider (except for the JSP-based container providers, which can extend the JSPContainerProviderAdapter). For example, the sample template-based Desktop container providers are developed based on this class.

The ContainerProviderAdapter class provides default implementations of methods in the ContainerProvider interface implemented using a ContainerProviderContext object as the persistent store. This class also has the getContainerProviderContext() method, which gets the container provider context, in addition to the get/setAvailableChannels and get/setSelectedChannels methods.


JSPContainerProviderAdapter

To extend container functionality for JSP-based container providers, a JSPContainerProviderAdapter class is included with the software. This class extends the JSPProvider. The JSPContainerProviderAdapter can be used as the base class for any JSP-based ContainerProvider and is similar in functionality to the ContainerProviderAdapter. For example, the JSPSingleContainerProvider extends from this class.

The JSPContainerProviderAdapter class provides default implementations of methods in the ContainerProvider interface implemented using a ContainerProviderContext object as the persistent store and extends JSPProvider to facilitate the execution of JSPs. It includes interfaces to get/setAvailableChannels, get/setSelectedChannels, and getContainerProviderContext().

Three sample extensions (namely JSPSingleContainerProvider, JSPTableContainerProvider, and JSPTabContainerProvider) to the JSPContainerProviderAdapter API are included.

JSPSingleContainerProvider

A single container wraps the content of a single channel. The single container enables a channel to take over an entire browser page. For example, this can be used to provide the front page or can be used to display a single channel whose name is passed in the request parameter. Typically, the front page consists of some banners and the output of another channel. The purpose of the single channel is to allow these banners, menu bars, and the like to be wrapped around the content of the included channel.

Another purpose of the single container is that the decorational elements (such as banners and menu bars) which wrap around the channel can be easily changed without changing the channel itself.

Using the JSPSingleContainerProvider

The JSPSingleContainerProvider class extends JSPContainerProviderAdapter. A single container simply displays a single leaf channel or a container. It must be a JSP that wraps a container or leaf channel.

The JSPSingleContainerProvider class:

  1. Gets the selected channel name.
  2. Returns the selected channel name as a String.
  3. If more than one channel is defined, it displays the first channel in the list.

Some examples of single container include JSPContentContainer, JSPLayoutContainer, JSPEditContainer.

Extending the JSPSingleContainerProvider

In the following example, the CustomSingleContainerProvider getSelectedChannel(HttpServletRequest req) method overrides the JSPSingleContainerProvider.getSelectedChannel() method to return the first channel from the list whose width is full_top.

  1. Extend the JSPSingleContainerProvider and develop the CustomSingleContainerProvider class file.
  2. The CustomSingleContainerProvider class overrides the JSPSingleContainerProvider.getSelectedChannel() method as shown in Code Example 5-1.

    Code Example 5-1  CustomSingleContainerProvider.java File  

    package custom;

    import com.sun.portal.providers.containers.jsp.single.JSPSingleContainerProvider;

    import com.sun.portal.providers.ProviderException;

    import com.sun.portal.providers.Provider;

    import com.sun.portal.providers.ProviderWidths;

    import com.sun.portal.providers.context.ContainerProviderContext;

    import javax.servlet.http.HttpServletRequest;

    import java.util.List;

    public class CustomSingleContainerProvider extends JSPSingleContainerProvider {

        public String getSelectedChannel(HttpServletRequest req) throws ProviderException {

            List selectedChannels = getSelectedChannels();

            for (int i=0; i<selectedChannels.size(); i++) {

                String channel = (String)selectedChannels.get(i);

                Provider p = getContainerProviderContext().getProvider(req, getName(), channel);

                if (p.getWidth() == ProviderWidths.WIDTH_FULL_TOP) {

                    return channel;

                }

            }

            return (String)selectedChannels.get(0);

        }

    }

  3. Compile the class and put it in the provider class base directory.
  4. The default directory for the class file is /etc/opt/SUNWps/desktop/classes. That is, build the JAR and copy the JAR into the provider class base directory. Or, just copy the class as a file into the provider class base directory. To compile the CustomSingleContainerProvider.java file, enter:

    javac -d /etc/opt/SUNWps/desktop/classes -classpath portal-server-install-root/SUNWps/sdk/desktop/desktopsdk.jar:identity-server-install-root/S UNWam/lib/servlet.jar CustomSingleContainerProvider.java

  5. Develop the display profile XML fragments for this provider.
  6. The display profile fragment for the CustomSingleContainerProvider’s provider is saved in CustomSCProvider.xml file (see Code Example 5-2) and the display profile fragment for the CustomSingleContainerProvider’s channel is saved in CustomSCChannel.xml file (see Code Example 5-3).

    Code Example 5-2  CustomSCProvider.xml File  

    <?xml version="1.0" encoding="utf-8" standalone="no"?>

    <!DOCTYPE DisplayProfile SYSTEM "jar://resources/psdp.dtd">

    <Provider name="CustomSingleContainerProvider" class="custom.CustomSingleContainerProvider">

        <Properties>

            <String name="contentPage" value="single.jsp"/>

            <Boolean name="showExceptions" value="false"/>

            <String name="title" value=" Single Container Provider "/>

            <String name="description" value=" DESCRIPTION "/>

            <String name="refreshTime" value="0"/>

            <String name="width" value="thin"/>

            <String name="fontFace1" value="Sans-serif"/>

            <String name="productName" value="Sun ONE Portal Server"/>

            <Boolean name="isEditable" value="true"/>

            <String name="editType" value=""/>

            <String name="editContainerName" value="JSPEditContainer"/>

            <String name="presetThemeChannel" value="JSPPresetThemeChannel"/>

            <String name="customThemeChannel" value="JSPCustomThemeChannel"/>

        </Properties>

    </Provider>

    Code Example 5-3  CustomSCChannel.xml File  

    <?xml version="1.0" encoding="utf-8" standalone="no"?>

    <!DOCTYPE DisplayProfile SYSTEM "jar://resources/psdp.dtd">

    <Container name="CustomSingleContainer"

    provider="CustomSingleContainerProvider" advanced="false">

        <Properties>

            <String name="title" value="JSP custom single container Channel"/>

            <String name="description" value="This is a test for single

    containers"/>

            <String name="contentPage" value="single.jsp"/>

        </Properties>

        <Available>

            <Reference value="Search"/>

            <Reference value="Bookmark"/>

        </Available>

        <Selected>

            <Reference value="Search"/>

        </Selected>

        <Channels>

        </Channels>

    </Container>

  7. Use the dpadmin command to upload the display profile fragments for this provider.
  8. For the CustomSingleContainerProvider, use the dpadmin command to upload the CustomSCProvider.xml file and CustomSCChannel.xml file XML fragments into the display profile. That is, type:

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname CustomSCProvider.xml

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname CustomSCChannel.xml

  9. Create a new directory for the provider in /etc/opt/SUNWps/desktop/desktoptype directory. The directory for the provider is typically named after the provider’s channel.
  10. For the sample CustomSingleContainerProvider, create a directory called CustomSingleContainer in /etc/opt/SUNWps/desktop/desktoptype directory.

  11. Develop and copy the JSP files for the provider in the newly created directory.
  12. For the CustomSingleContainerProvider, copy files from /etc/opt/SUNWps/desktop/default/JSPSingleContainerProvider to the /etc/opt/SUNWps/desktop/desktoptype/CustomSingleContainer directory.

    1. Modify single.jsp file in the /etc/opt/SUNWps/desktop/desktoptype/CustomSingleContainer directory as shown in Code Example 5-4.
    2.    

      Code Example 5-4  Modifications to single.jsp File  

      <%--

      Copyright 2001 Sun Microsystems, Inc. All rights reserved.

      PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.

      --%>

      <%-- single.jsp --%>

      <%@ taglib uri="/tld/desktop.tld" prefix="dt" %>

      <%@ taglib uri="/tld/desktopSingle.tld" prefix="dtsingle" %>

      <%@ page import="custom.CustomSingleContainerProvider" %>

      <%@ page session="false" %>

      <jsp:include page="header.jsp" flush="true"/>

      <dt:obtainContainer container="$JSPProvider">

          <dtsingle:singleContainerProvider>

              <dtsingle:obtainSelectedChannel>

      <img src="<dt:scontent/>/desktop/images/nothing.gif" height="8" width="0" border="0" alt=""><br>

      <%

      CustomSingleContainerProvider csp = (CustomSingleContainerProvider)pageContext.getAttribute("JSPProvider");

      %>

      <img src="<dt:scontent/>/desktop/images/nothing.gif" height="8" width="0" border="0" alt=""><br>

      <%

      String selected = csp.getSelectedChannel(request);

      out.println(csp.getContainerProviderContext().getContent(request, response, null, selected));

      %>

              </dtsingle:obtainSelectedChannel>

          </dtsingle:singleContainerProvider>

      </dt:obtainContainer>

      <jsp:include page="menubar.jsp" flush="true"/>

      <%@ include file="footer.html" %>

    3. Add a FULL_TOP channel to the container provider before testing the container provider.
    4. For example, for the CustomSingleContainerProvider, add the Search channel via the administration console.

  13. Access the CustomSingleContainerProvider from your browser. To access, log in to the Desktop and type the following URL in your browser:
  14. http://hostname:port/portal/dt?provider=CustomSingleContainer

JSPTableContainerProvider

A table container aggregates the content of other channels into rows and columns. It can be thought of as a bucket for the content of other channels. The JSPTableContainerProvider class extends JSPContainerProviderAdapter.

The table container facilitates the aggregation of multiple channels into a single display. That is, the JSPTableContainerProvider aggregates channels into HTML rows and columns.

Using the JSPTableContainerProvider

A JSPTableContainerProvider provides methods that allow the associated JSP files to use these methods, and generate a view that arranges the contained channels to be displayed in a HTML table. By the nature of the container provider, the JSPTableContainer has a list of available channels and a list of selected channels.

Available channels are the channels that are available to be activated in the Desktop, and selected channels are the channels that are displayed in the Desktop. Selected and available channels list is defined in the table container channel definition in the display profile.

Extending the JSPTableContainerProvider

This section includes some sample providers that extend JSPTableContainerProvider and override methods in the JSPTableContainerProvider API.

Example 1

The following is an example of a container provider that selects channels dynamically based on the time of the day.

  1. Extend JSPTableContainerProvider and develop the provider class file.
  2. For CustomTableContainerProvider, the CustomTableContainerProvider class is implemented by extending the JSPTableContainerProvider class as shown in Code Example 5-5.

    Code Example 5-5  CustomTableContainerProvider.java File  

    package custom;

    import com.sun.portal.providers.containers.jsp.table.JSPTableContainerProvider;

    import com.sun.portal.providers.ProviderException;

    import java.util.List;

    import java.util.ArrayList;

    import java.util.Calendar;

    public class CustomTableContainerProvider extends JSPTableContainerProvider {

        private Calendar rightNow = Calendar.getInstance();

            public List getSelectedChannels() throws ProviderException {

            List selectedChannels = super.getSelectedChannels();

            List newList = new ArrayList();

            if ( rightNow.AM_PM == rightNow.AM) {

                List amList = (List)getListProperty("amList");

                for (int i = 0; i < amList.size(); i++) {

                    String channel = (String)amList.get(i);

                    if ( selectedChannels.contains(channel)) {

                        newList.add(channel);

                    }

                }

                return newList;

            } else {

                List pmList = (List)getListProperty("pmList");

                for (int i = 0; i < pmList.size(); i++) {

                    String channel = (String)pmList.get(i);

                    if ( selectedChannels.contains(channel)) {

                        newList.add(channel);

                    }

                }

                return newList;

            }

        }

    }

  3. Compile the class and put it in the provider class base directory.
  4. The default directory for the class file is /etc/opt/SUNWps/desktop/classes. That is, build the JAR and copy the JAR into the provider class base directory. Or, just copy the class as a file into the provider class base directory. To compile the CustomTableContainerProvider.java file, enter:

    javac -d /etc/opt/SUNWps/desktop/classes -classpath portal-server-install-root/SUNWps/sdk/desktop/desktopsdk.jar:identity-server-install-root/S UNWam/lib/servlet.jar CustomTableContainerProvider.java

  5. Develop the display profile XML fragments for this provider and this provider’s channel.
  6. The display profile fragment for the CustomTableContainerProvider’s provider is saved in CustomTCProvider.xml file (see Code Example 5-6) and the display profile fragment for the CustomTableContainerProvider’s channel is saved in CustomTCChannel.xml file (see Code Example 5-7).

    Code Example 5-6  CustomTCProvider.xml File  

    <?xml version="1.0" encoding="utf-8" standalone="no"?>

    <!DOCTYPE DisplayProfile SYSTEM "jar://resources/psdp.dtd">

    <Provider name="CustomTableContainerProvider" class="custom.CustomTableContainerProvider">

        <Properties>

            <String name="contentPage" value="toptable.jsp"/>

            <Integer name="timeout" value ="1800"/>

            <Integer name="layout" value="1"/>

            <Boolean name="showExceptions" value="false"/>

            <Boolean name="parallelChannelsInit" value="false"/>

            <String name="title" value="Table Container Provider"/>

            <String name="description" value="DESCRIPTION"/>

            <String name="refreshTime" value="0"/>

            <String name="width" value="thin"/>

            <String name="fontFace1" value="Sans-serif"/>

            <String name="Desktop-fontFace1" value="Sans-serif"/>

            <String name="productName" value="Sun ONE Portal Server"/>

            <String name="presetThemeChannel" value="JSPPresetThemeContainer"/>

            <String name="customThemeChannel" value="JSPCustomThemeContainer"/>

            <Boolean name="refreshParentContainerOnly" value="false" advanced="true"/>

            <Boolean name="isEditable" value="true"/>

            <String name="editType" value="edit_complete"/>

            <String name="editContainerName" value="JSPEditContainer"/>

            <Integer name="thin_popup_height" value="200"/>

            <Integer name="thin_popup_width" value="500"/>

            <Integer name="thick_popup_height" value="300"/>

            <Integer name="thick_popup_width" value="600"/>

            <Integer name="fullwidth_popup_height" value="500"/>

            <Integer name="fullwidth_popup_width" value="600"/>

            <Collection name="categories">

                <String value="Personal Channels"/>

                <String value="Sample Channels"/>

                <String value="News Channels"/>

                <String value="Search Channels"/>

            </Collection>

            <Collection name="Personal Channels">

                <String value="UserInfo"/>

                <String value="MailCheck"/>

                <String value="Bookmark"/>

                <String value="App"/>

            </Collection>

            <Collection name="Sample Channels">

                <String value="SampleSimpleWebService"/>

                <String value="SampleJSP"/>

                <String value="SampleXML"/>

                <String value="SampleURLScraper"/>

            </Collection>

            <Collection name="News Channels">

                <String value="SampleRSS"/>

                <String value="Postit"/>

            </Collection>

            <Collection name="Search Channels">

                <String value="Search"/>

            </Collection>

            <Boolean name="defaultChannelIsMinimizable" value="true"/>

            <Boolean name="defaultChannelIsMinimized" value="false" advanced="true"/>

            <Boolean name="defaultChannelIsDetached" value="false" advanced="true"/>

            <Boolean name="defaultChannelIsDetachable" value="true"/>

            <Boolean name="defaultChannelIsRemovable" value="true"/>

            <Boolean name="defaultChannelHasFrame" value="true" advanced="true"/>

            <Boolean name="defaultChannelIsMovable" value="true"/>

            <Boolean name="defaultBorderlessChannel" value="false" advanced="true"/>

            <String name="defaultChannelColumn" value="1" advanced="true"/>

            <String name="defaultChannelRow" value="1" advanced="true"/>

            <Collection name="channelsIsMinimized" advanced="true"/>

            <Collection name="channelsIsDetached" advanced="true"/>

            <Collection name="channelsHasFrame" advanced="true"/>

            <Collection name="channelsIsMinimizable"/>

            <Collection name="channelsRow" advanced="true"/>

            <Collection name="channelsColumn" advanced="true"/>

            <Collection name="channelsIsMovable"/>

            <Collection name="channelsIsDetachable"/>

            <Collection name="channelsIsRemovable"/>

            <Collection name="borderlessChannels"/>

        </Properties>

    </Provider>

    Code Example 5-7  CustomTCChannel.xml File  

    <?xml version="1.0" encoding="utf-8" standalone="no"?>

    <!DOCTYPE DisplayProfile SYSTEM "jar://resources/psdp.dtd">

    <Container name="CustomTableContainer" provider="CustomTableContainerProvider">

        <Properties>

            <String name="title" value="Front Table Container Channel"/>

            <String name="contentPage" value="toptable.jsp"/>

            <String name="description" value="This is a test for front table containers" />

            <String name="Desktop-fontFace1" value="Sans-serif"/>

            <Collection name="categories">

                <String value="Personal Channels"/>

                <String value="Sample Channels"/>

                <String value="News Channels"/>

            </Collection>

            <Collection name="Personal Channels">

                <String value="UserInfo"/>

                <String value="MailCheck"/>

                <String value="Bookmark"/>

                <String value="App"/>

            </Collection>

            <Collection name="Sample Channels">

                <String value="SampleJSP"/>

                <String value="SampleXML"/>

            </Collection>

            <Collection name="News Channels">

                <String value="SampleRSS"/>

            </Collection>

            <Collection name="channelsRow" advanced="true">

                <String name="MailCheck" value="4"/>

                <String name="App" value="5"/>

                <String name="Bookmark" value="3"/>

                <String name="SampleRSS" value="2"/>

                <String name="SampleXML" value="2"/>

            </Collection>

            <Collection name="channelsIsRemovable" >

                <Boolean name="UserInfo" value="false"/>

            </Collection>

            <Collection name="amList">

                <String value="UserInfo"/>

                <String value="MailCheck"/>

                <String value="App"/>

                <String value="Bookmark"/>

            </Collection>

            <Collection name="pmList">

                <String value="MyFrontPageTabPanelContainer/Bookmark2"/>

                <String value="MailCheck"/>

                <String value="SampleXML"/>

                <String value="SampleRSS"/>

            </Collection>

        </Properties>

        <Available>

            <Reference value="UserInfo"/>

            <Reference value="MailCheck"/>

            <Reference value="App"/>

            <Reference value="Bookmark"/>

            <Reference value="MyFrontPageTabPanelContainer/Bookmark2"/>

            <Reference value="SampleJSP"/>

            <Reference value="SampleRSS"/>

            <Reference value="SampleXML"/>

        </Available>

        <Selected>

            <Reference value="UserInfo"/>

            <Reference value="MailCheck"/>

            <Reference value="App"/>

            <Reference value="Bookmark"/>

            <Reference value="MyFrontPageTabPanelContainer/Bookmark2"/>

            <Reference value="SampleJSP"/>

            <Reference value="SampleRSS"/>

            <Reference value="SampleXML"/>

        </Selected>

        <Channels>

        </Channels>

    </Container>

  7. Use the dpadmin command to upload the display profile fragments for this provider.
  8. For CustomTableContainerProvider, use the dpadmin command to upload the CustomTCProvider.xml file and CustomTCChannel.xml file fragments in the display profile. That is, type:

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname CustomTCProvider.xml

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname CustomTCChannel.xml

  9. Create a new directory for the provider in /etc/opt/SUNWps/desktop/desktoptype directory. The directory for the provider is typically named after the channel.
  10. For the sample CustomTableContainerProvider, create a directory called CustomTableContainer in /etc/opt/SUNWps/desktop/desktoptype.

  11. Develop and copy the JSP files for the provider in the newly created directory.
  12. For CustomTableContainerProvider, copy files from /etc/opt/SUNWps/desktop/default/JSPTableContainerProvider to the /etc/opt/SUNWps/desktop/desktoptype/CustomTableContainer directory.

  13. Copy the resource file for the provider into /etc/opt/SUNWps/desktop/classes directory.
  14. For example, for the CustomTableContainerProvider:

    1. Change directories to webcontainer/portal/WEB-INF/classes directory.
    2. Type cp JSPTableContainerProvider.properties /etc/opt/SUNWps/desktop/classes/CustomTableContainerProvider.properties.
  15. Access CustomTableContainerProvider from your browser. To access, log in to the Desktop and type the following URL in your browser:
  16. http://hostname:port/portal/dt?provider=CustomTableContainer

Example 2

Figure 5-2 shows a sample layout for a Thin_Wide_Thin_Span column. The table Desktop layout in Figure 5-2 has three columns with the full_bottom spanning two (left and center) columns.

Figure 5-2  Sample Table Column Span

This image is a sample Desktop layout.

To achieve the layout shown in Figure 5-2:

  1. Extend JSPTableContainerProvider and develop the SpanTableContainerProvider class file.
  2. The SpanTableContainerProvider class is implemented by extending the JSPTableContainerProvider class as shown in Code Example 5-8.

    Code Example 5-8  SpanTableContainerProvider.java File  

    package custom;

    import com.sun.portal.providers.containers.jsp.table.JSPTableContainerProvider;

    import com.sun.portal.providers.ProviderException;

    import com.sun.portal.providers.ProviderWidths;

    import com.sun.portal.providers.Provider;

    import com.sun.portal.providers.context.ContainerProviderContext;

    import javax.servlet.http.HttpServletRequest;

    import java.util.List;

    public class SpanTableContainerProvider extends JSPTableContainerProvider {

        public int getRowSpan(HttpServletRequest req) throws ProviderException {

            int rowSpan = 1;

            List selected = getSelectedChannels();

            for (int i=0; i < selected.size(); i++) {

                String channel = (String)selected.get(i);

                Provider p = getContainerProviderContext().getProvider(req, getName(), channel);

                if ( (p.getWidth() == ProviderWidths.WIDTH_FULL_BOTTOM) ) {

                    rowSpan = rowSpan++;

                }

            }

            return rowSpan;

        }

    }

  3. Compile the class and put it in the provider class base directory.
  4. The default directory for the class file is /etc/opt/SUNWps/desktop/classes. That is, build the JAR and copy the JAR into the provider class base directory. Or, just copy the class as a file into the provider class base directory. To compile the SpanTableContainerProvider.java file, enter:

    javac -d /etc/opt/SUNWps/desktop/classes -classpath portal-server-install-root/SUNWps/sdk/desktop/desktopsdk.jar:identity-server-install-root/S UNWam/lib/servlet.jar SpanTableContainerProvider.java

  5. Develop the display profile XML fragments for this provider and this provider’s channel.
  6. The display profile fragment for SpanTableContainerProvider’s provider is saved in SpanTCProvider.xml file (see Code Example 5-9) and the display profile fragment for SpanTableContainerProvider’s channel is saved in SpanTCChannel.xml file (see Code Example 5-10).

    Code Example 5-9  SpanTCProvider.xml File  

    <?xml version="1.0" encoding="utf-8" standalone="no"?>

    <!DOCTYPE DisplayProfile SYSTEM "jar://resources/psdp.dtd">

    <Provider name="SpanTableContainerProvider" class="custom.SpanTableContainerProvider">

        <Properties>

            <String name="contentPage" value="toptable.jsp"/>

            <Integer name="timeout" value ="1800"/>

            <Integer name="layout" value="1"/>

            <Boolean name="showExceptions" value="false"/>

            <Boolean name="parallelChannelsInit" value="false"/>

            <String name="title" value="Table Container Provider"/>

            <String name="description" value="DESCRIPTION"/>

            <String name="refreshTime" value="0"/>

            <String name="width" value="thin"/>

            <String name="fontFace1" value="Sans-serif"/>

            <String name="Desktop-fontFace1" value="Sans-serif"/>

            <String name="productName" value="Sun ONE Portal Server"/>

            <String name="presetThemeChannel" value="JSPPresetThemeContainer"/>

            <String name="customThemeChannel" value="JSPCustomThemeContainer"/>

            <Boolean name="refreshParentContainerOnly" value="false" advanced="true"/>

            <Boolean name="isEditable" value="true"/>

            <String name="editType" value="edit_complete"/>

            <String name="editContainerName" value="JSPEditChannel"/>

            <Integer name="thin_popup_height" value="200"/>

            <Integer name="thin_popup_width" value="500"/>

            <Integer name="thick_popup_height" value="300"/>

            <Integer name="thick_popup_width" value="600"/>

            <Integer name="fullwidth_popup_height" value="500"/>

            <Integer name="fullwidth_popup_width" value="600"/>

            <Collection name="categories">

                <String value="Personal Channels"/>

                <String value="Sample Channels"/>

                <String value="News Channels"/>

                <String value="Search Channels"/>

            </Collection>

            <Collection name="Personal Channels">

                <String value="UserInfo"/>

                <String value="MailCheck"/>

                <String value="Bookmark"/>

                <String value="App"/>

            </Collection>

            <Collection name="Sample Channels">

                <String value="SampleSimpleWebService"/>

                <String value="SampleJSP"/>

                <String value="SampleXML"/>

                <String value="SampleURLScraper"/>

            </Collection>

            <Collection name="News Channels">

                <String value="SampleRSS"/>

                <String value="Postit"/>

            </Collection>

            <Collection name="Search Channels">

                <String value="Search"/>

            </Collection>

            <Boolean name="defaultChannelIsMinimizable" value="true"/>

            <Boolean name="defaultChannelIsMinimized" value="false" advanced="true"/>

            <Boolean name="defaultChannelIsDetached" value="false" advanced="true"/>

            <Boolean name="defaultChannelIsDetachable" value="true"/>

            <Boolean name="defaultChannelIsRemovable" value="true"/>

            <Boolean name="defaultChannelHasFrame" value="true" advanced="true"/>

            <Boolean name="defaultChannelIsMovable" value="true"/>

            <Boolean name="defaultBorderlessChannel" value="false" advanced="true"/>

            <String name="defaultChannelColumn" value="1" advanced="true"/>

            <String name="defaultChannelRow" value="1" advanced="true"/>

            <Collection name="channelsIsMinimized" advanced="true"/>

            <Collection name="channelsIsDetached" advanced="true"/>

            <Collection name="channelsHasFrame" advanced="true"/>

            <Collection name="channelsIsMinimizable"/>

            <Collection name="channelsRow" advanced="true"/>

            <Collection name="channelsColumn" advanced="true"/>

            <Collection name="channelsIsMovable"/>

            <Collection name="channelsIsDetachable"/>

            <Collection name="channelsIsRemovable"/>

            <Collection name="borderlessChannels"/>

        </Properties>

    </Provider>

    Code Example 5-10  SpanTCChannel.xml File  

    <?xml version="1.0" encoding="utf-8" standalone="no"?>

    <!DOCTYPE DisplayProfile SYSTEM "jar://resources/psdp.dtd">

    <Container name="SpanTableContainerChannel" provider="SpanTableContainerProvider">

        <Properties>

            <String name="title" value="Front Table Container Channel"/>

            <String name="contentPage" value="toptable.jsp"/>

            <String name="description" value="This is a test for spanning table containers" />

            <String name="Desktop-fontFace1" value="Sans-serif"/>

            <Collection name="categories">

                <String value="Personal Channels"/>

                <String value="Sample Channels"/>

                <String value="News Channels"/>

            </Collection>

            <Collection name="Personal Channels">

                <String value="UserInfo"/>

                <String value="MailCheck"/>

                <String value="Bookmark"/>

                <String value="App"/>

            </Collection>

            <Collection name="Sample Channels">

                <String value="SampleJSP"/>

                <String value="SampleXML"/>

            </Collection>

            <Collection name="News Channels">

                <String value="SampleRSS"/>

            </Collection>

            <Collection name="channelsRow" advanced="true">

                <String name="MailCheck" value="4"/>

                <String name="App" value="5"/>

                <String name="Bookmark" value="3"/>

                <String name="SampleRSS" value="2"/>

                <String name="SampleXML" value="2"/>

            </Collection>

            <Collection name="channelsIsRemovable" >

                <Boolean name="UserInfo" value="false"/>

            </Collection>

            <Collection name="amList">

                <String value="UserInfo"/>

                <String value="MailCheck"/>

                <String value="App"/>

                <String value="Bookmark"/>

            </Collection>

            <Collection name="pmList">

                <String value="MyFrontPageTabPanelContainer/Bookmark2"/>

                <String value="MailCheck"/>

                <String value="SampleXML"/>

                <String value="SampleRSS"/>

            </Collection>

        </Properties>

        <Available>

            <Reference value="UserInfo"/>

            <Reference value="MailCheck"/>

            <Reference value="App"/>

            <Reference value="Bookmark"/>

            <Reference value="MyFrontPageTabPanelContainer/Bookmark2"/>

            <Reference value="SampleJSP"/>

            <Reference value="SampleRSS"/>

            <Reference value="SampleXML"/>

        </Available>

        <Selected>

            <Reference value="UserInfo"/>

            <Reference value="MailCheck"/>

            <Reference value="App"/>

            <Reference value="Bookmark"/>

            <Reference value="MyFrontPageTabPanelContainer/Bookmark2"/>

            <Reference value="SampleJSP"/>

            <Reference value="SampleRSS"/>

            <Reference value="SampleXML"/>

        </Selected>

        <Channels>

        </Channels>

    </Container>

  7. Use the dpadmin command to upload the display profile fragments for this provider.
  8. For SpanTableContainerProvider, use the dpadmin command to upload the CustomTCProvider.xml file and CustomTCChannel.xml file fragments in the display profile. That is, type:

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname SpanTCProvider.xml

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname SpanTCChannel.xml

  9. Create a new directory for the provider in /etc/opt/SUNWps/desktop/desktoptype directory. The directory for the provider is typically named after the channel.
  10. For the sample SpanTableContainerProvider, create a directory called SpanTableContainerChannel in /etc/opt/SUNWps/desktop/desktoptype directory.

  11. Copy files from /etc/opt/SUNWps/desktop/default/JSPTableContainerProvider to the newly created directory.
  12. Modify the JSP files (in /etc/opt/SUNWps/desktop/desktoptype/SpanTableContainerChannel) as shown in Step a, Step b, and Step c (modifications to the file are shown in bold):
    1. Add the following to toptable.jsp:
    2. Code Example 5-11  Changes to toptable.jsp File  

      <!-- BEGIN FULL TOP CHANNELS -->

      <dttable:getColumns id="channels" column="top" scope="request"/>

      <jsp:include page="tabletopbottom.jsp" flush="true">

      <jsp:param name="columnName" value="top"/>

      </jsp:include>

      <!-- END TOP CHANNELS -->

      <!-- BEGIN FULL BOTTOM CHANNELS -->

      <dttable:getColumns id="channels" column="bottom" scope="request"/>

      <jsp:include page="tabletopbottom.jsp" flush="true">

      <jsp:param name="columnName" value="bottom"/>

      </jsp:include>

      <!-- END BOTTOM CHANNELS -->

      Here, tcp is an instance of SpanTableContainerProvider.

    3. Add the following to tablecolumn.jsp:
    4. Code Example 5-12  Sample tablecolumn.jsp File  

      <%@ page import="custom.SpanTableContainerProvider"%>

      <%@ page session="false" %>

      <%

      SpanTableContainerProvider tcp = (SpanTableContainerProvider)pageContext.getAttribute("JSPProvider");

      %>

      <dt:obtainContainer container="$JSPProvider">

      <% String columnName = request.getParameter( "columnName" ); %>

      <% pageContext.setAttribute( "columnName", columnName ); %>

      <%

      if (columnName.equalsIgnoreCase("right")) {

      %>

      <TD WIDTH="<dttable:getColumnWidth column="$columnName"/>%" VALIGN=TOP ROWSPAN="<%=tcp.getRowSpan(request)%>">

      <%

      } else {

      %>

      <TD WIDTH="<dttable:getColumnWidth column="$columnName"/>%" VALIGN=TOP>

      <%

      }

      %>

    5. Add the following to tabletopbottom.jsp:
    6. Code Example 5-13  Sample tabletopbottom.jsp  

      <jx:if test="$hasChannel">

      <TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0>

      <%

      if (request.getParameter("columnName").equals("bottom")) {

      %>

      <TR COLSPAN=2>

      <%

      } else {

      %>

      <TR>

      <%

      }

      %>

      <TD WIDTH="100%" VALIGN=TOP>

      <jx:forEach var="channel" items="$channels">

  13. Copy the WebContainer/portal/web-apps/WEB-INF/classes/JSPTableContainerProvider.properties to /etc/opt/SUNWps/desktop/classes/SpanTableContainerProvider.properties file.
  14. At least one of the selected channels should be of width full_bottom and the selected layout should be thin_wide_thin for the layout described in Figure 5-2 to be displayed.
  15. Access SpanTableContainerProvider from your browser. To access, type the following URL in your browser:
  16. http://hostname:port/portal/dt?provider=SpanTableContainerChannel

Example 3

This section provides some sample extensions to the JSPTableContainerProvider class file and its associated JSP files for enabling a customized Desktop layout.

Customizing the Row Layout
  1. Create a new custom table container provider by extending JSPTableContainerProvider as shown in Code Example 5-14.
  2. Override the getLayout(), setUpColumns(), and getWidths() methods as shown in Code Example 5-14 in the CustomTCProvider.java file. You can also add any new logic to arrange the channels into rows and columns according to your new layout.

    Code Example 5-14  CustomTCProvider.java File  

    package custom;

    import com.sun.portal.providers.containers.jsp.table.JSPTableContainerProvider;

    import com.sun.portal.providers.ProviderException;

    import com.sun.portal.providers.ProviderWidths;

    import com.sun.portal.providers.Provider;

    import com.sun.portal.providers.util.Layout;

    import com.sun.portal.providers.context.ContainerProviderContext;

    import javax.servlet.http.HttpServletRequest;

    import java.util.List;

    import java.util.ArrayList;

    import java.util.Map;

    import java.util.HashMap;

    import java.util.Iterator;

    public class CustomTCProvider extends JSPTableContainerProvider {

        public int getLayout() throws ProviderException {

            int layout = getIntegerProperty("layout");

            return layout;

        }

        public Map setupColumns(HttpServletRequest req) throws ProviderException {

            int layout = getLayout();

            List leftList = new ArrayList();

            List centerList = new ArrayList();

            List rightList = new ArrayList();

            List fullTopList = new ArrayList();

            List fullBottomList = new ArrayList();

            if ((layout >= Layout.LAYOUT_THIN_THICK) && (layout <= Layout.LAYOUT_THIN_THIN_THIN)) {

                return super.setupColumns(req);

            } else {

                List selectedChannels = getSelectedChannels();

                for (Iterator i = selectedChannels.iterator(); i.hasNext(); ) {

                    String providerName = (String)i.next();

                    Provider p = null;

                    p = getContainerProviderContext().getProvider(req,

    getName(), providerName);

                    int width = -1;

                    try {

                        width = p.getWidth();

                    }

                      catch (NumberFormatException e) {

                    }

                      catch (Throwable e) {

                    }

                }

                // add the channel to leftList/centerList/rightList/fullTopList/fullBottomList based on width and as required by your new layout.

            }

            Map columnMap = new HashMap();

            columnMap.put( new Integer(LEFT), leftList );

            columnMap.put( new Integer(RIGHT), rightList );

            columnMap.put( new Integer(CENTER), centerList );

            columnMap.put( new Integer(TOP), fullTopList );

            columnMap.put( new Integer(BOTTOM), fullBottomList );

            return columnMap;

        }

        public int getWidths(int column) throws ProviderException {

            int centerWidth = -1;

            int leftWidth = -1;

            int rightWidth = -1;

            /* modify this method as shown in the customizing column widths

    section according to your layout specifications or keep this method as is.*/

            //return the corresponding width based on the column.

            switch( column ) {

                case LEFT:

                return leftWidth;

                case RIGHT:

                return rightWidth;

                case CENTER:

                return centerWidth;

                default:

                return -1;

            }

        }

    }

  3. Compile the class and put it in the provider class base directory.
  4. The default directory for the class file is /etc/opt/SUNWps/desktop/classes. That is, build the JAR and copy the JAR into the provider class base directory. Or, just copy the class as a file into the provider class base directory. To compile the CustomTCProvider.java file, enter:

    javac -d /etc/opt/SUNWps/desktop/classes -classpath portal-server-install-root/SUNWps/sdk/desktop/desktopsdk.jar:identity-server-install-root/S UNWam/lib/servlet.jar CustomTCProvider.java

  5. Develop the display profile XML fragment for this provider and this provider’s channel.
    1. The display profile fragment for the CustomTCProvider’s provider and channel must be saved in separate XML files.
    2. Add <Integer name="layout" value="5"/> in the display profile fragment for the CustomTCProvider’s provider.
  6. Use the dpadmin command to upload the display profile fragments for this provider.
  7. For CustomTCProvider, use the dpadmin command to upload the CustomTCProvider.xml file and CustomTCChannel.xml file fragments in the display profile. That is, type:

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname CustomTCProvider.xml

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname CustomTCChannel.xml

  8. Create a new directory for the provider in /etc/opt/SUNWps/desktop/desktoptype. The directory for the provider is typically named after the provider.
  9. For the sample CustomTCProvider, create a directory called CustomTCProvider in /etc/opt/SUNWps/desktop/desktoptype.

  10. Copy files from /etc/opt/SUNWps/desktop/default/JSPTableContainerProvider to the newly created directory.
  11. Modify the HTML in toptable.jsp file in /etc/opt/SUNWps/desktop/desktoptype/CustomTCProvider.
  12. Rearrange the channels into rows and columns as per your specifications. Replace JSPLayoutContainer with CustomLayoutContainer.

  13. Create a new directory for CustomLayoutContainer under /etc/opt/SUNWps/desktop/desktoptype. For example, type:
  14. mkdir /etc/opt/SUNWps/desktop/desktoptype/CustomLayoutContainer

  15. Copy files from /etc/opt/SUNWps/desktop/default/JSPLayoutContainer to /etc/opt/SUNWps/desktop/desktoptype/CustomLayoutContainer. For example, type:
  16. cp /etc/opt/SUNWps/desktop/default/JSPLayoutContainer/* /etc/opt/SUNWps/desktop/desktoptype/CustomLayoutContainer

  17. Modify layoutedit.jsp to display your new layout in the layout page.
  18. Modify the layoutedit.jsp file at /etc/opt/SUNWps/desktop/desktoptype/CustomLayoutContainer as shown in Code Example 5-15.

    Code Example 5-15  Sample layoutedit.jsp  

    <jx:choose>

        <jx:when test="$layout == 1">

            <%@ include file="layout1.jsp" %>

        </jx:when>

        <jx:when test="$layout == 2">

            <%@ include file="layout2.jsp" %>

        </jx:when>

        <jx:when test="$layout == 3">

            <%@ include file="layout3.jsp" %>

        </jx:when>

        <jx:when test="$layout == 5">

            <%@ include file="layout5.jsp" %>

        </jx:when>

    </jx:choose>

  19. Create a new layout5.jsp which gets displayed on the layout page when the user selects layout 5.
  20. Modify layoutdoedit.jsp to handle the processing of layout 5 that you have created.
  21. Add the display profile for CustomLayoutContainer as shown in Code Example 5-16.
  22. Code Example 5-16  CustomLayoutContainer.xml File  

    <Container name="CustomLayoutContainer" provider="JSPSingleContainerProvider" advanced="true">

        <Properties>

            <String name="title" value="JSP Custom Layout Channel"/>

            <String name="description" value="This is the JSP Layout Channel"/>

            <String name="contentPage" value="" merge="replace" lock="false" propagate="false"/>

            <String name="editPage" value="layoutedit.jsp"/>

            <String name="processPage" value="layoutdoedit.jsp"/>

            <Boolean name="isEditable" value="true" advanced="true"/>

            <String name="editType" value="edit_complete" advanced="true"/>

        </Properties>

        <Available>

        </Available>

        <Selected>

        </Selected>

        <Channels>

        </Channels>

    </Container>

  23. Upload the display profile XML fragment for CustomLayoutContainer using the dpadmin command.
  24. For example, to upload CustomLayoutContainer.xml file fragments, type:

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname CustomLayoutContainer.xml

  25. Access CustomTCProvider from your browser. To access, type the following URL in your browser:
  26. http://hostname:port/portal/dt?provider=CustomTCProvider

Customizing the Column Widths

The getWidths(int column) method throws ProviderException; it returns the column width for the column the width is requested for. By default, the column widths for left, right columns in layout 1 and layout 2 are defined as 30, 70 and for layout 3 they are defined as 25, 50, 25.

To customize the column widths, extend the JSPTableContainerProvider and override the getWidths(int column) method to return different widths.

  1. Extend the JSPTableContainerProvider and develop the CustomJSPTableContainerProvider class file.
  2. The CustomJSPTableContainerProvider class file in Code Example 5-17 overrides the getWidths() method in the JSPTableContainerProvider and returns 40 for left, and 60 for right columns, and 30, 40, 30 for layout 3 (changes are shown in bold).

    Code Example 5-17  CustomJSPTableContainerProvider.java File  

    package custom;

    import com.sun.portal.providers.containers.jsp.table.JSPTableContainerProvider;

    import com.sun.portal.providers.ProviderException;

    import com.sun.portal.providers.ProviderWidths;

    import com.sun.portal.providers.Provider;

    import com.sun.portal.providers.util.Layout;

    public class CustomJSPTableContainerProvider extends JSPTableContainerProvider {

        public int getWidths(int column) throws ProviderException {

            int centerWidth = -1;

            int rightWidth = -1;

            int leftWidth = -1;

            int layout = getLayout();

            switch (layout) {

                case Layout.LAYOUT_THIN_THICK:

                    leftWidth = 40;

                    rightWidth = 60;

                    break;

                case Layout.LAYOUT_THICK_THIN:

                    rightWidth = 40;

                    leftWidth = 60;

                    break;

                case Layout.LAYOUT_THIN_THICK_THIN:

                    rightWidth = 30;

                    centerWidth= 40;

                    leftWidth = 30;

                    break;

                default:

                    rightWidth = 40;

                    leftWidth = 60;

                    break;

            }

            switch( column ) {

                case LEFT:

                    return leftWidth;

                case RIGHT:

                    return rightWidth;

                case CENTER:

                    return centerWidth;

                default:

                    return -1;

            }

        }

    }

  3. Compile the class and put it in the provider class base directory.
  4. The default directory for the class file is /etc/opt/SUNWps/desktop/classes. That is, build the JAR and copy the JAR into the provider class base directory. Or, just copy the class as a file into the provider class base directory. To compile the CustomJSPTableContainerProvider.java file, enter:

    javac -d /etc/opt/SUNWps/desktop/classes -classpath BaseDir/SUNWps/sdk/desktop/desktopsdk.jar:BaseDir/SUNWam/lib/servlet.ja r CustomJSPTableContainerProvider.java

  5. Develop the display profile XML fragments for this provider and this provider’s channel.
  6. The display profile fragment for the CustomJSPTableContainerProvider’s provider is saved in CustomJSPTCProvider.xml file (see Code Example 5-18) and the display profile fragment for the CustomTableContainerProvider’s channel is saved in CustomJSPTCChannel.xml file (see Code Example 5-19).

    Code Example 5-18  CustomJSPTCProvider.xml File  

    <?xml version="1.0" encoding="utf-8" standalone="no"?>

    <!DOCTYPE DisplayProfile SYSTEM "jar://resources/psdp.dtd">

    <Provider name="CustomJSPTableContainerProvider" class="custom.CustomJSPTableContainerProvider">

        <Properties>

            <String name="contentPage" value="toptable.jsp"/>

            <Integer name="timeout" value ="1800"/>

            <Integer name="layout" value="1"/>

            <Boolean name="showExceptions" value="false"/>

            <Boolean name="parallelChannelsInit" value="false"/>

            <String name="title" value="Table Container Provider"/>

            <String name="description" value="DESCRIPTION"/>

            <String name="refreshTime" value="0"/>

            <String name="width" value="thin"/>

            <String name="fontFace1" value="Sans-serif"/>

            <String name="Desktop-fontFace1" value="Sans-serif"/>

            <String name="productName" value="Sun ONE Portal Server"/>

            <String name="presetThemeChannel" value="JSPPresetThemeContainer"/>

            <String name="customThemeChannel" value="JSPCustomThemeContainer"/>

            <Boolean name="refreshParentContainerOnly" value="false" advanced="true"/>

            <Boolean name="isEditable" value="true"/>

            <String name="editType" value="edit_complete"/>

            <String name="editContainerName" value="JSPEditChannel"/>

            <Integer name="thin_popup_height" value="200"/>

            <Integer name="thin_popup_width" value="500"/>

            <Integer name="thick_popup_height" value="300"/>

            <Integer name="thick_popup_width" value="600"/>

            <Integer name="fullwidth_popup_height" value="500"/>

            <Integer name="fullwidth_popup_width" value="600"/>

            <Collection name="categories">

                <String value="Personal Channels"/>

                <String value="Sample Channels"/>

                <String value="News Channels"/>

                <String value="Search Channels"/>

            </Collection>

            <Collection name="Personal Channels">

                <String value="UserInfo"/>

                <String value="MailCheck"/>

                <String value="Bookmark"/>

                <String value="App"/>

            </Collection>

            <Collection name="Sample Channels">

                <String value="SampleSimpleWebService"/>

                <String value="SampleJSP"/>

                <String value="SampleXML"/>

                <String value="SampleURLScraper"/>

            </Collection>

            <Collection name="News Channels">

                <String value="SampleRSS"/>

                <String value="Postit"/>

            </Collection>

            <Collection name="Search Channels">

                <String value="Search"/>

            </Collection>

            <Boolean name="defaultChannelIsMinimizable" value="true"/>

            <Boolean name="defaultChannelIsMinimized" value="false" advanced="true"/>

            <Boolean name="defaultChannelIsDetached" value="false" advanced="true"/>

            <Boolean name="defaultChannelIsDetachable" value="true"/>

            <Boolean name="defaultChannelIsRemovable" value="true"/>

            <Boolean name="defaultChannelHasFrame" value="true" advanced="true"/>

            <Boolean name="defaultChannelIsMovable" value="true"/>

            <Boolean name="defaultBorderlessChannel" value="false" advanced="true"/>

            <String name="defaultChannelColumn" value="1" advanced="true"/>

            <String name="defaultChannelRow" value="1" advanced="true"/>

            <Collection name="channelsIsMinimized" advanced="true"/>

            <Collection name="channelsIsDetached" advanced="true"/>

            <Collection name="channelsHasFrame" advanced="true"/>

            <Collection name="channelsIsMinimizable"/>

            <Collection name="channelsRow" advanced="true"/>

            <Collection name="channelsColumn" advanced="true"/>

            <Collection name="channelsIsMovable"/>

            <Collection name="channelsIsDetachable"/>

            <Collection name="channelsIsRemovable"/>

            <Collection name="borderlessChannels"/>

        </Properties>

    </Provider>

    Code Example 5-19  CustomJSPTCChannel.xml File  

    <?xml version="1.0" encoding="utf-8" standalone="no"?>

    <!DOCTYPE DisplayProfile SYSTEM "jar://resources/psdp.dtd">

    <Container name="CustomJSPTableContainerChannel" provider="CustomJSPTableContainerProvider">

        <Properties>

            <String name="title" value="Front Table Container Channel"/>

            <String name="contentPage" value="toptable.jsp"/>

            <String name="description" value="This is a test for front table containers" />

            <String name="Desktop-fontFace1" value="Sans-serif"/>

            <Collection name="categories">

                <String value="Personal Channels"/>

                <String value="Sample Channels"/>

                <String value="News Channels"/>

            </Collection>

            <Collection name="Personal Channels">

                <String value="UserInfo"/>

                <String value="MailCheck"/>

                <String value="Bookmark"/>

                <String value="App"/>

            </Collection>

            <Collection name="Sample Channels">

                <String value="SampleJSP"/>

                <String value="SampleXML"/>

            </Collection>

            <Collection name="News Channels">

                <String value="SampleRSS"/>

            </Collection>

            <Collection name="channelsRow" advanced="true">

                <String name="MailCheck" value="4"/>

                <String name="App" value="5"/>

                <String name="Bookmark" value="3"/>

                <String name="SampleRSS" value="2"/>

                <String name="SampleXML" value="2"/>

            </Collection>

            <Collection name="channelsIsRemovable" >

                <Boolean name="UserInfo" value="false"/>

            </Collection>

            <Collection name="amList">

                <String value="UserInfo"/>

                <String value="MailCheck"/>

                <String value="App"/>

                <String value="Bookmark"/>

            </Collection>

            <Collection name="pmList">

                <String value="MyFrontPageTabPanelContainer/Bookmark2"/>

                <String value="MailCheck"/>

                <String value="SampleXML"/>

                <String value="SampleRSS"/>

            </Collection>

        </Properties>

        <Available>

            <Reference value="UserInfo"/>

            <Reference value="MailCheck"/>

            <Reference value="App"/>

            <Reference value="Bookmark"/>

            <Reference value="MyFrontPageTabPanelContainer/Bookmark2"/>

            <Reference value="SampleJSP"/>

            <Reference value="SampleRSS"/>

            <Reference value="SampleXML"/>

        </Available>

        <Selected>

            <Reference value="UserInfo"/>

            <Reference value="MailCheck"/>

            <Reference value="App"/>

            <Reference value="Bookmark"/>

            <Reference value="MyFrontPageTabPanelContainer/Bookmark2"/>

            <Reference value="SampleJSP"/>

            <Reference value="SampleRSS"/>

            <Reference value="SampleXML"/>

        </Selected>

        <Channels>

        </Channels>

    </Container>

  7. Use the dpadmin command to upload the display profile fragments for this provider.
  8. For CustomJSPTableContainerProvider, use the dpadmin command to upload the CustomTCProvider.xml file and CustomTCChannel.xml file fragments in the display profile. That is, type:

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname CustomJSPTCProvider.xml

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname CustomJSPTCChannel.xml

  9. Create a new directory for the provider in /etc/opt/SUNWps/desktop/desktoptype. The directory for the provider is typically named after the provider.
  10. For the sample CustomJSPTableContainerProvider, create a directory called CustomJSPTableContainerChannel in /etc/opt/SUNWps/desktop/desktoptype.

  11. Develop and copy the JSP files for the provider in the newly created directory.
  12. For CustomJSPTableContainerProvider, copy files from /etc/opt/SUNWps/desktop/default/JSPTableContainerProvider to the /etc/opt/SUNWps/desktop/desktoptype/CustomJSPTableContainerChannel directory.

  13. Copy the resource file for the provider into /etc/opt/SUNWps/desktop/classes directory.
  14. For example, for the CustomJSPTableContainerProvider:

    1. Change directories to WebContainer/portal/web-apps/WEB-INF/classes directory.
    2. Type cp JSPTableContainerProvider.properties /etc/opt/SUNWps/desktop/classes/CustomJSPTableContainerProvider.properties.
  15. Access CustomJSPTableContainerProvider from your browser. To access, log in to the Desktop and type the following URL in your browser:
  16. http://hostname:port/portal/dt?provider=CustomJSPTableContainerChannel

TabContainer

A tab container aggregates the output of channels, providing a tabbed user interface to switch between them. A tab container’s configuration can be modified at runtime to vary which leaf channel is displayed.

A tab container provider generates its views primarily by being a client of table container objects. The TabContainer displays one of its contained channels at a time. It allows containers to be arranged onto virtual pages. The container can then switch between these pages allowing them to be physically viewed one at a time.

It allows the user to switch logically separate row-column displays. From the container perspective, each page is a table container. The tab container then contains multiple table containers, one for each page. By default, each tab in a tab container corresponds to a table container. The tab container can contain any number of table, single, or tab containers theoretically. Having a tab container inside a tab container is not advisable.

A tab container provider is a container provider that has a selected and available channels list, and allows getting and setting of these lists. Selected channels are the table containers that are considered active on the Desktop. Available channels are those that are available to be activated on the Desktop.

The TabContainer interface defines the interface for implementing a TabContainerProvider. A TabContainerProvider must implement this interface. This interface contains methods to query information about a TabContainer and to set the properties of a TabContainer. See the Javadocs for more information on the methods in this interface.

UnmodifiableTab

The UnmodifiableTab interface represents a tab that cannot be modified. This interface includes methods to:

ModifiableTab

The ModifiableTab interface represents an instance of the tab that can be modified. It extends UnmodifiableTab and all modifiable tabs inherit the characteristics of the UnmodifiableTab. This interface provides methods to allow the user to reset the display name (setDisplayname()) and description (setDesc()) of the predefined tab.

JSPTabContainerProvider

The JSPTabContainerProvider includes the functionality to enable display of JSPs in the TabContainer environment. It provides methods that allow the associated JSP files to use these methods, and generate a view that aggregates the output of channels, providing a tabbed user interface to switch between them.

The JSPTabContainerProvider class extends JSPContainerProviderAdapter and implements the TabContainer interface.

Extending the JSPTabContainerProvider

This section includes a sample extension to the JSPTabContainerProvider class. In this example, a new method called getTabTopics() is added to the JSPTabContainerProvider. The getTabTopics() method returns only the predefined tabs from the list of available tabs. This method is then called from the makeNewTab.jsp so that the Make New Tab page of the customTabContainer will only display the Predefined tab topics instead of displaying all the available tabs (predefined and user created).

To accomplish this:

  1. Extend the JSPTabContainerProvider and develop the CustomTabContainerProvider class file.
  2. The CustomTabContainerProvider class file in Code Example 5-20 includes a getTabTopics() method that returns only the predefined tabs from the list of available tabs.

    Code Example 5-20  CustomTabContainerProvider.java File  

    package custom;

    import com.sun.portal.providers.containers.jsp.tab.JSPTabContainerProvider;

    import com.sun.portal.providers.containers.jsp.tab.UnmodifiableTab;

    import com.sun.portal.providers.ProviderException;

    import java.util.List;

    import java.util.ArrayList;

    public class CustomTabContainerProvider extends JSPTabContainerProvider {

        public List getTabTopics() throws ProviderException {

            List availtabs = new ArrayList();

            List tabs = super.getAvailableTabs();

            for (int i=0; i < tabs.size(); i++) {

                UnmodifiableTab tab = (UnmodifiableTab)tabs.get(i);

                if (tab.isPredefined()) {

                    availtabs.add(tab);

                }

            }

            return availtabs;

        }

    }

  3. Compile the class and put it in the provider class base directory.
  4. The default directory for the class file is /etc/opt/SUNWps/desktop/classes. That is, build the JAR and copy the JAR into the provider class base directory. Or, just copy the class as a file into the provider class base directory. To compile the CustomTabContainerProvider.java file, enter:

    javac -d /etc/opt/SUNWps/desktop/classes -classpath portal-server-install-root/SUNWps/sdk/desktop/desktopsdk.jar:identity-server-install-root/S UNWam/lib/servlet.jar CustomTabContainerProvider.java

  5. Develop the display profile XML fragments for this provider and this provider’s channel.
  6. The display profile fragments for the CustomTabContainerProvider’s provider and channel are saved in CustomTabCProvider.xml (see Code Example 5-21) and CustomTabCChannel.xml (see Code Example 5-22) files respectively.

    Code Example 5-21  CustomTabCProvider.xml File  

    <?xml version="1.0" encoding="utf-8" standalone="no"?>

    <!DOCTYPE DisplayProfile SYSTEM "jar://resources/psdp.dtd">

    <Provider name="CustomTabContainerProvider" class="custom.CustomTabContainerProvider">

        <Properties>

            <String name="contentPage" value="tab.jsp"/>

            <Boolean name="showExceptions" value="false"/>

            <String name="title" value="*** Tab Container Provider ***"/>

            <String name="description" value="*** DESCRIPTION ***"/>

            <String name="refreshTime" value="" advanced="true"/>

            <String name="width" value="thin" advanced="true"/>

            <String name="fontFace1" value="Sans-serif"/>

            <String name="productName" value="Sun ONE Portal Server"/>

            <String name="presetThemeChannel" value="JSPPresetThemeContainer" advanced="true"/>

            <String name="customThemeChannel" value="JSPCustomThemeContainer" advanced="true"/>

            <Boolean name="isEditable" value="true" advanced="true"/>

            <String name="editType" value="edit_complete" advanced="true"/>

            <String name="editContainerName" value="JSPEditContainer" advanced="true"/>

    <Integer name="thin_popup_height" value="200"/>

            <Integer name="thin_popup_width" value="500"/>

            <Integer name="thick_popup_height" value="300"/>

            <Integer name="thick_popup_width" value="600"/>

            <Integer name="fullwidth_popup_height" value="500"/>

            <Integer name="fullwidth_popup_width" value="600"/>

            <Boolean name="defaultChannelIsMinimizable" value="true"/>

            <Boolean name="defaultChannelIsMinimized" value="false" advanced="true"/>

            <Boolean name="defaultChannelIsDetached" value="false" advanced="true"/>

            <Boolean name="defaultChannelIsDetachable" value="true"/>

            <Boolean name="defaultChannelIsRemovable" value="true"/>

            <Boolean name="defaultChannelHasFrame" value="true" advanced="true"/>

            <Boolean name="defaultChannelIsMovable" value="true"/>

            <Boolean name="defaultBorderlessChannel" value="false" advanced="true"/>

            <String name="defaultChannelColumn" value="1" advanced="true"/>

            <String name="defaultChannelRow" value="1" advanced="true"/>

            <Collection name="channelsIsMinimized" advanced="true"/>

            <Collection name="channelsIsDetached" advanced="true"/>

            <Collection name="channelsHasFrame" advanced="true"/>

            <Collection name="channelsIsMinimizable"/>

            <Collection name="channelsRow" advanced="true"/>

            <Collection name="channelsColumn" advanced="true"/>

            <Collection name="channelsIsMovable"/>

            <Collection name="channelsIsDetachable"/>

            <Collection name="channelsIsRemovable"/>

            <Collection name="borderlessChannels"/>

        </Properties>

    </Provider>

    Code Example 5-22  CustomTabCChannel.xml File  

    <?xml version="1.0" encoding="utf-8" standalone="no"?>

    <!DOCTYPE DisplayProfile SYSTEM "jar://resources/psdp.dtd">

    <Container name="CustomTabContainer" provider="CustomTabContainerProvider" merge="replace" lock="false" advanced="false">

        <Properties advanced="false" merge="fuse" lock="false" name="_properties" propagate="true">

            <String name="title" value="JSP Tab Container Channel" advanced="false"

    merge="replace" lock="false" propagate="true"/>

            <String name="description" value="This is a test for tab containers" advanced="false" merge="replace" lock="false" propagate="true"/>

            <String name="contentPage" value="tab.jsp" advanced="false" merge="replace" lock="false" propagate="true"/>

            <String name="editPage" value="tabedit.jsp" advanced="false" merge="replace" lock="false" propagate="true"/>

            <String name="startTab" value="MyFrontPageTabPanelContainer" advanced="false" merge="replace" lock="false" propagate="true"/>

            <Integer name="maxTabs" value="4" advanced="false" merge="replace" lock="false" propagate="true"/>

            <String name="makeTabProvider" value="JSPTabCustomTableContainerProvider" advanced="true" merge="replace" lock="false" propagate="true"/>

            <String name="makeTabChannel" value="JSPTabCustomTableContainer" advanced="true" merge="replace" lock="false" propagate="true"/>

            <Integer name="channelNumber" value="0" advanced="false" merge="replace" lock="false" propagate="true"/>

            <String name="contentChannel" value="JSPContentContainer" advanced="false" merge="replace" lock="false" propagate="true"/>

            <Collection name="TabProperties" advanced="false" merge="fuse" lock="false" propagate="true">

                <Collection name="MyFrontPageTabPanelContainer" advanced="false" merge="fuse" lock="false" propagate="true">

                    <String name="title" value="My Front Page" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <String name="desc" value="Your front page" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <Boolean name="removable" value="false" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <Boolean name="renamable" value="true" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <Boolean name="predefined" value="true" advanced="false" merge="replace" lock="false" propagate="true"/>

                </Collection>

                <Collection name="SamplesTabPanelContainer" advanced="false" merge="fuse" lock="false" propagate="true">

                    <String name="title" value="Samples" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <String name="desc" value="Sampless Tab" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <Boolean name="removable" value="true" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <Boolean name="renamable" value="true" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <Boolean name="predefined" value="true" advanced="false" merge="replace" lock="false" propagate="true"/>

                </Collection>

                <Collection name="JSPTabCustomTableContainer" advanced="false" merge="fuse" lock="false" propagate="true">

                    <String name="title" value="Make My Own Tab" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <String name="desc" value="Make from Scratch" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <Boolean name="removable" value="true" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <Boolean name="renamable" value="true" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <Boolean name="predefined" value="false" advanced="false" merge="replace" lock="false" propagate="true"/>

                </Collection>

                <Collection name="SearchTabPanelContainer" advanced="false" merge="fuse" lock="false" propagate="true">

                    <String name="title" value="Search" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <String name="desc" value="Search Tab" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <Boolean name="removable" value="true" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <Boolean name="renamable" value="true" advanced="false" merge="replace" lock="false" propagate="true"/>

                    <Boolean name="predefined" value="true" advanced="false" merge="replace" lock="false" propagate="true"/>

                </Collection>

            </Collection>

        </Properties>

        <Available advanced="false" merge="fuse" lock="false">

            <Reference value="MyFrontPageTabPanelContainer" advanced="false" merge="replace" lock="false" propagate="true"/>

            <Reference value="SamplesTabPanelContainer" advanced="false" merge="replace" lock="false" propagate="true"/>

            <Reference value="SearchTabPanelContainer" advanced="false" merge="replace" lock="false" propagate="true"/>

        </Available>

        <Selected advanced="false" merge="fuse" lock="false">

            <Reference value="MyFrontPageTabPanelContainer" advanced="false" merge="replace" lock="false" propagate="true"/>

            <Reference value="SamplesTabPanelContainer" advanced="false" merge="replace" lock="false" propagate="true"/>

            <Reference value="SearchTabPanelContainer" advanced="false" merge="replace" lock="false" propagate="true"/>

        </Selected>

        <Channels>

        </Channels>

    </Container>

  7. Use the dpadmin command to upload the display profile fragments for this provider.
  8. For CustomTabContainerProvider, use the dpadmin command to upload the CustomTabCProvider.xml file fragments in the display profile. That is, type:

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname CustomTabCProvider.xml

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname CustomTabCChannel.xml

  9. Create a new directory called CustomTabContainerProvider under /etc/opt/SUNWps/desktop/desktoptype.
  10. Copy all the required JSP files from /etc/opt/SUNWps/desktop/sampleportal/JSPTabContainerProvider to /etc/opt/SUNWps/desktop/desktoptype/CustomTabContainerProvider.
  11. Modify the makeNewTab.jsp file in /etc/opt/SUNWps/desktop/desktoptype/CustomTabContainerProvider to call getTabTopics().
  12. That is, replace the makeNewTab.jsp file with the makeNewTab.jsp file in Code Example 5-23.

    Code Example 5-23  Sample Modifications to makeNewTab.jsp File  

    <%--

    Copyright 2001 Sun Microsystems, Inc. All rights reserved.

    PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.

    --%>

    <%-- makeNewTab.jsp --%><%@ page import="custom.CustomTabContainerProvider" %>

    <table border=0 cellspacing=2 cellpadding=2 width="50%">

        <tr>

            <td align="right"><font face="<%=fontFace1%>" size="+0"><b>Tab Name:</b></font></td>

            <td><font face="<%=fontFace1%>" size="+0"><input type="text" name="JSPTabContainer.tabName" size="30"></font></td>

        </tr>

        <tr>

            <td align="right"><font face="<%=fontFace1%>" size="+0"><b>Tab Description:</b></font></td>

            <td><font face="<%=fontFace1%>" size="+0"><input type="text" name="JSPTabContainer.tabDesc" size="30"></font></td>

        </tr>

        <tr>

            <td align="right"><font face="<%=fontFace1%>" size="+0"><b>Tab Topics:</b></font></td>

            <td>

                <!-- start tab topic radios -->

                <table border="0" cellpadding="2" cellspacing="2">

                    <%

                        String checked = "";

                    %>

                    <tab:tabContainerProvider>

                    <%

                        CustomTabContainerProvider ctcp = (CustomTabContainerProvider)pageContext.getAttribute("JSPProvider");

                        List tabTopics = ctcp.getTabTopics();

                        for (int i=0; i < tabTopics.size(); i++) {

                            UnmodifiableTab tab = (UnmodifiableTab)tab.get(i);

                    %>

                    <TR>

                        <TD><INPUT TYPE="radio" NAME="JSPTabContainer.tabTopic" VALUE="<%=tab.getEncodedName%>" <%=checked%> ></TD>

                        <TD><FONT SIZE="-1" FACE="sans-serif"> <B> <%=tab.getDisplayname%> </B> <BR> <FONT SIZE="-1" FACE="sans-serif"> <%=tab.getDesc%> </FONT> </FONT> </TD>

                    </TR>

                    <%

                    }

                    %>

                    <%

                    checked = "CHECKED";

                    %>

                    <tab:getMakeTab id="makeTab"/>

                    <tab:obtainTab tab="$makeTab">

                    <%@ include file="makeTopic.jsp" %>

                    </tab:obtainTab>

                    </tab:tabContainerProvider>

                </table>

                <!-- end tab topic radios -->

                <input type="hidden" name="JSPTabContainer.make" value="make">

            </td>

        </tr>

    </table>

  13. Copy the resource file for the provider into /etc/opt/SUNWps/desktop/classes directory.
  14. For example, for the CustomJSPTableContainerProvider:

    1. Change directories to WebContainer/portal/web-apps/WEB-INF/classes directory.
    2. Type cp JSPTabContainerProvider.properties /etc/opt/SUNWps/desktop/classes/CustomTabContainerProvider.properties.
  15. Access CustomTabContainerProvider from your browser. To access, log in to the Desktop and type the following URL in your browser:
  16. http://hostname:port/portal/dt?provider=CustomTabContainer


Creating a Custom ContainerProvider

This section includes detailed instructions for creating a sample RouterContainerProvider. A RouterContainerProvider provides the interface for the user to select between a tab and table Desktop layout. Use the instructions (provided with the sample RouterContainerProvider) for developing your custom ContainerProvider by extending any one of the container providers.

  1. Based on whether the container provider is template based or JSP based container provider, create a new class which extends ContainerProviderAdapter or JSPContainerProviderAdapter.
  2. The new custom container provider can directly extend the container classes. For example:

    public class CustomContainerProvider extends *** {

        // Implement the methods

    }

  1. Compile the class file and put it in the provider class base directory.
  2. To compile the sample RouterContainerProvider, type:

    javac -d /etc/opt/SUNWps/desktop/classes -classpath portal-server-install-root/SUNWps/sdk/desktop/desktopsdk.jar:identity-server-install-root/S UNWam/lib/servlet.jar RouterContainerProvider.java

  3. Define the ContainerProvider provider and container channel XML fragments in the display profile.
  4. The sample RouterContainerProvider provider XML fragment in the RCProvider.xml file is shown Code Example 5-25.

    Code Example 5-25  RCProvider.xml File  

    <?xml version="1.0" encoding="utf-8" standalone="no"?>

    <!DOCTYPE DisplayProfile SYSTEM "jar://resources/psdp.dtd">

    <Provider name="RouterContainerProvider" class="com.sample.providers.containers.router.RouterContainerProvider">

        <Properties>

            <String name="contentPage" value="router.jsp"/>

            <String name="editPage" value="routeredit.jsp"/>

            <String name="processPage" value=""/>

            <Boolean name="showExceptions" value="false"/>

            <String name="title" value="*** Router Container Provider ***"/>

            <String name="description" value="*** DESCRIPTION ***"/>

            <String name="refreshTime" value="" advanced="true"/>

            <String name="width" value="thin" advanced="true"/>

            <String name="fontFace1" value="Sans-serif"/>

            <String name="productName" value="Sun ONE Portal Server"/>

            <Boolean name="isEditable" value="true" advanced="true"/>

            <String name="editType" value="edit_complete" advanced="true"/>

            <String name="editContainerName" value="JSPEditContainer" advanced="true"/>

            <String name="presetThemeChannel" value="JSPPresetThemeContainer" advanced="true"/>

            <String name="customThemeChannel" value="JSPCustomThemeContainer" advanced="true"/>

        </Properties>

    </Provider>

  1. Use the dpadmin command to upload the display profile fragments for this provider.
  2. For RouterContainerProvider, use the dpadmin command to upload the RCProvider.xml file and RCChannel.xml file fragments in to the display profile. That is, type:

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname RCProvider.xml

    portal-server-install-root/SUNWps/bin/dpadmin add -u dn_amadmin -w password -d distinguishedname RCChannel.xml

  3. Develop the templates or JSP files for the ContainerProvider.
  4. The sample RouterContainerProvider requires the following JSP files:

    • router.jsp (see Code Example 5-27) - This file includes the logic for displaying the tab or the table Desktop based on the user’s selcetion.
    • routeredit.jsp (Code Example 5-28) - This file has the logic for displaying the form where the user can select a tab or table Desktop.
    • Code Example 5-27  Sample router.jsp File  

      <%-- router.jsp --%>

      <%@ page import="com.sample.providers.containers.router.RouterContainerProvider"%>

      <%

      RouterContainerProvider rcp = (RouterContainerProvider)pageContext.getAttribute("JSPProvider");

      %>

      <%= rcp.getContainerProviderContext().getContent(request, response, null, rcp.getSelectedChannel())%>

      Code Example 5-28  Sample routeredit.jsp File  

      <%-- routeredit.jsp --%>

      <%@ page import="com.sample.providers.containers.router.RouterContainerProvider,

      com.sun.portal.providers.Provider,java.util.List,java.util.Map,java.util.ArrayList"

      %>

      <%@ page session="false" %>

      <%@ taglib uri="/tld/jx.tld" prefix="jx" %>

      <%@ taglib uri="/tld/desktop.tld" prefix="dt" %>

      <%@ taglib uri="/tld/desktopProviderContext.tld" prefix="dtpc" %>

      <%@ taglib uri="/tld/desktopContainerProviderContext.tld" prefix="dtcpc" %>

      <%@ taglib uri="/tld/desktopTheme.tld" prefix="dttheme" %>

      <%

          RouterContainerProvider rcp = (RouterContainerProvider)pageContext.getAttribute("JSPProvider");

          String selectedChannel = rcp.getSelectedChannel();

          pageContext.setAttribute( "rcp", rcp );

      %>

      <dt:obtainContainer container="$rcp">

          <dtpc:providerContext>

          <dtpc:getStringProperty key="fontFace1" id="fontFace"/>

          <jx:declare id="fontFace" type="java.lang.String"/>

          <%

              String fontFace1 = (String)pageContext.getAttribute("fontFace1", PageContext.REQUEST_SCOPE);

          %>

      <jsp:include page="header.jsp" flush="true"/>

      <form action="dt" name="routeredit_form" method=POST enctype="application/x-www-form-urlencoded">

          <input type=HIDDEN name="action" size=-1 value="process">

          <input type=HIDDEN name="provider" size=-1 value="JSPRouterContainer">

          <dt:getAvailableChannels id="availableChannel"/>

          <CENTER>

          <table border=0 cellspacing=1 cellpadding=0 width="75%" align="center">

              <tr>

                  <td bgcolor="#666699"><b><font face="<%=fontFace%>" color="#FFFFFF" size="+1">Please select a desktop for your front page</b></font>

                  </td>

              </tr>

              <tr>

                  <td>&nbsp;</td>

              </tr>

              <tr>

                  <td align=center>

                      <SELECT NAME="desktop">

                      <jx:forEach var="channel" items="$availableChannel">

                      <dtcpc:obtainChannelFromContainer channel="$channel">

                      <jx:declare id="channel" type="java.lang.String"/>

                      <dt:getTitle id="title" scope="request" silentException="true"/>

                      <%

                          String title = (String)pageContext.getAttribute("title", PageContext.REQUEST_SCOPE);

                          String selected = "";

                          if (selectedChannel.equals(channel)) {

                              selected = "selected";

                          }

                      %>

                      <OPTION <%=selected%> VALUE="<%=channel%>"><%=title%></OPTION>

                      </dtcpc:obtainChannelFromContainer>

                      </jx:forEach>

                      </SELECT>

                  </td>

              </tr>

          </table>

          </CENTER>

          <br>

          <font size=+0 face="<%=fontFace1%>">

              <input type=SUBMIT name="Submit" value="Finished" CLASS="button">

              <input type=BUTTON onClick="location=’<dtpc:getDesktopURL/>’" value="Cancel" CLASS="button">

          </font>

          <br>

          <p>

      </form>

      <br>

      <jsp:include page="menubar.jsp" flush="true"/>

      <%@ include file="footer.html" %>

          </dtpc:providerContext>

      </dt:obtainContainer>

  5. Make a directory for the files in /etc/opt/SUNWps/desktop/desktoptype directory and copy the files over to the newly created directory.
  6. For the sample RouterContainerProvider, type:

    mkdir /etc/opt/SUNWps/desktop/desktoptype/JSPRouterContainer

    cp router.jsp /etc/opt/SUNWps/desktop/desktoptype/JSPRouterContainer

    cp routeredit.jsp /etc/opt/SUNWps/desktop/desktoptype/JSPRouterContainer

  1. Modify the header.jsp file in /etc/opt/SUNWps/desktop/sampleportal/JSPTabContainer to add the text from tabheader.jsp file (as shown in Code Example 5-29).
  2. The HTML code to add a link to the edit page of the router container provider is shown (in bold) in the tabheader.jsp (see Code Example 5-29) file. Add this HTML code to /etc/opt/SUNWps/desktop/sampleportal/JSPTabContainer/header.jsp and /etc/opt/SUNWps/desktop/sampleportal/JSPTableContainerProvider/header.jsp files.

     

    Code Example 5-29  Sample tabheader.jsp File  

    <%--

        Copyright 2001 Sun Microsystems, Inc. All rights reserved.

        PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.

    --%>

    <%-- tabheader.jsp --%>

    <HTML>

        <CENTER>

        <TABLE BORDER="0" CELLPADDING="03" CELLSPACING="0" ALIGN="right" HEIGHT="29">

        <TR>

            <td><a href="dt?action=edit&provider=JSPRouterContainer" onMouseOver="over(’banner_home’)" onMouseOut="out(’banner_home’)"> <img name="banner_home" src="<dt:scontent/>/images/blueBullet.gif" width="13" height="9" border="0" alt=""></a></td>

            <td><a href="dt?action=edit&provider=JSPRouterContainer" onMouseOver="over(’banner_home’)" onMouseOut="out(’banner_home’)" class="noUnderline"> <span class="banner-links">Desktop Preference</span></a> </td>

        </TR>

        </TABLE>

        <img src="<dt:scontent/>/desktop/images/nothing.gif" height="8" width="0" border="0" alt=""><br>

  3. Modify the header.jsp file in /etc/opt/SUNWps/desktop/default/JSPTableContainerProvider to add the text from tableheader.jsp file (as shown in Code Example 5-30).
  4. The HTML code to add a link to the edit page of the router container provider is shown (in bold) in the tableheader.jsp (see Code Example 5-30) file.

    Code Example 5-30  Sample tableheader.jsp File  

    <%--

        Copyright 2001 Sun Microsystems, Inc. All rights reserved.

        PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.

    --%>

    <%-- tableheader.jsp --%>

    <HTML>

        <CENTER>

        <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">

        <TR>

            <td bgcolor="#CC0000" colspan="2"><img src="<dt:scontent/>/images/spacer.gif" width="1" height="3" alt=""></td>

        </TR>

        <TR>

            <td><a href="dt?action=edit&provider=JSPRouterContainer" onMouseOver="over(’banner_home’)" onMouseOut="out(’banner_home’)"> <img name="banner_home" src="<dt:scontent/>/images/blueBullet.gif" width="13" height="9" border="0" alt=""></a></td>

            <td><a href="dt?action=edit&provider=JSPRouterContainer" onMouseOver="over(’banner_home’)" onMouseOut="out(’banner_home’)" class="noUnderline"> <span class="banner-links">Desktop Preference</span></a> </td>

        </TR>

        </TABLE>

        <img src="<dt:scontent/>/desktop/images/nothing.gif" height="8" width="0" border="0" alt=""><br>

  5. Open a browser and log in to the administration console.
  6. The URL to access the administration console is http://hostname:port/amconsole.

  7. Change the default channel name to your ContainerProvider.
  8. To specify the default channel name, select Services from the View pull-down menu for your organization and select Portal Desktop. For the sample RouterContainerProvider, change the default channel name to JSPRouterContainer.

  9. Save the settings and log out of the administration console.
  10. Log in as the default user into the portal Desktop.
  11. Select the Desktop Preference Link from the menubar.
  12. The sample RouterContainerProvider provides the page to select Tabbed or Table Desktop.



Previous      Contents      Index      Next     


Copyright 2003 Sun Microsystems, Inc. All rights reserved.