@Contribute(PageRenderLinkTransformer.class)
@Primary
public static void 
provideURLRewriting(OrderedConfiguration<PageRenderLinkTransformer> 
configuration) {
    configuration.addInstance("SupportOldPhpUrls", 
OldPhpSystemLinkTransformer.class);
}



public class OldPhpSystemLinkTransformer implements PageRenderLinkTransformer {

    private static final String[] COUNTYS = {"oppland", "hedmark", 
"sortrondelag", "buskerud", "telemark", "nordtrondelag", "troms", "akershus", 
"nordland", "oslo", "hordaland", "austagder", "moreogromsdal", "vestagder", 
"rogaland", "sognogfjordane", "finnmark", "vestfold", "ostfold", "lappland"};

    @Inject
    private ContextValueEncoder contextValueEncoder;
    @Inject
    ComponentClassResolver componentClassResolver;

    @Override
    public Link transformPageRenderLink(Link defaultLink, 
PageRenderRequestParameters parameters) {
        return defaultLink;
    }

    @Override
    public PageRenderRequestParameters decodePageRenderRequest(Request request) 
{
        String path = request.getPath();
        if (urlStartsWithCounty(path)) {
            String[] split = path.split("/");
            if (split.length < 2) return null;
            String county = split[1];
            String destination = split.length > 2 ? split[2] :null;
            return  new PageRenderRequestParameters(
                     
componentClassResolver.resolvePageClassNameToPageName(OldPhpUrlHandler.class.getCanonicalName()),
                    new URLEventContext(contextValueEncoder, new 
String[]{county, destination}),
                    false);
        }
        return null;
    }

    private boolean urlStartsWithCounty(String path) {
        for (String s : COUNTYS) {
            if (path.startsWith("/" + s)) return true;
        }
        return false;
    }
}




From: slqiTapestry [via Apache Tapestry Mailing List Archives] 
[mailto:ml-node+s1045711n573291...@n5.nabble.com]
Sent: 29. august 2016 13:28
To: Svein-Erik Løken <sv...@jacilla.no>
Subject: RE: Logical Page Name Shortening

Okay thanks,


I read the https://tapestry.apache.org/url-rewriting.html and saw that Tapestry 
URL Rewriting API does not exist anymore and has been replaced with the 
LinkTransformer service.


Is there any example to use this service ?


________________________________
De : Thiago H de Paula Figueiredo <[hidden 
email]</user/SendEmail.jtp?type=node&node=5732917&i=0>>
Envoyé : vendredi 26 août 2016 15:18:31
À : Tapestry users
Objet : Re: Logical Page Name Shortening

You can always create a Jira ticket asking for a new configuration symbol
to be created to turn off logical page name shortening. Or, as Dmitry
already suggested, you can use URL rewriting to shape the URLs to your
needs. :)

On Thu, 25 Aug 2016 22:17:44 -0300, abangkis <[hidden 
email]</user/SendEmail.jtp?type=node&node=5732917&i=1>> wrote:

