Sun Java System Portal Server 7.1 Developer's Guide

ProcedureTo Develop the CustomSingleContainerProvider

  1. Extend the JSPSingleContainerProvider and develop the CustomSingleContainerProvider class file.

    The CustomSingleContainerProvider class overrides the JSPSingleContainerProvider.getSelectedChannel() method as shown below.


    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);
    	}
    }
  2. Compile the class and put it in the provider class base directory.

    The default directory for the class file is PortalServer-DataDir/portals/portal-ID/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 PortalServer-DataDir/portals/
    portal-ID/desktop/classes -classpath PortalServer-base/sdk/desktop/desktopsdk.jar:
    AccessManager-base/lib/servlet.jar CustomSingleContainerProvider.java
  3. Develop the display profile XML fragments for this provider.

    The display profile fragment for the CustomSingleContainerProvider’s provider is saved in CustomSCProvider.xml file (see below) and the display profile fragment for the CustomSingleContainerProvider’s channel is saved in CustomSCChannel.xml file (see below).

    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 Java System 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>

    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>
  4. Use the psadmin command to upload the display profile fragments for this provider.

    For the CustomSingleContainerProvider, use the psadmin add-display-profile sub command to upload the CustomSCProvider.xml file and CustomSCChannel.xml file XML fragments into the display profile. See the Sun Java System Portal Server 7.1 Command Line Reference for more information on this sub command.

  5. Create a new directory for the provider in PortalServer-DataDir/portals/portal-ID/desktop/desktoptype directory. The directory for the provider is typically named after the provider’s channel.

    For the sample CustomSingleContainerProvider, create a directory called CustomSingleContainer in PortalServer-DataDir/portals/portal-ID/desktop/desktoptype directory.

  6. Develop and copy the JSP files for the provider in the newly created directory.

    For the CustomSingleContainerProvider, copy files from PortalServer-DataDir/portals/portal-ID/desktop/default/JSPSingleContainerProvider to the PortalServer-DataDir/portals/portal-ID/desktop/desktoptype/CustomSingleContainer directory.

    1. Modify single.jsp file in the PortalServer-DataDir/portals/portal-ID/desktop/desktoptype/CustomSingleContainer directory as shown here:


      <%-- 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" %>
    2. Add a FULL_TOP channel to the container provider before testing the container provider.

      For example, for the CustomSingleContainerProvider, add the Search channel via the Portal Server administration console.

  7. Login to the Desktop and specify the URL in your browser to access the CustomSingleContainerProvider.


    http://hostname:port/portal-ID/dt?provider=CustomSingleContainer