Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.ibm.portal.struts.common
Class PortletApiUtils

    java.lang.Object
      com.ibm.portal.struts.common.PortletApiUtils

Direct Known Subclasses:
  PortletApiUtils

    public abstract class PortletApiUtils

extends java.lang.Object

This class provides the APIs for allowing an application to interact with a portal container. The APIs are generic and not specific to the portal container. The utility methods can be used to support classes like tags without creating tight dependencies on the portal container.

Since:
  5.1

Field Summary
`static int` | `RETURN_URL` Deprecated.
`protected static boolean` | `s_namescopeForm` Indicator of whether or not to namescope the form name.
`protected static boolean` | `s_namescopeInputName` Indicator of whether or not to namescope the name attribute of the input element.
`static int` | `STANDARD_URL` Deprecated.

Constructor Summary
`PortletApiUtils()` Constructor for PortletApiUtils.

Method Summary
`abstract void` | `addDefaultPortletAction(java.lang.Object portletURI)` Adds a portlet action to the given PortletURI.
`abstract void` | `addDefaultPortletAction(java.lang.Object portletURI, java.lang.String key)` Adds a portlet action to the given PortletURI using the given key.
`abstract java.lang.String` | `addModulePrefix(java.lang.String path, HttpServletRequest request)` Adds the module prefix to the path.
`abstract void` | `addParameter(java.lang.Object portletURI, java.lang.String key, java.lang.String value)` Adds the parameter to the given PortletURI.
`abstract void` | `addStrutsActionUrlAsParameter(java.lang.Object portletURI, java.lang.String actionUrl)` Adds the Struts action URL as a parameter to the given PortletURI using the value returned by getStrutsActionParameterName as the parameter name.
`abstract void` | `createCommand(java.lang.String path, HttpServletRequest request)` Creates the IViewCommand object for the path for the specified mode prefix.
`abstract void` | `createCommand(java.lang.String path, HttpServletRequest request, HttpServletResponse response)` Creates the IViewCommand object for the path for the specified mode prefix.
`abstract void` | `createCommand(java.lang.String path, HttpServletRequest request, HttpServletResponse response, java.lang.String commandPrefix)` Creates the IViewCommand object for the path for the specified mode prefix.
`abstract void` | `createCommand(java.lang.String path, HttpServletRequest request, java.lang.String commandPrefix)` Creates the IViewCommand object for the path for the specified mode prefix.
`java.lang.Object` | `createPortletURI(java.lang.Object response)` Creates a Portlet URI from the given response.
`abstract java.lang.Object` | `createPortletURI(java.lang.Object response, int urlType)` Deprecated.
`abstract java.lang.Object` | `createPortletURI(java.lang.Object response, PortletURIAttributes uriAttributes)` Creates a PortletURI for the given response.
`java.lang.Object` | `createPortletURIWithStrutsURL(HttpServletRequest request, java.lang.String actionUrl)` Creates a Struts PortletURI for the given response and URL.
`abstract java.lang.Object` | `createPortletURIWithStrutsURL(HttpServletRequest request, java.lang.String actionUrl, int urlType)` Deprecated.
`abstract java.lang.Object` | `createPortletURIWithStrutsURL(HttpServletRequest request, java.lang.String actionUrl, PortletURIAttributes uriAttributes)` Creates the requested type of PortletURI for the given response and URL.
`java.lang.Object` | `createPortletURIWithStrutsURL(java.lang.Object response, java.lang.String actionUrl)` Deprecated.
`abstract java.lang.Object` | `createPortletURIWithStrutsURL(java.lang.Object response, java.lang.String actionUrl, int urlType)` Deprecated.
`abstract java.lang.Object` | `createStrutsPortletURL(HttpServletRequest request, HttpServletResponse response, java.lang.String actionUrl, PortletURIAttributes uriAttributes)` Creates the requested type of PortletURI for the given response and URL.
`abstract java.lang.String` | `encodeAction(java.lang.String actionURL, HttpServletRequest request)` Encodes the Struts action URL so that it can be added as a paramter to the portlet URL.
`abstract java.lang.String` | `encodeNamespace(java.lang.String name, HttpServletRequest request)` Returns the namescoped name.
`abstract java.lang.String` | `encodeURL(java.lang.String path, HttpServletRequest request)` Returns the fully qualified URL from the path.
`abstract java.lang.String` | `encodeURL(java.lang.String path, HttpServletResponse response)` Returns the fully qualified URL from the path.
`abstract void` | `forward(java.lang.String uri)` Processes a forward.
`abstract void` | `forward(java.lang.String uri, HttpServletRequest request)` Processes a forward.
`abstract java.lang.String` | `getActionMappingURL(java.lang.String action, PageContext pageContext)` Return the form action converted into a server-relative URL.
`java.lang.String` | `getDefaultPortletActionName()` Returns the name of the portlet action for a Struts PortletURI.
`abstract java.lang.String` | `getEncodedBeanName(java.lang.String beanName, HttpServletRequest request)` Returns the encoded bean name with the first character upper-cased if isFormNamescoped returns true.
`abstract java.lang.Object` | `getHttpServletRequest(java.lang.Object request)` Gets the HttpServletRequest as an object from the given request object.
`abstract java.lang.Object` | `getHttpServletResponse(java.lang.Object response)` Gets the HttpServletResponse as an object from the given response object.
`java.lang.String` | `getParameterName(java.lang.String key)` Returns the parameter name stored under the specified key.
`abstract java.lang.Object` | `getPortletRequest(HttpServletRequest request)` Gets the PortletRequest as an object from the given request object.
`abstract java.lang.Object` | `getPortletResponse(HttpServletRequest request)` Gets the PortletResponse as an object from the given request.
`abstract java.lang.Object` | `getPortletResponse(HttpServletResponse response, HttpServletRequest request)` Gets the PortletResponse as an object from the given request.
`java.lang.String` | `getStrutsActionParameterName()` Returns the name of the parameter used to pass the Struts action.
`static PortletApiUtils` | `getUtilsInstance()` Gets the singleton instance of the PortletApiUtils implementation.
`abstract void` | `includeTile(java.lang.String path, PageContext pageContext)` Includes the path as a tile.
`static boolean` | `isFormNamescoped()` Returns whether or not namescoping of forms is enabled.
`void` | `setDefaultPortletActionName(java.lang.String name)` Sets the name of the portlet action for a Struts PortletURI.
`static void` | `setNamescopeForm(boolean value)` Turns namescoping of forms on or off, default is on.
`void` | `setParameterName(java.lang.String key, java.lang.String name)` Sets the parameter name for the specified key.
`void` | `setStrutsActionParameterName(java.lang.String name)` Sets the name used to store the Struts action as a parameter in the Portlet URL.
`static void` | `setUtilsInstance(PortletApiUtils implementation)` Sets the singleton instance of the PortletApiUtils implementation.
`int` | `typeOfURL(java.lang.String urlType)` Deprecated.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### s_namescopeForm

    protected static boolean s_namescopeForm

  Indicator of whether or not to namescope the form name.

