Portlet API 2

org.apache.jetspeed.portlet
Interface PortletRequest

All Known Subinterfaces:
SaxPortletRequest

public interface PortletRequest

The PortletRequest encapsulates the request sent by the client to the portlet.

See Also:
PortletResponse

Method Summary
 Object getAttribute(String name)
          Returns the value of the attribute with the given name, or null if no attribute with the given name exists.
 Enumeration getAttributeNames()
          Returns an enumeration of names of all attributes available to this request.
 Client getClient()
          Returns an object representing the client device that the user connects to the portal with.
 Locale getLocale()
          Returns the locale of the preferred language.
 Enumeration getLocales()
          Returns an enumeration of locales indicating, in decreasing order starting with the locale of the preferred languages, the preferred languages.
 String getMethod()
          Returns the HTTP method of this request.
 Portlet.Mode getMode()
          Returns the mode that the portlet is running in.
 PortletPage getPage()
          Returns the page that the portlet is part of.
 String getParameter(String name)
          Returns the value of the parameter with the given name, or null if no such parameter exists.
 Map getParameterMap()
          Returns a map of the parameters of this request.
 Enumeration getParameterNames()
          Returns an enumeration of all parameter names.
 String[] getParameterValues(String name)
          Returns the values of all parameters with the given name.
 PortletSession getSession()
          Returns the current session or, if there is no current session, it creates one and returns it.
 PortletSession getSession(boolean create)
          Returns the current session or, if there is no current session and the given flag is true, it creates one and returns it.
 PortletWindow getWindow()
          Returns the window that the portlet is running in.
 boolean isSecure()
          Returns whether this request was made using a secure channel, such as HTTPS.
 void setAttribute(String name, Object value)
          Associates an attribute with the given name and value with this request.
 

Method Detail

getMode

public Portlet.Mode getMode()
Returns the mode that the portlet is running in.
Returns:
the portlet mode

getMethod

public String getMethod()
Returns the HTTP method of this request. The most commonly used request methods are GET and POST.
Returns:
the method

getLocale

public Locale getLocale()
Returns the locale of the preferred language. The preference is based on the user's choice of language(s) and/or the client's Accept-Language header.

If more than one language is preferred, the locale returned by this method is the one with the highest preference.

Returns:
the locale of the preferred language
See Also:
getLocales()

getLocales

public Enumeration getLocales()
Returns an enumeration of locales indicating, in decreasing order starting with the locale of the preferred languages, the preferred languages. The preference is based on the user's choice of language(s) and/or the client's Accept-Language header.
Returns:
an enumeration of locales of preferred languages
See Also:
getLocale()

getClient

public Client getClient()
Returns an object representing the client device that the user connects to the portal with.
Returns:
the client

getParameter

public String getParameter(String name)
Returns the value of the parameter with the given name, or null if no such parameter exists.

You should only use this method when you are sure the parameter has only one value. If not, use getParameterValues(String)

Parameters:
name - the parameter name
Returns:
the parameter value
See Also:
getParameterMap(), getParameterValues(String)

getParameterMap

public Map getParameterMap()
Returns a map of the parameters of this request.
Returns:
a map of parameters
See Also:
getParameter(String), getParameterValues(String)

getParameterNames

public Enumeration getParameterNames()
Returns an enumeration of all parameter names. If this request
Returns:
the enumeration

getParameterValues

public String[] getParameterValues(String name)
Returns the values of all parameters with the given name.

A request can carry more than one parameter with a certain name. This method returns these parameters in the order of appearance.

Parameters:
name - the parameter name
Returns:
the array of parameter values
See Also:
getParameterMap(), getParameter(String)

setAttribute

public void setAttribute(String name,
                         Object value)
Associates an attribute with the given name and value with this request. If a portlet needs to communicate information to embedded servlets or JSP, this methods can used carry the information along.

The portlet provider should take care that the the namespace of attribute names is not unnecessarily polluted. It is recommended to prefix all attributes the package and class name of the portlet that makes use of this method. The prefixing should probably be done by the portlet container.

Parameters:
name - the attribute name
value - the attribute value

getAttribute

public Object getAttribute(String name)
Returns the value of the attribute with the given name, or null if no attribute with the given name exists.
Parameters:
name - the attribute name
Returns:
the attribute value

getAttributeNames

public Enumeration getAttributeNames()
Returns an enumeration of names of all attributes available to this request. This method returns an empty enumeration if the request has no attributes available to it.
Returns:
an enumeration of attribute names

isSecure

public boolean isSecure()
Returns whether this request was made using a secure channel, such as HTTPS.
Returns:
true if channel is secure,
false otherwise

getWindow

public PortletWindow getWindow()
Returns the window that the portlet is running in.
Returns:
the portlet window

getPage

public PortletPage getPage()
Returns the page that the portlet is part of.
Returns:
the portlet page

getSession

public PortletSession getSession()
Returns the current session or, if there is no current session, it creates one and returns it.
Returns:
the portlet session

getSession

public PortletSession getSession(boolean create)
Returns the current session or, if there is no current session and the given flag is true, it creates one and returns it.

If the given flag is false and there is no current portlet session, this method returns null.

Parameters:
create - true to create a news session,
false to return null of there is no current session
Returns:
the portlet session

Portlet API 2