Reply To: I think h:link is generated wrong

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

#26532

welyab
Participant

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:

.addRule(Join.path("/nota-avulsa-produtor-rural")
             .to("/faces/produtor-rural/emissao-nota-avulsa.xhtml"));

(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

@Override
   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.

Thanks.

  • 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.