### s_namescopeInputName

    protected static boolean s_namescopeInputName

  Indicator of whether or not to namescope the name attribute of the input element.

### STANDARD_URL

    public static final int STANDARD_URL

  Deprecated.
  Supported Portal URL type - standard

  See Also:
    `PortletURIAttributes`, Constant Field Values

### RETURN_URL

    public static final int RETURN_URL

  Deprecated.
  Supported Portal URL type - return

  See Also:
    `PortletURIAttributes`, Constant Field Values

Constructor Detail

### PortletApiUtils

    public PortletApiUtils()

  Constructor for PortletApiUtils. Typically not needed, the static methods can be used to obtain the implementation object.

Method Detail

### getUtilsInstance

    public static PortletApiUtils getUtilsInstance()

  Gets the singleton instance of the PortletApiUtils implementation.

  Returns:
    the implementation object of the PortletApiUtils or `null` if none has been set

### setUtilsInstance

    public static void setUtilsInstance(PortletApiUtils implementation)

  Sets the singleton instance of the PortletApiUtils implementation.

  Parameters:
    `implementation` - the implementation object of the PortletApiUtils

### getDefaultPortletActionName

    public java.lang.String getDefaultPortletActionName()

  Returns the name of the portlet action for a Struts PortletURI.

  Returns:
    name of the portlet action

