Escaping the hash symbol in a URL

Splash Forums PrettyFaces Users Escaping the hash symbol in a URL

This topic contains 2 replies, has 3 voices, and was last updated by  Lincoln Baxter III 1 year, 9 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26522

    Sidestroker
    Participant

    Hello,

    I have added the following snippet in the pretty-cms-config.xml file I have deployed:
    Because I want the page to open on a specific tab.

    <url-mapping id=”/vanity-test”>
    <pattern>/vanity-test</pattern>
    <view-id>/folder1/folder2/vanity-test.jsf#tab-2</view-id>
    </url-mapping>

    But I’m not sure how to escape the hash tag. It does not look like escaping it with %23 does any good. Currently, the vanity URL is not being created at all, and it’s due to the hash tag. Once I remove the “#tab-2”, the vanity URL takes effect. Is there a different way of encoding the hash tag?

    #26523

    This isn’t possible. Something like “#tab1” is only used by the browser to navigate to a specific part of the page AFTER the full page has been loaded. But “#tab1” isn’t part of the request sent to the server. Therefore you cannot use it for a view-id and cannot “hide” it using PrettyFaces.

    #26524

    I think he wants to have PrettyFaces generate an outbound link that adds the anchor. Afaik, the best way to do this is to issue a redirect yourself:

    Assuming your mapping is this:

    <url-mapping id=”/vanity-test”>
    <pattern>/vanity-test</pattern>
    <view-id>/folder1/folder2/vanity-test.jsf</view-id>
    </url-mapping>

    facesContext.getCurrentInstance().getExternalContext().sendRedirect("/folder1/folder2/vanity-test.jsf#tab-2")

    And PrettyFaces should issue a new URL:

    /vanity-test#tab-2

    ~lincoln

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

You must be logged in to reply to this topic.

Comments are closed.