Sun Java System Portal Server 7 Developer's Guide

Example 2

In the following example, the SimpleUserInfoProvider overrides the processEdit() method of the JSPProvider. It reads the common name that is input in the edit page JSP, and then it is read from the processEdit() method. The value is set to the backend store. To accomplish this:

ProcedureTo Develop the SimpleUserInfoProvider

Steps
  1. Extend the JSPProvider and develop the SimpleUserInfoProvider class.

    The SimpleUserInfoProvider class overrides the JSPProvider processEdit() method as shown in Example 2.


    SimpleUserInfoProvider.java File
    package custom;
    
    import java.net.URL;
    
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpServletRequest;
    
    import com.sun.portal.providers.ProviderException;
    import com.sun.portal.providers.jsp.JSPProvider;
    
    public class SimpleUserInfoProvider extends JSPProvider {
        public URL processEdit(
        HttpServletRequest req, HttpServletResponse res
        ) throws ProviderException {
            //get the common name from the request and set it into the backend store
            getProviderContext().setStringAttribute("cn",(String)req.getParameter("cn"));
            return null;
        }
    }
  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 SimpleUserInfoProvider.java file, type:


    javac -d PortalServer-DataDir/portals/portal-ID/desktop/classes -classpath PortalServer-base/sdk/desktop/desktopsdk.jar:AccessManager-base/lib/servlet.jar SimpleUserInfoProvider.java
  3. Develop the display profile XML fragment for this provider and this provider’s channel.

    The display profile fragment for the SimpleUserInfoProvider’s provider is saved in SimpleUIProvider.xml file and the display profile fragment for the SimpleUserInfoProvider’s channel is saved in SimpleUIPChannel.xml file.


    SimpleUIProvider.xml File
    <?xml version="1.0" encoding="utf-8" standalone="no"?>
    <!DOCTYPE DisplayProfile SYSTEM "jar://resources/psdp.dtd">
    
    <Provider name="SimpleUserInfoProvider" class="custom.SimpleUserInfoProvider">
        <Properties>
            <String name="title" value="Simple User Information Provider"/>
            <String name="description" value="My UserInformation"/>
            <String name="refreshTime" value="0" advanced="true"/>
            <Boolean name="isEditable" value="false" advanced="true"/>
            <String name="editType" value="edit_subset" advanced="true"/>
            <String name="width" value="thin" advanced="true"/>
            <String name="helpURL" value="desktop/usedesk.htm" advanced="true"/>
            <String name="fontFace1" value="Sans-serif"/>
            <String name="productName" value="Sun Java System Portal Server"/>
            <String name="contentPage" value="simpleUserInfoContent.jsp"/>
            <String name="editPage" value="simpleUserInfoEdit.jsp"/>
        </Properties>
    </Provider>

    In SimpleUIPChannel.xml, note that the SimpleUserInfoProvider channel definition is embedded inside JSPTableContainer thus making the channel only visible via the container.


    SimpleUIPChannel.xml File
    <?xml version="1.0" encoding="utf-8" standalone="no"?>
    <!DOCTYPE DisplayProfile SYSTEM "jar://resources/psdp.dtd">
    
    <Container name="JSPTableContainer" provider="JSPTableContainerProvider">
        <Properties>
            <Collection name="Personal Channels">
                <String name="SimpleUserInfo"/>
            </Collection>
            <Collection name="channelsColumn">
                <String name="SimpleUserInfo" value="3"/>
            </Collection>
        </Properties>
        <Available>
            <Reference value="SimpleUserInfo"/>
        </Available>
        <Selected>
            <Reference value="SimpleUserInfo"/>
        </Selected>
        <Channels>
            <Channel name="SimpleUserInfo" provider="SimpleUserInfoProvider">
                <Properties>
                    <String name="processPage" value="simpleUserInfoDoedit.jsp"/>
                </Properties>
            </Channel>
        </Channels>
    </Container>
  4. Use the psadmin command to upload the display profile fragments for this provider.

    For the SimpleUserInfoProvider, use the psadmin add-display-profile command to upload the SimpleUIProvider.xml file and use the psadmin modify-display-profile command to upload the SimpleUIPChannel.xml file XML fragments in the display profile. For more information on these subcommands, see the Sun Java System Portal Server 7 Command-Line Reference.

  5. Create a channel directory under the template root directory.

    By default, the template root directory is PortalServer-DataDir/portals/portal-ID/desktop/desktoptype. For this example, create an SimpleUserInfo directory under PortalServer-DataDir/portals/portal-ID/desktop/desktoptype directory.

  6. Develop and copy all the JSP files over to the newly created directory (in Step 5).

    For example, develop the simpleUserInfoContent.jsp and simpleUserInfoEdit.jsp files and copy them over to the newly created PortalServer-DataDir/portals/portal-ID/desktop/desktoptype/SimpleUserInfo directory.

  7. Access the SimpleUserInfo channel inside the JSPTableContainer. To access, log in to the Desktop and type the following URL in your browser:


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