-
1. Re: Problems when paginating with search criterias
uke Sep 28, 2007 4:53 AM (in response to uke)This is the code as it looks now. One problem is that the s:links put the searchCriteria as a get-parameter, which messes up some characters. Is it possible to html-encode it in some way?
I tried to solve problem no2 by adding a hidden field in the search-form, which sets firstResult to 0, but that didn't do anything, perhaps because get-parameters are prioritized over post-parameters?
components.xml:<fwk:entity-query name="users" entity-manager="#{entityManager}" ejbql="from User" order="name" max-results="10"> <fwk:restrictions> <value>lower(name) like lower(concat(#{searchCriteria},'%'))</value> </fwk:restrictions> </fwk:entity-query>
pages.xml:<page view-id="/listUsers.xhtml"> <param name="firstResult" value="#{users.firstResult}"/> <param name="searchCriteria" value="#{searchCriteria}"/> </page>
listUsers.xhtml:<h:form> <h:inputText name="searchCriteria" value="#{searchCriteria}"/> <h:commandButton value="Search"/> </h:form> <h:dataTable value="#{users.resultList}"var="user"> <h:column> <s:link view="/viewUser.xhtml" value="#{user.name}"> <f:param name="userId" value="#{user.id}"/> </s:link> </h:column> </h:dataTable> <s:link rendered="#{users.previousExists}" value="First"> <f:param name="firstResult" value="0"/> </s:link> <s:link rendered="#{users.previousExists}" value="Previous"> <f:param name="firstResult" value="#{users.previousFirstResult}"/> </s:link> <s:link rendered="#{users.nextExists}" value="Next"> <f:param name="firstResult" value="#{users.nextFirstResult}"/> </s:link> <s:link rendered="#{users.nextExists}" value="Last"> <f:param name="firstResult" value="#{users.lastFirstResult}"/> </s:link>
Thanks in advance
Sebastian -
2. Re: Problems when paginating with search criterias
pmuir Oct 27, 2007 6:42 AM (in response to uke)What is character encoding set to?
-
3. Re: Problems when paginating with search criterias
uke Oct 29, 2007 8:03 AM (in response to uke)Hi!
Thanks for your response.
All I've specified is the content-type (as an html meta-tag) in my template, which is set to utf-8.
Though now when you mentioned it, I looked through the seam reference again and added this to my components.xml.<web:character-encoding-filter encoding="UTF-8" override-client="true" url-pattern="*.seam"/>
Although, that didn't make any difference either. Should I add the encoding to some other place as well?
The URL is formed correctly, but in the input-field, "åaa" has become "Ã¥aa".
Note that this only occurs after going between result-pages (with the s:links). The initial search (with the h:commandButton) works fine. -
4. Re: Problems when paginating with search criterias
uke Oct 31, 2007 10:51 AM (in response to uke)After a lot of trying around, I've put the search criteria-string into an object, so that I can control the getter and setter for it.
With the setter looking like thisthis.criteria = new String(criteria.getBytes("ISO-8859-1"), "UTF-8");
The search works when the criteria is sent as a page parameter, though it breaks the original form-request.
My conclusion based on this is that the form sends a utf-8-encoded string, but the get-request parameter is ISO-8859-1-encoded.
If this seems like a reasonable explanation, is there a way around this? Where can I set the encoding for the page parameters?