Issue with a undesired ending slash at the url generated

Splash Forums PrettyFaces Users Issue with a undesired ending slash at the url generated

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #26494

    patricknasc
    Participant

    Hello folks, I’m facing a boring issue and really couldn’t find a solution. Wish you can help me!

    I’ve created a pretty-config.xml with the following content:


    <url-mapping id=”cadastro”>
    <pattern value=”/cadastro” />
    <view-id value=”/templates/frontend/form_wizard.xhtml” />
    </url-mapping>
    <url-mapping id=”tab3″>
    <pattern value=”/cadastro#tab3″ />
    <view-id value=”/cadastro#tab3″ />
    </url-mapping>

    I’m using JSF 2.2, and my managedBean looks like this:

    @ManagedBean
    @SessionScoped
    public class CadastroBean implements Serializable {
    //..
    public String iniciarCadastro(){
    return “pretty:cadastro”;
    }

    public String avancar(){
    return “pretty:tab3″;
    }
    //…

    My first .xhtml archive invokes an h:command button with the action as follows:

    <h:commandButton id=”btnCadastrar” name=”btnCadastrar” action=”#{cadastroBean.iniciarCadastro}” class=”btn btn-primary” style=”margin-top:-13px;” value=”Avançar” />

    And my the the result is pretty fine, my managed bean is invoked and I get the desired url:
    http://localhost:8888/cadastro

    But at the same project, I’m programming a wizard with tabs, and I need to generate an url like this:

    http://localhost:8888/cadastro#tab3

    If I write down this url at my browser I got the desired result, but setting my “wizard’s foward button” that looks like this:

    <h:commandButton class=”btn blue button-next” action=”#{cadastroBean.avancar}” value=”Avançar” />

    I got an issue in which the resultant url is:

    http://localhost:8888/cadastro#tab3/

    not http://localhost:8888/cadastro#tab3, as I hoped.

    If I just cut of the last “/” of the url and refresh the page it works fine, so my question is, what should I do to take of this last /, and why it appears there if the pattern I set doesn’t have it?

    #26495

    You cannot use fragments in rewriting rules. Even if you send a redirect to /cadastro#tab3 the browser will just request /cadastro from the server. Without the fragment. That’s because fragments are just a hint for the browser to scoll to the specified position after a page is loaded. But they are NOT sent to the server as part of the request.

    I guess you will have to use something like a query parameter instead. 🙁

    #26496

    patricknasc
    Participant

    Nice, and thanks in advance for the readiness! But I got doubt on this issue… I’m debugging at server side and the return I sent was like:

    //..

    public String avancar(){
    return “pretty:tab3″;
    }

    //..
    In other words, I’m not sending the fragment value from client to server anymore, but trying the send from the server to client.

    Knowing this “tab3” is my url mapping id and considering I wished my view id value to looks like “/cadastro#tab3” but I’m getting “/cadastro#tab3/”, do you still suggest me to use query parameters? Can you detail a little bit more?

    • This reply was modified 1 year, 9 months ago by  patricknasc.
    #26498

    I think I understand your problem. The issue is that PrettyFaces doesn’t currently support generating outbound anchors based on URL mappings… it’s possible we could create an enhancement for this so that you could do something like:

    public String advance(){
    return “pretty:page#tab3:″;
    }

    I think that probably makes sense. Do you?

    This means that the mapping would be simply:

    <url-mapping id=”page”>
      <pattern value=”/page” />
      <view-id value=”/templates/frontend/form_wizard.xhtml” />
    </url-mapping>

    And you could use different anchors directly from the action method result (making it easier to select anchors progamatically).

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

You must be logged in to reply to this topic.

Comments are closed.