How to pass request parameters in URL between JSF Pages

Passing request parameters with URL from one page to another and binding them in target pages is possible but using them with UIInput components is not. Because the param map is read-only. So update model phase in lifecycle fails if you are using as a value for UIInput components. To avoid this,
In the backing bean of the target page, define a variable and getter/setter for it. In the getter method; if the variable is null, initialize it with expressionResolver method. The expression parameter should be in #{foo} format.
    

private String myParam;

public String getMyParam() {
if (myParam == null) {
myParam = (String) expressionResolver("#{param.foo}");
}
return myParam;
}

public void setMyParam(String myParam) {
this.myParam = myParam;
}

public Object expressionResolver(String expression) {
Object value = null;

if ((expression.indexOf("#{") != -1) && (expression.indexOf("#{") < expression.indexOf('}'))) {
value = getFacesContext().getApplication().createValueBinding(expression).getValue(getFacesContext());
} else {
value = expression;
}
return value;
}
To use the value in the target page, bind myParam to a h:inputHidden component.
<h:inputHidden id="hiddenParam" value="#{yourBackingBean.myParam}"/>


For example you can use the value in javascript like,

var myParam = document.getElementById('form1:hiddenParam').value;

0 comments: