以 PDF 格式下载本书 (498 KB)
Chapter 3 Presenting Information on the DesktopWhen you look at the Portal Desktop, you see a web page with columns and tabs along the top. Each column contains one or more channels (small windows). A channel contains a page that displays a specific type of information (such as news and search). You can use the tabs to navigate and separate content by categories. Each top level tab can have multiple nested tabs. The Enterprise Sample uses two tabs: Home and My Portal. The Home page has the nested tabs News and Career. This chapter discusses the following topics: For detailed information on channels and tabs, see the Sun Java System Portal Server 7 Developer Sample Guide. Understanding ChannelsTo the end user, a channel is a distinct area in the desktop, usually set off with a border and header row of icons. The icons enable users to configure the channel to their preference. Channels are administered from the Portal Server administration console. The administration console allows you to create channels from pre-built as well as custom providers and to change channel preferences. Channels can be implemented either as Providers or Portlets. Note – A “channel” is a Sun Java System Portal Server specific term. The portlet specification (JSR-168) does not use the term “channel”. Rather, the JSR-168 portlet specification uses the term “portlet window” to refer to a specific use of a portlet. Desktop ProvidersProviders are vertical channels that have a single use and can be reused (multiple channels can be created from a single provider) on a custom portal. Providers are Java class files based on the Provider API that can be used to construct both channels and page containers. You can use the Portal Server pre-built providers such as JSPProvider, URLScraperProvider, and XMLProvider to implement channels without the need to write code. For more information on the Provider API, see Sun Java System Portal Server 7 Developer’s Guide. JSR-168 PortletsPortlets function similarly to providers, however they are based on the API defined by the JSR-168 portlet specification. The Sun Java System Portal Server includes the following sample portlets:
Note – Use the Portal Server management console of command-line utilities to deploy these portlets at the Enterprise Sample organization level. The advantages to using portlets are as follows:
Note – For more information on the portlets, see Sun Java System Portal Server 7 Developer’s Guide. Adding Content to the Desktop Using ChannelsPortal administrators can add content to the Portal Desktop by adding provider and portlet channels. The following procedures discuss how to create a channel, modify it’s properties, add it to the desktop and then verify that it is being displayed. Suppose you want to create a channel, named MyChannel, that displays content from an external web page (for example, http://www.google.com). You use the following procedures: Creating a URLScraper Channel
|
window.<%=channelName% >= new Menu(); |
The variable, channelName, is a String that contains the unique name of the channel. This is required so that each channel menu has a unique identifier. Menu items can be added using the addMenuItem(String name, String action) method.
To add items which are not links
window.<%=channelName%>. addMenuItem("— Channel Menu —");
|
To add menu items with an associated action
window.<%=channelName%>.addMenuItem("Update Channel", "location=’<dtpc:getDesktopURL pathinfo="$pathInfo"/>’");
|
The above line shows how to add a menu item that redirects the browser to a different location when clicked.
To add a menu item that will open a popup window when clicked
window.<%=channelName%>.addMenuItem("Attach Channel",onClick="openUrlInParent(<dtpc:getDesktopURL/>?action=process&provider=<%=containerName%>&<%=containerName%>channelAction=attach&<%=containerName%>.targetProvider=<%=leafChannel%>’, true);
windowClosed(window.name);
window.close();");
|
Similar Javascript actions can be associated with each menu item. Actions are invoked when you click on the menu item. Here are some examples.
To add menu item separators use addMenuSeparator() method. For example:
window.<%=channelName%>.addMenuSeparator(); |
To modify the appearance and operations, customize the following properties:
window.<%=channelName%>.fontColorHilite = "#FFFFFF"; window.<%=channelName%>.menuHiliteBgColor = "#F68947"; window.<%=channelName%>.disableDrag = true; |
To invoke the menu:
<a href="javascript://" onClick="showMenu(window.<%=channelName%>);" title=" Click to view or modify channel options"><img src="<dt:scontent/>/enterprise/images/channel-button.gif" ></a> |
In the above example, when you click an image, the pull down menu displays. You may have to delete the compiled JSP class cache under PortalServer-DataDir/portal/portal-ID/desktop/compiled directory to force recompilation of the changed JSPs.
You can use tabs to categorize the information on your desktop. A tab is a web page. Each top level tab can have multiple nested tabs. The Enterprise Sample uses two tabs: Home and My Portal. The Home page has the nested tabs News and Career.
Every page is either one of the following:
The framework that displays tabs. It can hold nested tabs.
The framework that displays the rows and columns for a particular tab.
Before you can display the information within a channel, a tab and table container must be defined.
The Adventure Sports Cafe home page is a tab, and the News tab is nested within. A tab may specify a set of providers and/or portlets that it may contain. The home page consists of a type of table container which has a three column layout (thin, wide, thin).
The following procedures illustrate how to create and display information:
This procedure creates a new tab container by the name MyTabContainer and adds it to the list of Containers on the Portal Desktop administration page.
Login to the Portal Server management console as administrator (amadmin).
Click the Portals tab and click Portal-ID in the list of portals.
Select Enterprise Sample in the drop down list for Current Location.
Click the Manage Containers & Channels link.
In the left side frame, select ASCTabContainer in the View Type drop down list.
Select New Channel or Container link in the right side frame.
A popup window displays with a wizard to guide you through the steps for creating a new container.
Ensure that the correct values are selected for the portal and DN in the popup window. Select the Container radio button and click Next.
A message displays indicating successful creation of the container.
Select ASCTabContainerProvider from the Container Provider drop down list and click Next.
Provide a unique name for the container. For example, MyTabContainer.
Verify the information and click Close.
A message displays indicating successful creation of the container.
Select the link Show or Hide Channels and Containers on Portal Desktop link.
Ensure that the newly created container is listed in the list of containers Visible on the Portal Desktop list.
Verify the information and click Close to the Portal management page.
Click MyTabContainer under ASCTabContainer.
Change the description and title to My Top Level Tab and MyTab respectively in the Edit properties form.
Click Save to save the changes and return to the Portal administration page.
The newly created tab, MyTab, has no content. To add content to this tab, add another nested tab to MyTab.
The nested tab is an aggregation of channels, so it is created as a JSPTableContainerProvider.
Login to the Portal Server administration console as administrator (amadmin).
Click the Portals tab and click on My Portal in the list of portals.
In the drop down list for Current Location select Enterprise Sample.
Click the Manage Containers & Channels link.
In the left side frame, select ASCTabContainer/MyTabContainer in the View Type drop down list.
In the right side frame, Click on New Tab to launch the tab creation wizard.
In the pop up wizard window, do the following.
Ensure that the values selected for Portal and DN are correct and click Next.
Specify the properties for the new tab. The Tab Name property value has to be unique across all containers. Leave the Removable property as selected, and click Next.
Ensure that the {Parent Tab Container value is set to ASCTabContainer/MyTabContainer. Select the appropriate radio button for Would you like to add content to the new tab? and click Next.
If you opted to add content to the new tab, select channels to be displayed on the tab from the list of channels. Multiple channels (e.g., SampleXML) can be selected. Ensure that the Visible on Users Desktop option is selected.
Verify that you have entered the correct information and click Next.
Click Finish.
You can change the layout of columns by modifying their layout properties. The layout of the columns is determined by a numeric value you assign for each table container. Every channel can be assigned a thickness: thin or wide. All the thin and wide channels are then aggregated by the containers and displayed according to the selected channel layout.
The numeric value for the layout is unique and is used as the value for the layout property of the container. Table 3–1 shows the numeric values associated with the number of columns and their widths.
Table 3–1 Column Layout|
Layout |
Number of Columns |
Numeric value |
|---|---|---|
|
Thin - Wide |
Two |
1 |
|
Wide - Thin |
Two |
2 |
|
Thin - Wide - Thin |
Three |
3 |
The default layout of the NewsContainer is Thin - Wide - Thin. The Enterprise Sample defines column widths as layout=3 (Thin-Wide-Thin). To extend support for more layouts, refer to Adding New Layouts.
Login to the Portal Server administration console as administrator (amadmin).
Click the Portals tab and click on the portal-ID in the list of portals.
Select Enterprise Sample from the drop down list for Current Location.
Click the Manage Containers & Channels link.
Select NewsContainer in the left side frame.
Change layout property to a new numeric value (refer to layout table for valid values).
Click Save to save the changes.
Access the Enterprise Sample anonymous portal.
Login as Mary with the password mary.
The new layout for NewsContainer displays.
The Enterprise Sample relies on the CSS file for positioning of channels on the page. When creating new layouts or modifying existing layouts, review the Enterprise Sample CSS files under /var/opt/SUNWportal/portals/portal-ID/web-src/enterprise/css.
The various CSS file are available and are selected based on client browser type and client operating system. The CSS file selection logic can be found in writeCSS function in /var/opt/SUNWportal/portals/portal-ID/web-src/enterprise/js/util.js.
The Enterprise Sample supports layout=3 (THIN-WIDE-THIN) layout.
You can extend the code to support multiple layouts by modifying the file /var/opt/SUNWportal/portals/portal-ID/desktop/enterprise_sample/JSPTableContainerProvider/table.jsp.
Replace the code in the table.jsp Listing 1 with the code in Listing 2.
Listing 1
<!-- Begin Left Column of Channels --> <div class="tableContainerColumnLeft"> <dttable:getColumns id="channels" column="left" scope="request"/> <jsp:include page="column.jsp" flush="true"> <jsp:param name="columnName" value="center"/> </jsp:include> </div> <!-- End Left Column of Channels --> <!-- Begin Middle Column of Channels --> <div class="tableContainerColumnCenter""> <dttable:getColumns id="channels" column="center" scope="request"/> <jsp:include page="column.jsp" flush="true"> <jsp:param name="columnName" value="center"/> </jsp:include> </div> <!-- End Middle Column of Channels --> <!-- Begin Right Column of Channels --> <div class="tableContainerColumnRight"> <dttable:getColumns id="channels" column="right" scope="request"/> <jsp:include page="column.jsp" flush="true"> <jsp:param name="columnName" value="center"/> </jsp:include> </div> <!-- End Right Column of Channels --> |
Listing 2
You can find the original code in /var/opt/SUNWportal/portals/portal-ID/desktop/enterprise_sample/JSPTableContainerProvider/table.jsp starting at Line # 78
<dtpc:getIntegerProperty key="layout" id="layout"/>
<jx:declare id="layout" type="Integer"/>
<!-- start table-container -->
<% if (layout == 1) { %>
<!-- THIN-WIDE layout -->
<!-- Begin Left Column of Channels -->
<div class="tableContainerColumnLeft">
<dttable:getColumns id="channels" column="left" scope="request"/>
<jsp:include page="column.jsp" flush="true">
<jsp:param name="columnName" value="left"/>
</jsp:include>
</div>
<!-- End Left Column of Channels -->
<!-- Begin Right Column of Channels -->
<div class="tableContainerColumnCenter">
<dttable:getColumns id="channels" column="right" scope="request"/>
<jsp:include page="column.jsp" flush="true">
<jsp:param name="columnName" value="center"/>
</jsp:include>
</div>
<!-- End Right Column of Channels -->
<% } else if (layout == 3) { %>
<!-- THIN-WIDE-THIN layout -->
<!-- Begin Left Column of Channels -->
<div class="tableContainerColumnLeft">
<dttable:getColumns id="channels" column="left" scope="request"/>
<jsp:include page="column.jsp" flush="true">
<jsp:param name="columnName" value="left"/>
</jsp:include>
</div>
<!-- End Left Column of Channels -->
<!-- Begin Middle Column of Channels -->
<div class="tableContainerColumnCenter">
<dttable:getColumns id="channels" column="center" scope="request"/>
<jsp:include page="column.jsp" flush="true">
<jsp:param name="columnName" value="center"/>
</jsp:include>
</div>
<!-- Begin Right Column of Channels -->
<div class="tableContainerColumnRight">
<dttable:getColumns id="channels" column="right" scope="request"/>
<jsp:include page="column.jsp" flush="true">
<jsp:param name="columnName" value="right"/>
</jsp:include>
</div>
<!-- Begin Right Column of Channels -->
<% } else if (layout == 4) { %>
<!-- Add custom layout here -->
<% } %>
</div><!-- end table-container -->
|
Redeploy the portal web application using the utility: /opt/SUNWportal/bin/psadmin redeploy adminuser amAdmin -passwordfile password-filename -portal portal-ID.
This section helps you to create a create a subtab title “My Wiki” under the My Portal tab with a wiki channel. The portlet is available to the employees of your organization and they can start collaborating via the wiki features.
The following procedures are described in this section:
Login to the Portal Server administration console as administrator (amadmin).
Click the Portals tab.
Click the portal-ID in the Portals list.
Select Enterprise Sample [Org] in the Select DN list.
Click Manage Containers and Channels.
Click MyPortalContainer under ASCTabContainer.
Click New Channel or Container in the MyPortalContainer Task and Properties page.
In the New Channel or Container wizard, specify the following:
Click WikiContainer under MyPortal Container.
In the WikiContainer tasks and properties page, modify the desired property values.
For example you might want to change the channel title to My Wiki.
Click Save.