tags:

views:

23

answers:

1

I want some code in facelet (jsf 2.0) to work:

  <h:inputText id="q" />
  <h:button outcome="/search.xhtml?q=#{q.value}" />

but when I press the button, search page opens without any parameters.

I think, my EL expression is wrong. Is it possible to access inputText value from EL expression? If not, how can I achieve the same functionality?

+1  A: 

I've finished with using plain html form:

<form action="faces/search.xhtml" method="get">
      <input type="text" name="query" />
      <input type="submit" value="Find" />
</form>

In search.xhtml I have view param to get a value of query string:

    <f:metadata>
        <f:viewParam name="query" />
    </f:metadata>

This solution has the problem - "faces/search.xhtml" is hardcoded. Also, when I place this form in search.xhtml and perform several searches I have something like this in browser url:

"http://localhost:8080/Application/faces/faces/faces/search.xhtml"

I think this problem can be solved with PrettyFaces (TODO :)

Dmitry