### setDefaultPortletActionName

    public void setDefaultPortletActionName(java.lang.String name)

  Sets the name of the portlet action for a Struts PortletURI.

  Parameters:
    `name` - the portlet action name

### getStrutsActionParameterName

    public java.lang.String getStrutsActionParameterName()

  Returns the name of the parameter used to pass the Struts action.

  Returns:
    name the parameter name for the Struts action

### setStrutsActionParameterName

    public void setStrutsActionParameterName(java.lang.String name)

  Sets the name used to store the Struts action as a parameter in the Portlet URL.

  Parameters:
    `name` - the parameter name used to store the Struts action

### getParameterName

    public java.lang.String getParameterName(java.lang.String key)

  Returns the parameter name stored under the specified key. This allows the parameter names to be independent of the generic key.

  Parameters:
    `key` - the parameter names key
  Returns:
    the parameter name, `null` if not set

### setParameterName

    public void setParameterName(java.lang.String key,
                                 java.lang.String name)

  Sets the parameter name for the specified key.

  Parameters:
    `key` - the paramter key
    `name` - the parameter name

### getPortletResponse

    public abstract java.lang.Object getPortletResponse(HttpServletRequest request)

  Gets the PortletResponse as an object from the given request. This method may return null if called during the event phase of portal. The returned object should be casted to the appropriate PortletResponse class of the container.

  Parameters:
    `request` - the request object
  Returns:
    Object the portlet response, can return `null`

### getPortletResponse

    public abstract java.lang.Object getPortletResponse(HttpServletResponse response,
                                                        HttpServletRequest request)

  Gets the PortletResponse as an object from the given request. This method may return null if called during the event phase of portal. The returned object should be casted to the appropriate PortletResponse class of the current Portal container.

  Parameters:
    `response` - the response object
    `request` - the request object
  Returns:
    Object the portlet response object, can return `null`

### getPortletRequest

    public abstract java.lang.Object getPortletRequest(HttpServletRequest request)

  Gets the PortletRequest as an object from the given request object. The returnd object should be casted to the appriorate PortletRequest class of the current Portal container.

  Parameters:
    `request` - the request object
  Returns:
    Object the portlet request, can return `null`

### getHttpServletRequest

    public abstract java.lang.Object getHttpServletRequest(java.lang.Object request)

  Gets the HttpServletRequest as an object from the given request object.

  Parameters:
    `request` - the request object
  Returns:
    Object the portlet request, can return `null`

### getHttpServletResponse

    public abstract java.lang.Object getHttpServletResponse(java.lang.Object response)

  Gets the HttpServletResponse as an object from the given response object.

  Parameters:
    `request` - the request object
  Returns:
    Object the portlet request, can return `null`

### createPortletURI

    public java.lang.Object createPortletURI(java.lang.Object response)

  Creates a Portlet URI from the given response. This method can only be called in the render phase of portal. The Portlet URI should be casted to the appropriate PortletURI class of the current Portal container. The response object must be a valid PortletResponse object to create the URL.

  Parameters:
    `response` - the portlet response
  Returns:
    Object the portlet URL, can be `null`

### createPortletURI

    public abstract java.lang.Object createPortletURI(java.lang.Object response,
                                                      int urlType)

  Deprecated.

  Creates a PortletURI for the given response. This method can only be called in the render phase of portal. The Portlet URI should be casted to the appropriate PortletURI class of the current Portal container. The response object must be a valid PortletResponse object to create the URL.

  Parameters:
    `response` - A PortletResponse
    `urlType` - the type of URL, typically standard, or return
  Returns:
    Object the portlet URL, can be `null`

