Passing parameters between JSP files

Request parameters can be passed using the following two methods:

The param map contains parameters passed in the URL, or passed from another page from an HTML form. To reference a request parameter within a target page:

${param.P}
where P is the parameter.

Because the param map is read-only, the updateModel phase of the JavaServer Faces lifecycle fails if used as the value of components with type UIInput. As a result, forms seem broken because their actions are never run; this is a known issue. Therefore, you should use the param map for output components only. One way to work around this problem is to define a variable in the page code file of the Faces JSP page. Then, generate a getter and setter for it. In its getter method, initialize it (if it is null) to resolveExpression("#{param.xyz}). Then, create the input component and bind it to the property of your page.

Request scope parameters are not visible in the URL. To pass this parameter, create a Button - Command or a Link - Command on the originating page. In the Quick Edit view, set the parameter in the request scope using code:

requestScope.put("P", "some value");

You can reference the target page through a value of #{requestScope.P}. You can use the request scope on both input and output components.

ParametersValues in the requestScope are (as the name implies) not persistent. This can cause problems, especially if a relational record list is filtered on a requestScope parameter into a data table that supports paging. The act of paging initiates a submit in which the parameter is out of scope. To work around this problem, create a hidden input field that uses the parameter as a value. This method does not work for pages with multiple forms (including portlets) where the forms return to the same page. In this case, consider other scopes for the parameters (recommended) or for the relational record list (not recommended).

 

Related concepts

Data table components