> I encounter this problem too. I have a de folder (short for data entry)
> and
> add Node page inside it.
>
> Then the tapestry generated URL become mysite/de/train/addNo (supposed to
> mysite/de/train/addNode). In most cases the shortening work well, but in
> this case, it break REST :(. I later decided to rename and refactor the
> folder, but would be great if tapestry have better alternative to handle
> this case more elegantly in the future. :)
>
> On Thu, Aug 25, 2016 at 12:01 AM, Dmitry Gusev <[hidden 
> email]</user/SendEmail.jtp?type=node&node=5732917&i=2>>
> wrote:
>
>> Looking at code I don't think this is something you can configure easily
>> with a symbol.
>>
>> If you really need to change page URLs you may use one of the URL
>> rewriting
>> techniques, i.e.:
>>
>> https://tapestry.apache.org/url-rewriting.html
>> http://www.tynamo.org/tapestry-routing+guide/
>>
>>
>> On Wed, Aug 24, 2016 at 6:26 PM, Lherm Nicolas <[hidden 
>> email]</user/SendEmail.jtp?type=node&node=5732917&i=3>> wrote:
>>
>> > Okay I understand this.
>> >
>> >
>> > However , would it posssible to keep the name without the "cut" by
>> > Tapestry .
>> >
>> >
>> > I mean create a page like address / CreateAddress and have the url
>> ending
>> > with CreateAdress ?
>> >
>> >
>> > ________________________________
>> > De : Dmitry Gusev <[hidden 
>> > email]</user/SendEmail.jtp?type=node&node=5732917&i=4>>
>> > Envoyé : mercredi 24 août 2016 17:18:49
>> > À : Tapestry users
>> > Objet : Re: Logical Page Name Shortening
>> >
>> > To make URLs shorter/prettier, so you could name your java classes &
>> TMLs
>> > differently, i.e.:
>> >
>> > address/CreateAddress => address/create
>> > user/CreateUser => user/create
>> >
>> > Without this feature your URLs would be address/createaddress and
>> > user/createuser, or you would have to name your pages the same but put
>> them
>> > to different packages, which may be not convenient when you want to
>> lookup
>> > a class by its name or when you want to import one user.Create to
>> > address.Create -- in java you'd have to use fully qualified names.
>> >
>> > On Wed, Aug 24, 2016 at 6:12 PM, Lherm Nicolas <[hidden 
>> > email]</user/SendEmail.jtp?type=node&node=5732917&i=5>>
>> wrote:
>> >
>> > > Hi,
>> > >
>> > >
>> > > Yes I saw it, but I don't understand why tapestry removed the
>> suffix.
>> > >
>> > > ________________________________
>> > > De : Dmitry Gusev <[hidden 
>> > > email]</user/SendEmail.jtp?type=node&node=5732917&i=6>>
>> > > Envoyé : mercredi 24 août 2016 16:54:46
>> > > À : Tapestry users
>> > > Objet : Re: Logical Page Name Shortening
>> > >
>> > > Hi, have you seen this?
>> > >
>> > > http://tapestry.apache.org/page-navigation.html
>> > >
>> > > On Wed, Aug 24, 2016 at 5:38 PM, Lherm Nicolas <[hidden 
>> > > email]</user/SendEmail.jtp?type=node&node=5732917&i=7>>
>> wrote:
>> > >
>> > > > Hello,
>> > > >
>> > > >
>> > > > I have a question about the shortheneng URL's of somes page names.
>> > > >
>> > > >
>> > > > I read that Tapestry removed the redundant suffix of the URL in
>> > certains
>> > > > cases, and and wanna know why or where do they do this ?
>> > > >
>> > > >
>> > > > Thanks
>> > > >
>> > > >
>> > >
>> > >
>> > > --
>> > > Dmitry Gusev
>> > >
>> > > AnjLab Team
>> > > http://anjlab.com
>> > >
>> >
>> >
>> >
>> > --
>> > Dmitry Gusev
>> >
>> > AnjLab Team
>> > http://anjlab.com
>> >
>>
>>
>>
>> --
>> Dmitry Gusev
>>
>> AnjLab Team
>> http://anjlab.com
>>
>
>
>


--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden 
email]</user/SendEmail.jtp?type=node&node=5732917&i=8>
For additional commands, e-mail: [hidden 
email]</user/SendEmail.jtp?type=node&node=5732917&i=9>


________________________________
If you reply to this email, your message will be added to the discussion below:
http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Logical-Page-Name-Shortening-tp5732904p5732917.html
To unsubscribe from users@tapestry.apache.org<mailto:users@tapestry.apache.org> 
Mailing List Archives, click 
here<http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2375125&code=c3ZlaW5AamFjaWxsYS5ub3wyMzc1MTI1fC0xNTM4NzY2ODg4>.
NAML<http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>

Reply via email to