Sun Java logo     Previous      Contents      Index      Next     

Sun logo
Sun Java System Portal Server 6 2004Q2 Developer's Guide 

Chapter 10
Creating a Custom ContainerProvider

This chapter 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 10-2.

    Code Example 10-2  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 Java System 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 10-4) - This file includes the logic for displaying the tab or the table Desktop based on the user’s selcetion.
    • routeredit.jsp (Code Example 10-5) - This file has the logic for displaying the form where the user can select a tab or table Desktop.
    • Code Example 10-4  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 10-5  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 10-6).
  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 10-6) 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 10-6  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 10-7).
  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 10-7) file.

    Code Example 10-7  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 2004 Sun Microsystems, Inc. All rights reserved.