1

I have this JSF page with a form which contains fields "company". I am trying to pre-populate the company fields with the URL. So, once the following link is clicked

localhost/accounts/index.jsf?company=test

users should see the form with company field filled with value "test".

Here is my JSF file

<p><h:inputText id="company" name="company" value="#{Bean.company}" required="true"
                                                        requiredMessage="Please enter your company" /></p> 

I have tried to use f:viewParam by followed this tutorial (8. page parameters), but still could not get it working. http://java.dzone.com/articles/how-do-10-common-tasks-jsf-20

Does anyone know how to fix this? Thanks!

2
  • 1
    Post the code (JSF, Java, etc) that gives you problems. Commented Nov 27, 2013 at 19:48
  • why dont you set the value of company in Bean constructor itself as "test" ? Commented Nov 28, 2013 at 5:40

1 Answer 1

5

To capture param value, you should use <f:metadata>

 <f:metadata>
    <f:viewParam name="company" value="#{Bean.company}" />
</f:metadata>

<p>
<h:inputText id="company" name="company"
           value="#{Bean.company}" required="true"
 requiredMessage="Please enter your company" />
</p>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.