<h:link includeViewParams="true"> does not include URL parameters

4.7k Views Asked by At

I have a JSF page which is opened by an URL like test.xhtml?a=15&b=20.

I have a link which should pass all URL parameters to the next page.

<h:link outcome="index" includeViewParams="true" value="Include all url parameters" />

I was expecting that when I click on the link it will go to index.xhtml?a=15&b=20

But I don't see anything in the URL. Did I understand the includeViewParams wrong?

1

There are 1 best solutions below

2
On BEST ANSWER

The includeViewParams will include all <f:viewParam> values. You however don't seem to have declared them.

Declare them accordingly in the template client.

<f:metadata>
    <f:viewParam name="a" />
    <f:viewParam name="b" />
</f:metadata>

Note that binding the value to bean property as in <f:viewParam name="a" value="#{bean.a}" /> is optional. The view parameters in the example are available in the EL scope by #{a} and #{b}.

See also: