Thanks for your answers. Both sound quite interesting. I will check them although JSPs are not my first choice too. Because I didn't found an alternative yet, I am also interested in new ideas.
-----Ursprüngliche Nachricht----- Von: sam lee [mailto:[email protected]] Gesendet: Freitag, 1. April 2011 15:30 An: [email protected] Betreff: Re: Inheritance and URL decomposition I think he really means <cq:include/>. /apps/component/page /apps/component/page/head.jsp /apps/component/page/body.jsp /apps/component/page/center.jsp ... /apps/component/page/html.jsp And, in html.jsp, you do: <cq:include script="center.jsp"/> And, you have: /apps/component/product @sling:resourceSuperType = component/page /apps/component/product/center.jsp /apps/component/product/simple.html.jsp And, in simple.html.jsp, you do: <cq:include script="html.jsp"/> Then, I think component/page/html.jsp will be included since you did not overwrote it in component/product. And, the html.jsp in turn will include center.jsp.. and since center.jsp is overwritten, product/center.jsp will be used. But that's CQ stuff. In sling, you'll have to write your own taglib that does that. I am not sure if <cq:include/> is open source. But seriously... I would want to move away from jsp and use a proper html templating. Has anyone done this? On Fri, Apr 1, 2011 at 9:21 AM, Justin Edelson <[email protected]>wrote: > Depending on the scope of the change between the regular and "simple" > views, one thing you could do is just have an if statement in your > center.jsp which does something like this: > > <% if ("simple".equals(slingRequest.getSelectorString()) { %> > <!-- do the simple thing --> > <% } else { %> > <!-- do the non-simple thing --> > <% } %> > > Within the if / else blocks, you could include other scripts of course. > > HTH, > Justin > > On Fri, Apr 1, 2011 at 5:27 AM, Marco Dohnke <[email protected]> > wrote: > > Yes I know. I also tried several ways with the resourceSuperType. The > problem is: > > > > /apps/myapp/components/product/center.jsp overwrites > /apps/myapp/components/page/center.jsp because the resourceSuperType is set > on it. > > > > But a sling selector is not useable for that. If I use > /apps/.../product/simple.jsp I have to reimplement all what I implemented in > the page component. That's not very DRY. I thought there is a way to achieve > this. > > > > Kind regards, > > Marco > > > > -----Ursprüngliche Nachricht----- > > Von: Felix Meschberger [mailto:[email protected]] > > Gesendet: Freitag, 1. April 2011 10:50 > > An: [email protected] > > Betreff: Re: Inheritance and URL decomposition > > > > Hi, > > > > Am Donnerstag, den 31.03.2011, 14:41 +0100 schrieb sam lee: > >> Day CQ mailing list is: http://groups.google.com/group/day-communique > >> > >> If the resource, /products/my-first-product , has sling:resourceType = > >> /apps/foo/product, > >> then, to render .html version of the resource, > /apps/foo/product/html.jsp > >> will be used. > >> To render simple.html version of the resource, > >> /apps/foo/product/simple.html.jsp will be used. > >> > >> You can do whatever you want in those .jsp files. > >> > >> I am not sure about inheritance. > >> You can set /products/my-first-product's sling:resourceSuperType = > >> /apps/foo/page .. > >> But I am not sure if that will help for your script resolution (using > >> <sling:include/>). > > > > Yes, sling supports sling:resourceSuperType of course and thus all > > resolutions for scripts and servlets will check the resource type > > hierarchy. > > > > Regards > > Felix > > > > > > >
