0

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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Hi Balus, I was able to accomplish this with a JSP form with the sql commands within the form (no controller - MVC, of which I am trying to correct) the page is named: index.jsp –  Nov 18 '16 at 10:29
  • Yes, I would like to pass the value of the input field - I tried but it also does not pass the value. –  Nov 18 '16 at 11:09
  • I can see why you asked the question... Balus... You can't achieve it using . Its name is autogenerated by JSF based on the client ID (which is in turn based on component ID and all of its naming container parents). and there is no attribute called name in h:inputText, –  Nov 18 '16 at 13:29
  • @Balus SOLVED>>> '
    Search
    '
    –  Nov 18 '16 at 14:44

0 Answers0