### createPortletURI

    public abstract java.lang.Object createPortletURI(java.lang.Object response,
                                                      PortletURIAttributes uriAttributes)

  Creates a PortletURI for the given response. This method can only be called in the render phase of portal. The Portlet URI should be casted to the appropriate PortletURI class of the current Portal container. The response object must be a valid PortletResponse object to create the URL.

  Parameters:
    `response` - the portlet response object
    `uriAttributes` - the URI attributes
  Returns:
    object the portlet URI, can be `null`

### createPortletURIWithStrutsURL

    public java.lang.Object createPortletURIWithStrutsURL(java.lang.Object response,
                                                          java.lang.String actionUrl)

  Deprecated.

  Creates a Struts PortletURI for the given response and URL. Creates a DefaultPortletAction and adds the Struts action URL as a parameter. The response object must be a valid PortletResponse object to create the URL. The PortletURI should be casted to the appropriate PortletURI class of the current portal container.

  Parameters:
    `response` - the response object
    `actionUrl` - the Struts action Url
  Returns:
    Object portlet url, can return `null`

### createPortletURIWithStrutsURL

    public java.lang.Object createPortletURIWithStrutsURL(HttpServletRequest request,
                                                          java.lang.String actionUrl)

  Creates a Struts PortletURI for the given response and URL. Creates a DefaultPortletAction and adds the Struts action URL as a parameter. The return value can be `null`, if the response object cannot be found. The PortletURI should be casted to the appropriate PortletURI class of the current portal container.

  Parameters:
    `request` - the request object
    `actionUrl` - the Struts action Url
  Returns:
    Object portlet url, can return `null`

### createPortletURIWithStrutsURL

    public abstract java.lang.Object createPortletURIWithStrutsURL(java.lang.Object response,
                                                                   java.lang.String actionUrl,
                                                                   int urlType)

  Deprecated.

  Creates the requested type of PortletURI for the given response and URL. Creates a DefaultPortletAction and adds the Struts action URL as a parameter. The response object must be a valid PortletResponse object to create the URL. The PortletURI should be casted to the appropriate PortletURI class of the current portal container.

  Parameters:
    `response` - A PortletResponse
    `actionUrl` - the Struts action Url
    `urlType` - the type of URL to create
  Returns:
    Object the portlet URL, can return `null`

### createPortletURIWithStrutsURL

    public abstract java.lang.Object createPortletURIWithStrutsURL(HttpServletRequest request,
                                                                   java.lang.String actionUrl,
                                                                   int urlType)

  Deprecated.

  Creates the requested type of PortletURI for the given response and URL. Creates a DefaultPortletAction and adds the Struts action URL as a parameter. The return value can be `null`, if the response object cannot be found. The PortletURI should be casted to the appropriate PortletURI class of the current portal container.

  Parameters:
    `request` - the HttpServletRequest object
    `actionUrl` - the Struts action Url
    `urlType` - the type of URL to create
  Returns:
    Object portlet URI, can return `null`

### createPortletURIWithStrutsURL

    public abstract java.lang.Object createPortletURIWithStrutsURL(HttpServletRequest request,
                                                                   java.lang.String actionUrl,
                                                                   PortletURIAttributes uriAttributes)

  Creates the requested type of PortletURI for the given response and URL. Creates a DefaultPortletAction and adds the Struts action URL as a parameter. The return value can be `null`, if the response object cannot be found. The PortletURI should be casted to the appropriate PortletURI class of the current portal container.

  Parameters:
    `request` - the HttpServletRequest object
    `actionUrl` - the Struts action Url
    `uriAttributes` - the Portlet URI attributes
  Returns:
    Object portlet URI, can return `null`

