0
votes

I have an inputtext in a page page1.xhtml and I want to pass the value the user will enter into a second page page2.xhmtl as a view parameter using a get method. I use an h:button and put as outcome value from the backing bean but it when I navigate to the second page I the parameter is not passed. What's wrong? Is the value not passed to the backing bean before pressing the button and therefore value cannot be read? Is there another way to do it?

page1.xhtml

h:inputText id="q" value="#{QBean.q}"></h:inputText>
<h:button value="Done" outcome="page2?q=#{indexBean.q}">

page2.xhtml

<f:metadata>
       <f:viewParam name="q" value="#{QBean.q}"/>
</f:metadata>

QBean

private String q;

//setter
//getter
2

2 Answers

2
votes

Your sole functional requirement seems to be that you want a GET form instead of a POST form. In that case, use normal HTML elements, not JSF components.

<form action="page2.xhtml">
    <input name="q" />
    <input type="submit" value="Done" />
</form>
0
votes

You could use the POST-REDIRECT-GET approach and take commandButton instead: <h:commandButton value="Done" action="page2?faces-redirect=true&amp;includeViewParams=true"/>