The <portal-fmt/> tags are used to provide enhanced
portal formatting capabilities.
The following table provides a brief description of each tag.
Note: Do not use portal tags in portlet JSPs. The following tags are
only for use in theme and skin JSPS.
Table 1. Descriptions of <portal-fmt/> tagsTag |
Description |
<portal-fmt:answer/> |
Returns the answer text for a given key in the specified language.
This tag should be used only within a <portal-skin:portletRender/>
or <portal-core:pageRender/> tag. |
<portal-fmt:bidi/> |
This tag is used to support the display of bidirectional languages. |
<portal-fmt:description/> |
Provides the description of an object that implements the Localized interface.
This tag can be used in both theme and skin JSPs. |
<portal-fmt:identification/> |
Transforms a String representation of the ObjectID
into an ObjectID. Also transforms an ObjectID into a String representation
of the ObjectID. |
<portal-fmt:problem/> |
Returns the problem text for a given key in the specified language.
This tag should be used only within a <portal-skin:portletRender/>
or <portal-core:pageRender/> tag. |
<portal-fmt:text/> |
Returns the text for a given key in the specified language.
For information about how to set the bundle refer to the portletExt:setBundle tag
under JSP tags for standard portlets. |
<portal-fmt:textParam/> |
If the text that is retrieved contains placeholders in the
form of "{0}", "{1}", "{2}", ..., these can be set using this tag.
This tag should be used only in the body of the <portal-fmt:text/>
tag. |
<portal-fmt:title/> |
Provides the title of an object that implements the Localized
interface. This tag can be used in both theme and skin JSPs. |
<portal-fmt:user/> |
If the user is logged in, this tag returns one of the specified
values of attribute. |
Detailed descriptions of the <portal-fmt/>
tags
The following section provides detailed descriptions
of the <portal-fmt/> JSP tags:
- <portal-fmt:answer bundle="bundle">
- Returns the answer text for a given key in the specified language.
The following keys can be looked up in the resource bundle.
- content.not.available.answer
- login.invalid.answer
- password.invalid.answer
- userid.invalid.answer
- portlet.not.active.answer
- portlet.not.authorized.answer
- portlet.not.available.answer
- portlet.title.not.available.answer
Each key corresponds to a problem key (without the .answer suffix).
See the <portal-fmt:problem> tag
for a complete description of each problem and a complete example.
- <portal-fmt:bidi dir="rtl|ltr" attribute="portlet"
locale="locale">
- This tag is used to support the display of bidirectional languages.
Bidirectional languages are those that are typically read from right
to left except when left-to-right text strings are displayed (for
example, URLs, code samples, or directory and file names).
Attributes:
- dir
Indicates the normal direction of text in the
language. This attribute is required.
- For dir="rtl", the tag content is written only if the client's
locale belongs to a bidirectional language. This is the default setting
if dir is not specified.
- For dir="ltr", the tag content is written only if the client's
locale does not belong to a bidirectional language.
- attribute="portlet"
Indicates that the text is for
the title of a portlet. This attribute is optional.
- locale
The tag content is written only if the language
belongs to the bidirectional languages that are defined by the portal.
If attribute is specified, locale is ignored.
WebSphere® Portal JSPs
use this tag in a BidiInclude.jsp that creates the
following scripting variables which, in many cases, are easier to
use and recommended over the <portal-fmt:bidi/> tag.
- <%=bidiAlignRight%>
- resolves as the value left for BIDI languages, right for
all other languages. This is primarily intended for text alignment,
such as in a table cell.
- <%=bidiAlignLeft%>
- resolves as the value right for BIDI languages, left for
all other languages. This is primarily intended for text alignment,
such as in a table cell.
- <%=bidiImageRight%>
- resolves as the value Left for BIDI languages, Right for
all other languages. This is primarily intended to append the value
to the filename for an image. For example, the theme directory provide
two image files that can be used for the portlet window, Album_Border_TopLeft.gif and Album_Border_TopRight.gif.
- <%=bidiImageLeft%>
- resolves as the value Right for BIDI languages, Left for
all other languages. This is primarily intended to append the value
to the filename for an image.For example, the theme directory provide
two image files that can be used for the portlet window, Album_Border_TopLeft.gif and Album_Border_TopRight.gif.
- <%=bidiImageRTL%>
- resolves to the value _rtl for BIDI languages, null for all other
languages. This is primarily intended for graphic images. For example,
the skin previews provide two image files to preview the skin, preview.gif and preview_rtl.gif.
The following example shows how a directional image
is invoked. The <%=bidiImageRTL%> scripting variable is used
to invoke the appropriate icon, for example,
tab_next_rtl.gif,
when the locale belongs to a bidirectional language.
<img alt="<portal-fmt:text key="link.next" bundle="nls.engine"/>"
src="<portal-logic:urlFindInTheme file='<%="tab_next"+bidiImageRTL+".gif"%>'/>"
border="0" align="absmiddle">
- <portal-fmt:description locale="locale"
varname="scripting_variable" />
- Provides the localized description of the Object specified by varname or
of the navigation node set in the <portal-navigation:navigationLoop/>
tag. This tag can be used in both theme and skin JSPs.
Attributes
- locale
- Optional. Overrides the current language setting.
- varname
- Optional. Specifies the name of the scripting variable holding
the localized object. The <portal:navigation/> tag sets this
object to <%=wpsNavNode%>.
<portal-navigation:navigationLoop>
<!-- write the description of the node in the current locale -->
<portal-fmt:description varname="<%=wpsNavNode%>"/>
<!-- write the description of the node in chinese -->
<portal-fmt:description varname="<%=wpsNavNode%>" locale="zh"/>
</portal-navigation:navigationLoop>
- <portal-fmt:identification action="setting"
object="object_name" var="variable_name"/>
- Transforms a String representation of the ObjectID into an ObjectID.
Also transforms an ObjectID into a String representation of the ObjectID.
Attributes:
- action
- Specifies the operation to be done on the given object. Allowed
values are "serialize" and "deserialize"
- object
- Specifies the object which needs to be handled. Allowed values
are an object of the type com.ibm.portal.Identifiable or java.lang.String.
- var
- Specifies the name of the scripting variable where the generated
value will be stored.
The following example shows how this tag is used
to set an identifiable object and translate it to a String representation:
<portal-fmt:identification object="<%=contentNode%>" action="serialize" var="oid_string">
<p><portal-fmt:title varname="<%=contentNode%>"/> has the ObjectID <%=oid_string%></p>
</portal-fmt:identification>
The following example
shows how this tag is used to set a unique name (this could also be
an object ID string representation) and translate it to an object
ID:
<portal-fmt:identification object="ibm.portal.Home" action="deserialize" var="oid">
<% if (oid instanceof com.ibm.portal.ObjectID) { %>
<p>This is how it works</p>
<% } %>
</portal-fmt:identification>
- <portal-fmt:problem bundle="bundle">
- Returns the problem text for a given key in the specified language.
The following keys can be looked up in the resource bundle.
- content.not.available - Occurs if there is no page content
that can be displayed. Used in the <portal-core:pageRender/> tag.
- login.invalid - Occurs when the user ID, password, or both
are not valid. This is used in the Login screen.
- password.invalid - Occurs when the password field is empty
during login. This is used in the Login screen.
- portlet.not.active - Occurs when a portlet is not active.
Used in the <portal-skin:portletRender/> tag.
- portlet.not.authorized - Occurs when a user does not have
appropriate permissions on a portlet. Used in the <portal-skin:portletRender/> tag.
- portlet.not.available - Occurs when an error occurs that
prevents a portlet from rendering. Used in the <portal-skin:portletRender/> tag.
- portlet.title.not.available - Occurs when a portlet title
is not available. Used in the <portal-skin:portletTitle/> tag.
- userid.invalid - Occurs when the user ID field is empty
during login. This is used in the Login screen.
There is a corresponding answer key for each problem (see
the <portal-fmt:answer/> tag).
The
resource bundle must be located in a directory that is on the classpath
of the WebSphere Portal enterprise
application. It is recommended that you create a new directory to
separate your custom code from the base code. Add the new directory
to the Portal application classpath. For details, refer to the WebSphere Application
Server documentation.
The following sample retrieves the problem text from /nls/problem_locale.properties.
The text is displayed only when an error is encountered rendering
the page.
For example:
<portal-core:pageRender>
<p align="center">
<strong><portal-fmt:problem bundle="nls.problem"/></strong>
<br>
<portal-fmt:answer bundle="nls.problem"/>
</p>
</portal-core:pageRender>
- <portal-fmt:text key="key"
bundle="bundle">
- Returns the text for a given key in the specified language.
The key indicates a parameter in a resource
bundle or properties file, indicated by bundle.
Both attributes are required. See the description of <portal-fmt:textParam> for
an example and further description of the attributes of <portal-fmt:text/>.
Where possible, the <i18n:bundle/> and <i18n:message/>
tags of the I18N tag library should be used instead of <portal-fmt:text/>..
- <portal-fmt:textParam>
- If the text that is retrieved contains placeholders in the form
of "{0}", "{1}", "{2}", these can be set using this tag. This
tag should be used only in the body of the <portal-fmt:text/>
tag. The text to be substituted for the placeholders needs to
be entered as content for this tag. It can even be an expression.
Examples
The
welcome parameter in a resource
bundle is set as follows:
welcome = Welcome {0}!
In the following example, the value of the <portal-fmt:textParam>
tag is written in place of the {0}.
<portal-fmt:text key="welcome" bundle="nls.engine">
<portal-fmt:textParam>World</portal-fmt:textParam>
</portal-fmt:text>
- <portal-fmt:title locale="locale"
varname="localized_object"/>
- Provides the localized title of the localized object specified
in varname. The tag also implies the localized object
if it is called inside of the <portal-navigation:navigationLoop/>
tag.
Attributes
- locale
- Optional. Overrides the current language setting.
- varname
- Optional. Specifies the name of the scripting variable holding
the localized object. The <portal-navigation:navigation/> tag
sets this object to <%=wpsNavNode%>.
- <portal-fmt:user attribute="value"/>
- If the user is logged in, this tag returns one of the specified
user attributes. value can be any user attribute
defined to Member Manager.