General question about a mega-rewrite application code sample.

Splash Forums Rewrite Users General question about a mega-rewrite application code sample.

This topic contains 4 replies, has 3 voices, and was last updated by  balteo 5 years ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #18345

    balteo
    Participant

    Hello,

    I am new to rewrite which seems to be very powerful. I would be grateful if someone could translate the code below into plain English:

    ******************

    .addRule(Join.path(“/{one}”).to(“/{one}.xhtml”)

    .when(Not.any(Path.matches(“.*javax.faces.resource.*”))

    .and(DispatchType.isRequest().or(Direction.isOutbound()))))

    ******************

    Especially the [Direction.isOutbound()] part.

    Regards,

    Julien.

    #22515

    Hey there, here goes:

    .addRule(Join.path(“/{one}”).to(“/{one}.xhtml”)

    Inbound URL /{one} maps to internal resource `/{one}.xhtml, where ‘one’ matches any non ‘/’ character… except when the path contains “javax.faces.resource” (except this is an old configuration, since regular expressions must be defined using {params} now.

    And only perform this rule when the inbound request type is Request (not forward, error, include, or async,) or the URL is being generated as an outbound link or redirect.

    #22516

    balteo
    Participant

    Thanks Lincoln,

    -First, can you please confirm the following: inbound vs outbound links according to my understanding: an inbound link e.g. “/article/28/” maps to an existing resource e.g. “?article=28” the latter being ALSO visible whereas an outbound link hides the “ugly” url completely. Right?

    -Second, I am not sure I understand the “Not.any” bit (Return a new Condition that negates the given Condition instance) according to javadocs.

    -Third, from the sample application point of view, what is the purpose of the last part of the rule i.e. [And only perform this rule when the inbound request type is Request (not forward, error, include, or async,) or the URL is being generated as an outbound link or redirect.]

    Regards,

    J.

    #22517

    Hey Julien,

    regarding the first two questions:

    First question

    Inbound requests are incoming requests that are somehow processed by the servlet engine. Examples for this cases are requests sent by the browser, requests which are internally forwarded and so on.

    In contrast to this outbound refers to URLs generated by the container. A typical example are URLs rendered to the HTML page. For example if a JSF form is rendered the JSF implementation has to insert an URL for the postback to the action attribute. You could change this URL using an outbound rule. Another example are redirects. If the servlet container sends a redirect outbound rules allow to rewrite these URLs.

    Second question

    Not.any() simply negates the rule you supply as an argument. The method is called any because you can supply more than one rule to the method. So the method means something like “return true if none of the supplied conditions are true”.

    Christian

    #22518

    balteo
    Participant

    Thanks a lot Christian and Lincoln.

    I understand much better now.

    Regards,

    Julien.

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

You must be logged in to reply to this topic.

Comments are closed.