### createStrutsPortletURL

    public abstract java.lang.Object createStrutsPortletURL(HttpServletRequest request,
                                                            HttpServletResponse response,
                                                            java.lang.String actionUrl,
                                                            PortletURIAttributes uriAttributes)

  Creates the requested type of PortletURI for the given response and URL. Creates a DefaultPortletAction and adds the Struts action URL as a parameter. The return value can be `null`, if the response object cannot be found. The Portlet URI should be casted to the appropriate PortletURI class of the current portal container.

  Parameters:
    `request` - the HttpServletRequest object
    `response` - the HttpServletResponse object
    `actionUrl` - the Struts action Url
    `uriAttributes` - the PortletURI attributes
  Returns:
    Object portlet URI, can return `null`

### typeOfURL

    public int typeOfURL(java.lang.String urlType)

  Deprecated.

  Returns the enumerated value for the URL type.

  Parameters:
    `urlType` - the url type
  Returns:
    the url type, returns STANDARD_URL if type is not found
  See Also:
    `PortletURIAttributes`

### addDefaultPortletAction

    public abstract void addDefaultPortletAction(java.lang.Object portletURI)

  Adds a portlet action to the given PortletURI. The name will be the value returned by getDefaultPortletActionName.

  Parameters:
    `portletURI` - previously created PorletURI

### addDefaultPortletAction

    public abstract void addDefaultPortletAction(java.lang.Object portletURI,
                                                 java.lang.String key)

  Adds a portlet action to the given PortletURI using the given key.

  Parameters:
    `portletURI` - previously created PorletURI
    `key` - the key to add

### addStrutsActionUrlAsParameter

    public abstract void addStrutsActionUrlAsParameter(java.lang.Object portletURI,
                                                       java.lang.String actionUrl)

  Adds the Struts action URL as a parameter to the given PortletURI using the value returned by getStrutsActionParameterName as the parameter name.

  Parameters:
    `portletURI` - previously created porletURI
    `actionUrl` - action URL String to use

### addParameter

    public abstract void addParameter(java.lang.Object portletURI,
                                      java.lang.String key,
                                      java.lang.String value)

  Adds the parameter to the given PortletURI. The key will be used to look up the parameter name from getParameterName

  Parameters:
    `portletURI` - previously created PorletURI
    `key` - the parameter name
    `value` - the parameter value

### forward

    public abstract void forward(java.lang.String uri)
                          throws ServletException

  Processes a forward. Portal does not support forwards, so this method is an alternative to pageContext.forward. The URI can either be a Struts action or a URI that can be included. If this is not the case then a ServletException is thrown. If the request object cannot be found, then a ServletException is thrown.

  Parameters:
    `uri` - forward to the specified URI path
  Throws:
    `ServletException` - if the forward is not successful

### forward

    public abstract void forward(java.lang.String uri,
                                 HttpServletRequest request)
                          throws ServletException

  Processes a forward. Portal does not support forwards, so this method is an alternative to pageContext.forward. The URI can either be a Struts action or a URI that can be included. If this is not the case then a ServletException is thrown.

  Parameters:
    `uri` - forward to the URI path
    `request` - the HttpServletRequest object
  Throws:
    `ServletException` - if the forward is not successful

### encodeURL

    public abstract java.lang.String encodeURL(java.lang.String path,
                                               HttpServletRequest request)

  Returns the fully qualified URL from the path.

  Parameters:
    `path` - the path
    `request` - the request object.
  Returns:
    String the encoded URL

### encodeURL

    public abstract java.lang.String encodeURL(java.lang.String path,
                                               HttpServletResponse response)

  Returns the fully qualified URL from the path.

  Parameters:
    `path` - the path
    `response` - the response object.
  Returns:
    String the encoded URL

### encodeNamespace

    public abstract java.lang.String encodeNamespace(java.lang.String name,
                                                     HttpServletRequest request)

  Returns the namescoped name. This method can return a blank string if namescope cannot be determined, typically because the method is called in the render phase of portal.

  Parameters:
    `name` - the name to namescope
    `request` - the request object.
  Returns:
    String the namescoped name, can be a blank string

