Outbound URL fixup rule

Splash Forums Rewrite Users Outbound URL fixup rule

Tagged: 

This topic contains 5 replies, has 2 voices, and was last updated by  Christian Kaltepoth 3 years, 5 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #19588

    Anonymous

    Have found both PrettyFaces and rewrite very useful, but as always want to do a little more.

    There is a problem with webflow and view resolving that I want to workaround using rewrite:

    For some unknown reason webflow generates the URL:

    http://server/app/WEB-INF/views/login.xhtml?execution=e3s1

    and should be

    http://server/app/controller/flow?execution=e3s1

    have tried with CDN rule but cannot get the query in the resulting URL, also do not understand how to access request parameters so I can extract controller and flow information.

    Any pointer is appreciated, also have seen this problem if you try to integrate Spring MVC with Primefaces so a fix would be great! (I know this is no the root cause but I will help a lot!).

    Thanks

    #23460

    Anonymous

    Maybe this is not the best solution, have divided the problem in two rules.

    – As have not found how to get the controller and the flow in the outbound rule, just do a partial fixup with:

    config.defineRule()
    .when(Direction.isOutbound().and(
    URL.matches("{p}/WEB-INF/{s}execution{q}")
    .where("p").matches(".*")
    .where("s").matches(".*")
    .where("q").matches(".*")))
    .perform(Substitute.with("{p}/flow/{q}"));

    This way I get an URL like http://server:port/app/flow/paramswhere “flow” is the constant I use for the next rule.

    – And also adding an inbund rule to finish the job:

    config.addRule(Join.path("/flow/{q}").to("/controller/flow?execution={q}").when(Direction.isInbound()));

    Still trying to figure out how to access the “Referrer” header to extract controller and flow values.

    The header referrer is in the “correct form”: http://server:port/app/controller/flow?execution=paramsso from there I could get the values to rebuild the URL.

    Thanks,

    #23461

    There is a Header condition that you could try to use to access the Referrer header.

    I don’t know WebFlow, and without having access to the application it is difficult to help here.

    However, it may be also an option to implement a custom condition/operation or rule. With this you can implement any behavior you want. There are a few examples for custom conditions and operations here:

    http://ocpsoft.org/rewrite/examples/

    Let us know if you run into any problems.

    #23462

    Anonymous

    Have tried to use the Headercondition, but have not figured out how to bind the result to a variable, when I use the variable afterwards I get an exception.

    In this case I think the best solution is using only one outbound rule, but in that scenario I need access to the URL of the requested page, so I can fixup the URL’s that are included inside that page.

    Any pointers?

    #23463

    Anonymous

    Have this rule:

    config.defineRule()
    .when(Direction.isOutbound()
    .and(Path.matches("{p}/WEB-INF/{s}")
    .where("p").matches(".*")
    .where("s").matches(".*xhtml")))
    .when(QueryString.parameterExists("execution"))
    .perform(Substitute.with("{p}/controller/flow?execution={execution}"));

    Also, in a bean I have the correct values for controller/flow but have not found a way to bind them to a variable so the substitution reads as {p}/{controllerPath}?execution={execution}.

    Thanks,

    #23464

    I don’t have access to the code right now so I cannot look this up, but I think you can do something like:

    .perform(Substitute.with("{p}/controller/flow?execution={execution}").where("execution").bindsTo("myBean.myProperty"));

    With myBean.myProperty beeing an EL expression pointing to the correct value.

    Does this work?

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

You must be logged in to reply to this topic.

Comments are closed.