JSP tags for IBM portlets

 

+
Search Tips   |   Advanced Search

 

The following tags are used by JSPs for IBM portlets. The IBM portlet API is deprecated. For new development work, you should use the Standard portlet API.

 

Detailed descriptions of the IBM portlet API tags

The following tags are used by IBM portlets.

<portletAPI:if attribute ="value" />

Through the attributes of this tag, several conditions can be checked. If the condition is true, the content of the tag is written to the page. Otherwise the content is skipped. More than one condition can be evaluated. All conditions must evaluate to be true for the tag contents to be written. Also, each parameter can contain multiple values separated by commas or semicolons. Only one value in the list needs to be true for the condition to evaluate as true.

Include at least one of the following attributes:

mode = [Portlet.Mode]

evaluates the current mode of the portlet. For example, mode="Edit" is true if the user has placed the portlet in Edit mode.

previousMode = [Portlet.Mode]

evaluates the previous mode of the portlet. For example, previousMode="View" is true after a portlet is moved from View to Edit mode.

state = [PortletWindow.State]

evaluates the state of the portlet. For example, state="Minimized" is true after the user clicks the minimize icon of the portlet.

markup = [string]

evaluates the markup language supported by the client. For example, markup="wml" is true if the client supports WML.

mimetype = [string]

evaluates the MIME type supported by the client. For example, mimetype="text.html" is true if the client supports HTML.

capability = [Capability]

evaluates the client's capabilities. For example, capability="HTML_CSS" is true if the client supports cascading style sheets.

In the following example, the portlet must be in View mode and the portlet state must be either Normal or Maximized for the image to be rendered:

    
<portletAPI:if mode="View" state="Normal,Maximized">
      <img src="images/results.gif">
</portletAPI:if>
  

<portletAPI:log text="text" level="level" />

Writes a string in the portlet log.

text = [string]

indicates the message or trace string to be recorded in the portlet log. This attribute is required.

level = [ERROR | WARN | INFO | DEBUG]

indicates the level of the message to be logged. See Message and trace logging for more information about the logs that are written. This parameter is optional; if level is not specified, ERROR is the default.

    <portletAPI:log text="This is an error message!"/>
  

<portletAPI:text bundle="properties_file" key="string" />

This tag has been deprecated. Use the JSTL <fmt:bundle/> and <fmt:message/> tags instead.

<portletAPI:bidi dir="rtl|ltr" />

This tag is used to support text for bidirectional languages. Bidirectional languages are those which 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).

dir

Indicates the normal direction of text in the language.

  • 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.

locale

Tag content is written only if the language belongs to the bidirectional languages defined in LocalizerService.properties .

<portletAPI:dataLoop />

Loops through all attributes in PortletData of the current concrete portlet instance. Use the <dataAttribute> tag to get the attributes between the dataLoop start and end tag.

pattern = string

Optional. A regular expression that defines which attributes should be looped.

See dataAttribute for an example of how this tag is used.

<portletAPI:dataAttribute />

Returns the value of one or more PortletData attributes. The attribute can be specified by the name parameter. We can also use this tag within a <dataLoop> tag to retrieve all attributes or a subset of the attributes from PortletData.

name = string

Optional. Indicates the attribute name.

The following example loops through the PortletData attributes, returning only the values with names that start with stock.user.

Our user settings of the stock portlet:<br>
<portletAPI:dataLoop pattern="stock.user.*.">
   <portletAPI:dataAttribute/><br>
</portletAPI:dataLoop>

One specific user setting of the stock portlet:<br>
<portletAPI:dataAttribute name="stock.user.quotes-count"/><br>

<portletAPI:settingsLoop />

Loops through all attributes in PortletSettings of the current concrete portlet. Use the <settingsAttribute> tag to get the attributes between start and end tag.

pattern = string

a regular expression that defines which attributes should be looped.

See settingsAttribute for an example of how this tag is used.

<portletAPI:settingsAttribute />

Returns the value of one or more PortletSettings attributes. The attribute can be specified by the name parameter. We can also use this tag within a settingsLoop tag to retrieve all attributes or a subset of the attributes from PortletSettings.

name = string

Optional. Indicates the attribute name.

The following example loops through the PortletSettings attributes, returning only the values with names that start with stock.config. .

  Our configuration settings of the stock portlet:<br>
  <portletAPI:settingsLoop pattern="stock.config.*.">
     <portletAPI:settingsAttribute/><br>
  </portletAPI:settingsLoop>

  One specific configuration setting of the stock portlet:<br>
  <portletAPI:settingsAttribute name="stock.config.hostname"/><br>

<portletAPI:CreateReturnURI />

Creates a URI that will display the portlet in the previously known mode. We can pass a parameter or action in the URI by including URIParameter or URIAction between the CreateReturnURI start and end tags.

The following example uses the tag to create a link that will display the portlet in its previously known mode.

  <a href="<portletAPI:CreateReturnURI/>">
    <fmt:message key="back_label">
  </a>

For examples of passing a parameter or action with this tag, see URIParameter and URIAction.

<portletAPI:createURI />

Creates an URI that points to the current portlet with the given parameters. We can pass a parameter or action in the URI by including URIParameter or URIAction between the createURI start and end tags.

state = [PortletWindow.State]

Optional. Indicates the state of the portlet. For example, state="Solo" creates a URI for a link that opens the portlet in solo state. If state is not specified, the URI points to the portlet's current state.

See URIParameter and URIAction.

<portletAPI:URIParameter />

Adds a parameter to the URI of the createURI and CreateReturnURI tags.

name = string

Required. The name of the parameter to add.

value = string

Required. The value of the parameter to add.

In the following example, the parameter showQuote and value IBM are added to the URI.

  <portletAPI:createURI state="Maximized">
    <portletAPI:URIParameter name="showQuote" value="IBM "/>
  </portletAPI:createURI>

<portletAPI:URIAction />

Adds a default action to the URI of the createURI and createReturnURI tags. The portlet must provide an action listener to handle the event.

name = string

Required. The name of the parameter to add.

<portletAPI:createURI>
   <portletAPI:URIAction name="Add" />
</portletAPI:createURI>

<portletAPI:encodeNamespace value="string" />

Maps the given string value into this portlet's namespace. Use this tag for named elements in portlet output (for example, form fields or Javascript variables) to uniquely associate the element with this concrete portlet instance and avoid name clashes with other elements on the portal page or with other portlets on the page.

The following parameter names may not be used in portlet JSPs without namespace encoding as they are reserved by the portal server:

  • names starting with a point '.'

  • names starting with an underscore '_'

value = string

Required. Specifies the value to be mapped into the portlet's namespace.

In the following example, a text field with the name 'email' is encoded to ensure uniqueness on the portal page.

   <input border="0"
       type="text"
       name="<portletAPI:encodeNamespace value='email' />">

<portletAPI:init />

Provides the following variables that the JSP can use to access the corresponding objects of the portlet API:

  • portletRequest

  • portletResponse

  • portletConfig

After using the init tag, the JSP invokes the encodeNamespace() method of the portletResponse.

  <portletAPI:init/>
  <%=portletResponse.encodeNamespace("test")%>

 

Related information