### addModulePrefix

    public abstract java.lang.String addModulePrefix(java.lang.String path,
                                                     HttpServletRequest request)

  Adds the module prefix to the path. The module config will be determined from the request object and the module prefix will be prepended to the path.

  Parameters:
    `path` - the path
    `request` - the request object.
  Returns:
    String the module prefixed path

### getEncodedBeanName

    public abstract java.lang.String getEncodedBeanName(java.lang.String beanName,
                                                        HttpServletRequest request)

  Returns the encoded bean name with the first character upper-cased if isFormNamescoped returns true.

  Parameters:
    `beanName` - the bean name
    `request` - the request object.
  Returns:
    String encoded bean name

### setNamescopeForm

    public static void setNamescopeForm(boolean value)

  Turns namescoping of forms on or off, default is on.

  Parameters:
    `value` - false to turn off namescoping

### isFormNamescoped

    public static boolean isFormNamescoped()

  Returns whether or not namescoping of forms is enabled.

  Returns:
    boolean false if namescoping is turned off

### createCommand

    public abstract void createCommand(java.lang.String path,
                                       HttpServletRequest request,
                                       HttpServletResponse response,
                                       java.lang.String commandPrefix)
                                throws ServletException

  Creates the IViewCommand object for the path for the specified mode prefix. The command prefix is used to store the command and commands are saved by the portlet mode.

  Parameters:
    `path` - the URI for the command
    `request` - the request object.
    `response` - the response object.
    `commandPrefix` - the prefix that the command is stored under
  Throws:
    `ServletException` - if create fails

### createCommand

    public abstract void createCommand(java.lang.String path,
                                       HttpServletRequest request,
                                       HttpServletResponse response)
                                throws ServletException

  Creates the IViewCommand object for the path for the specified mode prefix. The command prefix is used to store the command and commands are saved by the portlet mode.

  Parameters:
    `path` - the URI for the command
    `request` - the request object.
    `response` - the response object.
  Throws:
    `ServletException` - if create fails

### createCommand

    public abstract void createCommand(java.lang.String path,
                                       HttpServletRequest request)
                                throws ServletException

  Creates the IViewCommand object for the path for the specified mode prefix. The command prefix is used to store the command and commands are saved by the portlet mode. The commands prefix will be determined from the request object.

  Parameters:
    `path` - the URI for the command
    `request` - the request object.
  Throws:
    `ServletException` - if create fails

### createCommand

    public abstract void createCommand(java.lang.String path,
                                       HttpServletRequest request,
                                       java.lang.String commandPrefix)
                                throws ServletException

  Creates the IViewCommand object for the path for the specified mode prefix. The command prefix is used to store the command and commands are saved by the portlet mode.

  Parameters:
    `path` - the URI for the command
    `request` - the request object.
    `commandPrefix` - the prefix that the command is stored under
  Throws:
    `ServletException` - if create fails

### includeTile

    public abstract void includeTile(java.lang.String path,
                                     PageContext pageContext)
                              throws ServletException

  Includes the path as a tile. The path can be an action or a includable path, and the markup will be written to the pageContext print writer.

  Parameters:
    `path` - the URI for the command
    `pageContext` - the page context
  Throws:
    `ServletException` - if include fails

### encodeAction

    public abstract java.lang.String encodeAction(java.lang.String actionURL,
                                                  HttpServletRequest request)

  Encodes the Struts action URL so that it can be added as a paramter to the portlet URL.

  Parameters:
    `actionURL` - the Struts action URL
    `request` - the servlet request object
  Returns:
    the encoded Struts action

### getActionMappingURL

    public abstract java.lang.String getActionMappingURL(java.lang.String action,
                                                         PageContext pageContext)

  Return the form action converted into a server-relative URL.

  Parameters:
    `action` - the Struts action
    `pageContext` - the page context
  Returns:
    the server-relative URL

Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD