bea.com | products | dev2dev | support | askBEA |
![]() |
![]() |
|
![]() |
e-docs > WebLogic Platform > WebLogic Portal > JavaServer Page Guide > Portal and Portlet Management JSP Tags |
JavaServer Page Guide
|
Portal and Portlet Management JSP Tags
WebLogic Portal includes a set of JSP tags designed to facilitate the development of portals and portlets. Use these predefined tags to reduce the amount of Java code required in your JSP page. This topic explains how to import each set of tags into your Web pages, and describes the purpose of each tag.
In the following tables, the Required column specifies if the attribute is required (yes) or optional (no). In the R/C column, C means that the attribute is a Compile time expression, and R means that the attribute can be either a Request time expression or a Compile time expression.
This topic includes the following sections:
Portlet Tag Libraries
The following section describes the portlet tags and their attributes.
<portlet:createWebflowURL>
The <portlet:createWebflowURL> tag is used in a portlet to dynamically create a Webflow URL in a JSP. The Webflow URL may include the protocol, domain name, port, Web application URI, WebflowServlet URI, and query string. Table 2-1 describes the <portlet:createWebflowURL> tag attributes.
Example
Listing 2-1 illustrates how to use the <portlet:createWebflowURL> JSP tag.
Listing 2-1 Using <portlet:createWebflow>
<%@ taglib uri="portlet.tld" prefix="portlet" %>...
<center>
<font size="6" color="green">Portlet 2 - Page 1</font><BR>
<p>
<p>
Portlet Webflow Test:
<p>
<a href="<portlet:createWebflowURL event="switch"/>">Next Page</a>
<p>
</center>
<portlet:form>
The <portlet:form> tag is used in a JSP to dynamically generate an HTML form tag. This tag is not as sophisticated as the <portlet:validatedForm> tag, but is simpler. See <portlet:validatedForm> tag for more information. Table 2-2 describes the <portlet:form> tag attributes.
<portlet:validatedForm>
The <portlet:validatedForm> tag is used to dynamically generate HTML forms that can be validated. When a Web site visitor enters invalid information, the visitor's input is preserved and redisplayed with an appropriate error message. Table 2-3 describes the <portlet:ValidatedForm> tag attributes.
Example
The following code sample illustrates how to use the <portlet:validatedForm> JSP tag:
Listing 2-2 Using <portlet:validatedForm>
<%@ taglib uri="portlet.tld" prefix="portlet" %>
<%@ taglib uri="webflow.tld" prefix="webflow" %>
<center>
<% String validStyle="color: black; font-family: Arial"; %>
<% String invalidStyle="color: darkred; font-style: Arial"; %>
<%-- If there was an InvalidFormDataException thrown display the message --%>
<font size="3" color="darkred"><portlet:getException/></font>
<br>
<webflow:getProperty id="welcomeStr" property="WELCOME_STRING"
type="java.lang.String" scope="request" namespace="portlet3"/>
<% if (welcomeStr == null || welcomeStr.length() < 1)
{
%>
<portlet:validatedForm event="button.go" applyStyle="message" messageAlign="right"
validStyle="<%=validStyle%>" invalidStyle="<%=invalidStyle%>"
unspecifiedStyle="<%=validStyle%>" >
<p>
Welcome :
<webflow:text name="welcome" value="Hello" size="15" maxlength="30" /> <br>
<input type="submit" name="Submit"/> </portlet:validatedForm>
<br>
<%
}
else
{
%>
<font size="5" color="green"><%= welcomeStr %></font>
<%
}
%>
</center>
<p>
<portlet:createPortletEditURL>
The <portlet:createPortletEditURL> tag generates a webflow URL that represents editing a portlet.
Example
Listing 2-3 illustrates how to use the <portlet:createPortletEditURL> JSP tag:
Listing 2-3 Using <portlet:createPortletEditURL>
}
if (PortletRenderHelper.isEditable(request))
{
%>
<td width="1%" valign="middle"><a href="<portlet:createPortletEditURL httpsInd='http'/>">
<img src="<webflow:createResourceURL resource='<%=imagesPath+"portlet_edit.gif"%>'/>" hspace="1" vspace="2" border="0" alt="Edit" align="absmiddle"></a></td>
<%
<portlet:createPortletUneditURL>
The <createPortletUneditURL> JSP tag generates a webflow URL that represents leaving the edit URL and moving to another page. Table 2-5 describes the <portlet:createPortletUneditURL> tag attributes.
<portlet:createPortletMinimizeURL>
The <portlet:createPortletMinimizeURL> JSP tag generates a webflow URL that represents minimizing a portlet. Table 2-6 describes the <portlet:createPortletMinimizeURL> tag attributes.
Example
Listing 2-4 illustrates how to use the <portlet:createPortletMinimizeURL> JSP tag:
Listing 2-4 Using <portlet:createPortletMinimizeURL>
}
if (PortletRenderHelper.isMinimizable(request))
{
%>
<td width="1%" valign="middle"><a href="<portlet:createPortletMinimizeURL httpsInd='http'/>">
<img src="<webflow:createResourceURL resource='<%=imagesPath+"portlet_min.gif"%>'/>" hspace="1" vspace="2" border="0" alt="Minimize" align="absmiddle"></a></td>
<%
<portlet:createPortletUnminimizeURL>
The <portlet:createPortletUnminimizeURL> tag generates a webflow URL that represents unminimizing a portlet. Table 2-7 describes the <portlet:createPortletUnminimizeURL> tag attributes.
Example
Listing 2-5 illustrates how to use the <portlet:createPortletUnminimizeURL> JSP tag:
Listing 2-5 Using <portlet:createPortletUnminimizeURL>
<%-- Create a link to unminimize the portlet --%>
<td width="1%" valign="middle">
<a href="<portlet:createPortletUnminimizeURL/>">
<img src="<webflow:createResourceURL resource=
'<%=imagesPath+"portlet_unmin.gif"%>'/>" hspace="1" vspace="2"
border="0" alt="Restore" align="absmiddle"></a></td>
<portlet:createPortletMaximizeURL>
The <portlet:createPortletMaximizeURL> JSP tag generates a webflow URL that represents maximizing a portlet. Table 2-8 describes the <portlet:createPortletMaximizeURL> tag attributes.
Example
Listing 2-6 illustrates how to use the <portlet:createPortletMaximizeURL> JSP tag:
Listing 2-6 Using <portlet:createPortletMaximizeURL>
<%
}
if (PortletRenderHelper.isMaximizable(request))
{
%>
<td width="1%" valign="middle">
<%-- Create the link to maximize the portlet --%>
<a href="<portlet:createPortletMaximizeURL
httpsInd='http'/>"><img src=
"<webflow:createResourceURL
resource='<%=imagesPath+"portlet_max.
gif"%>'/>" hspace="1" vspace="2" border="0"
alt="Maximize" align="absmiddle"></a></td>
<%
<portlet:createPortletUnmaximizeURL>
The <portlet:createPortletUnmaximizeURL> JSP Tag generates a webflow URL that represents unmaximizing a portlet. Table 2-8 describes the <portlet:createPortletUnmaximizeURL> tag attributes.
Example The following code sample illustrates how to use the <portal:createPortletUnamximizeURL> JSP tag: Listing 2-7 Using <portlet:createPortletUnmaximizeURL> <portlet:createPortletFloatURL>
<%-- Create a link to unmaximize the portlet --%>
<td width="1%" valign="middle">
<a href="<portlet:createPortletUnmaximizeURL/>">
<img src="<webflow:createResourceURL
resource='<%=imagesPath+"portlet_unmax.
gif"%>'/>" hspace="1" vspace="2" border="0"
alt="Unmaximize"></a></td>
The <portlet:createPortletFloatURL> tag generates a webflow URL that represents creating a "floating" portlet, which is a portlet that appears in an independent window. Table 2-10 describes the <portlet:createPortletFloatURL> tag attributes.
. Example Listing 2-8 illustrates how to use the <portal:createPortletFloatURL> JSP tag: Listing 2-8 Using <portlet:createPortletFloatURL> <portlet:getException>
<%
}
if (PortletRenderHelper.isFloatable(request))
{
url = portletState.getUrl(Portlet.URL_CONTENT);
%>
<util:validURL url="<%=url%>">
<% request.setAttribute( "fullscreenPortletURL", url); %>
<td width="1%" valign="middle">
<a href="javascript:submitForm();"
onClick="openBrWindow('<portlet:createPortletFloatURL httpsInd='http'/>','<%= portletWindowName%>', 'scrollbars=yes,width=780,height=550'); return false;">
<img src="<webflow:createResourceURL resource='<%=imagesPath+"portlet_float.gif"%>'/>" hspace="1" vspace="2" border="0" alt="Float" align="absmiddle"></a></td>
</util:validURL>
The <portlet:getException> tag is used to retrieve the exception or message thrown by a webflow processor. This can be the message associated with a InvalidFormFieldException or ProcessingException. This tag can be inlined in which it calls getMessage() on the exception or return a scripting variable representing the exception itself. Table 2-11 describes the
Portal Tag Libraries
The following sections describe the portal tags and their attributes.
<portal:createWebflowURL>
The <portal:createWebflowURL> tag is used in a JSP to dynamically create a Webflow URL in a JSP. The Webflow URL may include the protocol, domain name, port, Web application URI, WebflowServlet URI, and query string. Table 2-12 describes the <portal:createWebflowURL> tag attributes.
<portal:form>
The <portal:form> tag is used in a JSP to dynamically generate an HTML form tag. This tag is not as sophisticated as the <portal:validatedForm> tag, but is simpler. For more information about the <portal:validatedForm> tag, refer to the next section. Table 2-13 describes the <portal:form> tag attributes.
<portal:validatedForm>
The <portal:validatedForm> tag is used to dynamically generate HTML forms that can be validated. When a Web site visitor enters invalid information, the visitor's input is preserved and redisplayed with an appropriate error message. Table 2-14 describes the
<portal:createPortalPageChangeURL>
The <portal:createPortalPageChangeURL> tag generates a webflow URL for a page change event.
Example
Listing 2-9 illustrates how to use the <portal:createPortalPageChangeURL> JSP tag:
Listing 2-9 Using <portal:createPortalPageChangeURL>
if (DISPLAY_TEXT_LINKS)
{
if (portalPageName.equals(selectedPage))
{
%>
<td class="tabselected" nowrap align="center">
<b>
<a href="<ptl:createPortalPageChangeURL pageName='<%= portalPageName %>'/>"><span class="tabselected"><%=portalPageName%></span></a></b></td>
<td class="tabselected" WIDTH="2"><b> </b></td>
<%
}
else
{
%>
<td class="tabunselected" nowrap align="center">
<b>
<a href="<ptl:createPortalPageChangeURL pageName='<%= portalPageName %>'/>"><span class="tabunselected"><%=portalPageName%></span></a></b></td>
<td class="tabunselected" WIDTH="2"><b> </b></td>
<% }
Utility Tag Libraries
The following section describes the utility tags and their attributes.
<util:validURL>
Processes the body if the supplied url is not null and greater than three characters long. Table 2-16 describes the <util:validURL> tag attributes.
<util:invalidURL>
The <utility:invalidURL> tag processes the body if the supplied url is null or less than four characters long. Table 2-17 describes the <util:invalidURL> tag attributes.
Example
The following code sample illustrates how to use the <utility:invalidURL> as well as the <utility:validURL> JSP tag:
Listing 2-10 Using <utility:invalidURL> and <utility:validURL>
<%
// First try for an alternate header if one doesn't exist use
// the regular header
url = portletState.getUrl(Portlet.URL_ALTERNATE_HEADER);
debug.out("Alternate header: " + url);
%>
<util:invalidURL url="<%=url %>">
<% url = portletState.getUrl(Portlet.URL_HEADER); %>
</util:invalidURL>
<util:validURL url="<%=url %>">
<table cellpadding="4" cellspacing="0" width="100%"
class="portletheader">
<tr>
<td width="100%">
<jsp:include page="<%=url%>"/>
</td>
</tr>
</table>
</util:validURL>
<%
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |