Why not use Panels? Bob
On Thu, Sep 2, 2010 at 2:51 AM, Kuhns, John <[email protected]> wrote: > I'm not 100% sure this is what you're looking for, but I had a similar > requirement I worked out quick and dirty as so: > > border-template.htm: > <html> > <!-- common headers, title etc. --> > <body> > <!-- common elements like menu and page frame, etc. --> > #parse($subPath) > </body> > </html> > > BorderPage class (note the dynamic class assignment for getPagePath): > public class BorderPage extends Page { > > public BorderPage(){ > String subPath = getContext().getPagePath(this.getClass()); > addModel("subPath", subPath); > } > > } > > In the constructor or onInit method of a particular page, you can override > the subPath to use a particular template at any point within the chain of > inheritance. For example, I have an IntranetPage class that I use as the base > class for all my intranet pages and I override the subPath in the constructor > for IntranetPage so they all use the same "sub-template": > > intranetpage.htm: > <div class="column-container"> > <div class="left-column"> > $accordion > </div> > <div class="right-column" > > #parse($path) > <div class="clear"></div> > </div> > <div class="footer"> > </div> > </div> > > IntranetPage class (note the static class assignment for getPagePath): > public class IntranetPage extends BorderPage { > > public IntranetPage(){ > String subPath = getContext().getPagePath(IntranetPage.class); > addModel("subPath", subPath); > } > > } > > > I haven't had to extend it further (subPath, subSubPath, etc.) so I haven't > thought about it. I believe this simple approach will meet your needs, though. > > Hope this helps, > John > > -----Original Message----- > From: Andrei Ionescu [mailto:[email protected]] > Sent: Wednesday, September 01, 2010 6:53 AM > To: [email protected] > Subject: Page Decoration with the Border vs. Page inclusion in the Border? > > I guess this question was asked a few times, but I haven't seen an > answer/solution with Click that works :( : > > Is it possible to Decorate Click pages with the border-template.htm vs. > the actual "inclusion" of the page in the border-template.htm using the > #parse($page) Velocity macro? > > The actual Click approach works very well for simple > templates(border-template.htm ), but more complex ones are hard to > make/maintain, hence the requirement to "decorate" (inject their content). > > One framework that allows to arbitrarily decorate web pages (even remote > ones) is Sitemesh (the new sitemesh3 http://www.sitemesh.org/) > http://www.opensymphony.com/sitemesh/ > but unfortunately I have no idea how to use it with Click it a way that > Click still keeps all it's fantastic functionality :(. > > The "decoration" (like Sitemesh does) requirement is quite common where > the Template needs to change (e.g. in the case of the CMS, Blog, or > applications that allow customer branding), and it might have a strange > structure and requires several insertion points for the content from > pages - e.g. left column, right column, etc. > E.g. for the EditUserPage.java page edit-user.htm: > ------------- > $form > $addUserButton > ------------- > > the $form needs to go in one DIV of the border-template.htm, but the > $adduserButton needs to go to another div (e.g. on the right) - those > DIVs might be separated from another with several DIVS or nested or > contain some more things, or there might be a table there, so I can't > write in edit-user.htm something like: > --------- > <div id="center"> $form </div> > <div id="left"> $addUserButton </div> > -------- > because that would break and mess up with the structure of the > border-template.htm (that should be the only place the layout takes place). > > Click allows only one insertion point: in the DIV where > #parse($page) takes place :(. > > Using "decoration" it would be possible to insert different parts of > edit-user.htm to different places of the border-template.htm, but how? > > Any ideas how to achieve this with Click would be highly appreciated. > > regards, > Andrei. > >
