Spaces in my pretty faces urls…

Splash Forums PrettyFaces Users Spaces in my pretty faces urls…

This topic contains 11 replies, has 3 voices, and was last updated by  Christian Kaltepoth 6 years, 1 month ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #17996

    balteo
    Participant

    Hello,

    I migrated to pretty faces recently and noticed that my URLs contain spaces as in:

    http://localhost:8080/lang/fr/galerie/sculpture/La chute-2”

    Here is how I use pretty faces:

    <pretty:link mappingId=”sculptureAction” title=”#{sculpture.sculpturei18nMap[view.locale.language].titre}, #{sculpture.sculpturei18nMap[view.locale.language].matiere} #{sculpture.hauteur}x#{sculpture.largeur}x#{sculpture.profondeur} #{msg} (#{msg}x#{msg}x#{msg}) ” styleClass=”miniature-link-text”>

    <f:param value=”#{view.locale.language}”/>

    <f:param value=”#{jbm:normaliserURL(sculpture.sculpturei18nMap[view.locale.language].titre)}” />

    <f:param value=”#{sculpture.sculptureID}” />

    <h:outputText value=”#{sculpture.sculpturei18nMap[view.locale.language].titre}” />

    </pretty:link>

    I was thinking about URLEncoding [URLEncoder.encode(“title”,”UTF-8″);] the title in the “normaliserURL” function.

    Is that a good idea? Is there a better way around this problem?

    Regards,

    Julien.

    #21175

    Which version of PrettyFaces are you using? We had some problems with URL encoding in the past but the most recent version should work well.

    #21176

    balteo
    Participant

    Hello Christian,

    I use the latest version: 3.3.0…

    J.

    Am I missing something else?

    #21177

    balteo
    Participant

    By the way, here is my “sculptureAction”:

    @URLMapping(id = “sculptureAction”, parentId = “rootAction”, pattern = “galerie/sculpture/#{sculptureView.titre}-#{sculptureView.id}”, viewId = “/sculpture.jsf”)

    J.

    #21178

    Actually <pretty:link> should handle the encoding of the space character correctly for you. I see no mistake on your side. It looks fine what you are doing.

    Is the space character rendered to the <a> link in your HTML page or do you just see the space character in the browser bar after clicking the link? The latter one would be OK, as some browsers will decode the character correctly when displaying it to the user. But if the <a> link contains the space character this would be a problem. :)

    #21179

    balteo
    Participant

    There are spaces both in the link and the browser’s address bar…

    J.

    #21180

    Hmmm! I cannot reproduce this. I used a <pretty:link> like this:

    <pretty:link mappingId="greeting">
    <f:param value="url test"/>
    Test
    </pretty:link>

    And this is the rendered HTML output:

    <a href="/prettyfaces-demo/greeting/url%20test" id="form:j_id1635310146_6178dac4">Test</a>

    Could you also test a constant string in the <f:param> component with your app?

    #21181

    balteo
    Participant

    Christian,

    In fact, I don’t mind encoding the URL myself. I just want to make sure there is no harm in doing so.

    Can you confirm that?

    Regards,

    Julien.

    #21182

    Well, it would be fine to encode your own URLs, but I really don’t think you should have to! This should be happening for you. I seem to recall seeing a problem like this before, and it had something to do with the JSF or GlassFish version.

    Which server are you using?

    #21183

    Also, do you have any other filters installed that might be wrapping the outbound response?

    #21184

    balteo
    Participant

    Hello Lincoln,

    I use Tomcat 7 together with RF 4.0.0 (Mojarra 2.0.4-b09).

    Here are my two filters:

    *****************

    <filter>

    <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>

    <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>

    </filter>

    <filter>

    <filter-name>Pretty Filter</filter-name>

    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>

    </filter>

    *****************

    J.

    #21185

    I just tried to reproduce this issue again. My setup:

    * Tomcat 7.0.20

    * Mojarra 2.0.4-b09

    * PrettyFaces 3.3.0

    Everything works fine. The space character gets correctly replaced by “%20”.

    You can download the example application I used for testing here:

    https://github.com/chkal/prettyfaces-tests/archives/encoding

    Are you sure the space is contained in the URL? I saw that Chrome for example shows a space instead of “%20” in the tooltip of a link.

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.

Comments are closed.