Accessing request parameters from a Portlet

From VYRE

Jump to: navigation, search

As described in the portlet specification, each portlet can only access request parameters it has self sent. Therefore, portals must encode the names of the request parameters with prefixes unique to the portlet. However, it is sometimes useful to be able to access a parameter supplied by an external entity. Unify offers the following solution to this problem.

Note: This approach breaks the portability of your portlet, that is, this technique will not work in other portals and your portlet will depend on API from Vyre.

To access the request parameters, simply do the following:

import vyre.publishing.Keys;
import vyre.util.params.RequestParameters;
...
RequestParameters requestParams = (RequestParameters)request.getAttribute(Keys.SERVLET_PARAMETERS);
... 

The RequestParameters object has methods for accessing the request parameters, usually on the following format:

requestParams.getXXX(paramName, defaultValue)

For example getString(), getInt(), getLong(), etc. It also has methods for accessing file parameters. Check the API doc for the full details.

Personal tools