3

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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user373201
  • 10,945
  • 34
  • 112
  • 168

1 Answers1

7

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:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks, it works but doesn't make sense, once you ahve includeViewParams, one would assume that that would automatically copy everything over, instead of specifying again using f:viewParam, the only typing you save is not having to mention value="". Just a thought – user373201 Oct 12 '12 at 14:33
  • 2
    "allow everything" is in first place a bad mentiality in web development world. You don't want to give the client that much freedom. Control what may come in and out. – BalusC Oct 12 '12 at 14:47