I think h:link is generated wrong

Splash Forums Rewrite Users I think h:link is generated wrong


This topic contains 2 replies, has 2 voices, and was last updated by  welyab 7 years, 2 months ago.

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



    I’m using rewrite 2.0.9.Final.

    Supose that my application is on “nota-avulsa” context path.

    My ApplicationConfigurationProvider looks like:

    return ConfigurationBuilder.begin()

    When I write

    <h:link outcome="/faces/nota-avulsa/pesquisar-notas.xhtml">Pesquisar Notas</h:link>

    A gente negerated HTML like that:

    <a href="/pesquisa-nota-avulsa">Pesquisar Notas</a> (without context path name: "nota-avulsa")

    Is this the right behavior?

    I expected a generated link with context path, because if a click on link with contextpath, I get 404 error pager.

    <a href="/nota-avulsa/pesquisa-nota-avulsa">Pesquisar Notas</a>

    If a write the URL manually on browser, the write RULE works fine.



    I think you have to remove the /faces prefix when using h:link.


    <h:link outcome="/nota-avulsa/pesquisar-notas.xhtml">Pesquisar Notas</h:link>

    Instead of:

    <h:link outcome="/faces/nota-avulsa/pesquisar-notas.xhtml">Pesquisar Notas</h:link>



    I found the cause of problem.

    The method org.ocpsoft.rewrite.servlet.config.Substitute,performHttp(....) performs a check by testing if the generated URL starting with the context path.
    In my first post, I do not expose the real URL configuration (sorry my mistake).

    A real case is fallow:


    (register invoice for farmers)

    The context path of application is "/nota-avulsa", and notice that Join.path starts with "/nota-avulsa..."as well. This cause my problem.

    The Rewrite calls the fallow method in org.ocpsoft.rewrite.servlet.config.Substitute

       public void performHttp(final HttpServletRewrite event, final EvaluationContext context)
          if (event instanceof HttpInboundServletRewrite)
             String target = location.getBuilder().build(event, context, Transpositions.encodePath());
             ((HttpInboundServletRewrite) event).forward(target);
          else if (event instanceof HttpOutboundServletRewrite)
             ParameterizedPatternBuilder builder = location.getBuilder();
             String target = builder.build(event, context, Transpositions.encodePath());
             if (((HttpOutboundServletRewrite) event).getOutboundAddress().getPath().startsWith(event.getContextPath())
                      && target.startsWith("/")
                      && !target.startsWith("//")
                      // ------------------------------------------------------------------
                      // -- Here the cause of problem
                      && !target.startsWith(event.getContextPath())) // <<<<<<<<<
                target = event.getContextPath() + target;
             ((HttpOutboundServletRewrite) event).setOutboundAddress(AddressBuilder.create(target));

    My question is, is this a known restriction, which Join.path can not start with the same context name of the application?

    By now, I will continue the software production just change Join.path values to others different of context path name.


    • This reply was modified 7 years, 2 months ago by  welyab.
    • This reply was modified 7 years, 2 months ago by  welyab.
    • This reply was modified 7 years, 2 months ago by  welyab.
    • This reply was modified 7 years, 2 months ago by  welyab.
Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘Rewrite Users’ is closed to new topics and replies.

Comments are closed.