I have a GET form on which I need to preset the value of an <h:inputText>
to a request parameter.
I tried using <f:param>
inside <h:inputText>
.
<form name="frmSearch" method="get" action="search.xhtml">
Search
<h:inputText name="txtKeyword" type="text" id="txtKeyword" placeholder="Enter keyword">
<f:param name="keyword" value="#{param['keyword']}"></f:param>
</h:inputText>
</form>
And I tried to access it as below.
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
String keyword = request.getParameter("keyword");
// keyword is null.
However, it returned null
. What's the correct approach?