All right! I've managed to make it work with our app. Brilliant code Lance!
:)

Area is an equivalent to your Mode object.

I had to make a few rough changes:
        if (!matcher.matches()) {
                String newPath = "/"+ area.getArea() + "/";
                transformed = link.copyWithBasePath(newPath);
                //throw new RuntimeException("Illegal path " + 
link.getBasePath());
        } else {
                String newPath = String.format("/%s/%s/%s", area.getArea(),
                                matcher.group(1), matcher.group(2));
                transformed = link.copyWithBasePath(newPath);
        }

Remove the exception throwing and transform with area only if the link is:
"/"
It's our index link that does this:
            
              ...
            

I also added an else statement and moved the area position in the
formatting.

Thanks again!

-------------
For anyone else in the same situation, Lance's solution is here:
https://github.com/uklance/tapestry-sandbox/blob/master/src/main/java/com/github/uklance/mode/ModeComponentEventLinkEncoder.java

You'll need these files:
com.github.uklance.web.DelegateRequest;
com.github.uklance.mode.ModeComponentEventLinkEncoder.java
com.github.uklance.mode.Mode.java
com.github.uklance.mode.ModeImpl.java

And put this method in your AppModule.java:
https://github.com/uklance/tapestry-sandbox/blob/master/src/main/java/com/github/uklance/services/AppModule.java#L133

You can then type http://domain//some/otherLink
and the links on the page will be transformed to something like this:
http://domain/someModeITyped/some/otherLink

If you like us need to know what the URL got prefixed with, you can inject
the environment variable to any page like this:

@Inject
private Environment environment;

And access the prefix like this (ours is Area instead of Mode):

        String getArea() {
                Area area = environment.peek(Area.class);
                return (area != null) ? area.getArea() : null;
        }




--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Dynamicly-assign-fixed-symbolic-root-folders-to-the-URL-Tapestry-Tapestry-5-3-3-tp5715743p5715785.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Reply via email to