Search code examples
jsfsearchencodinggmailprettyfaces

Prettyfaces url style search gmail


Good day:

I am conducting a search using prettyFaces, style gmail. When I do with gmail, space is replaced by a symbol "+". And in the box is not added the "+".

Example Gmail

In my case, when I do the same, in other characters url as in my box are added.

My app

Here the mapping code, and box:

<url-mapping id="search">
    <pattern value="/buscar/#{ /.*/ searchBean.q}" />
    <view-id value="/faces/reqs/search.xhtml" />
    <action>#{searchBean.search}</action>
</url-mapping>

<div class="search">
    <h:form id="searchForm">
        <span class="button-group">
           <p:inputText value="#{searchBean.q}" size="50"/>
           <p:commandButton action="pretty:search"/>
        </span>
     </h:form>
 </div>

Thanks for the help.

EDIT:

And if facebook would be because it is a parameter? and as it would be a solution to avoid aparesca special characters in the input? facebook example


Solution

  • This is expected behavior. In case of GMail the spaces are part of the "fragment" which is the part after the "#" character. In your PrettyFaces setup, the search term is part of the path.

    There are different encoding rules for fragments and path parts of the URL. So PrettyFaces is handling this correctly.