0
votes

I'm trying to pass form field values as GET parameters between 2 views (called "A" and "B"). In "B", I handle the parameters with f:metadata and f:viewParam. This part works great if I use the URL directly.

However, now I would like to pass fields from another view "A", but currenly without success. The fields are defined as follows:

<h:form>
<p:inputText id="field1" value="#{A.field1}"/>
<p:inputText id="field2" value="#{A.field2}"/>
[...]
</h:form>

If I use f:param within a Primefaces p:button, the parameters are transmitted but not retrieved dynamically (in fact, if I check the web page html code, the initial values of the form are written "statically").

What is the best approach to handle this ?

Thanks in advance

1

1 Answers

0
votes

Use h:button with f:param:

<h:button outcome="B.xhtml" value="Click me!">
    <f:param name="maybe_an_id" value="3" />
</h:button>

This will generate a normal HTML button, with a Javascript on click like this:

<input type="button" value="Click me!"
  onclick="window.location.href='/path/to/B.xhtml?maybe_an_id=3'; return false;">

See also: When should I use h:outputLink instead of h:commandLink?