Re: Wicket Layout Design
On 19/07/2012 17:01, divad91 wrote: Hi, I am new to Wicket. I'm working on a multi province web application. The goal is to use the same web application for all provinces. CSS and some business logic will differ for each province. I want to know the best ways to instantiate my layout components in my base page. (Using markup inheritance for page composition) * Each layout component could be subclassed. public class BasePage extends WebPage { public BasePage() { // Want to know the best way to instanciate // HeaderXXX or HeaderYYY for example base on the province. add(new Header()); add(new SideBar()); add(new Footer()); } } My BasePage is in a common maven module. Each province subclassed pages and components are in a different maven module. I read that using factories to instanciate components was not a good idea (http://blog.comsysto.com/2011/05/09/apache-wicket-best-practices-2/) Do you have a better approach to accomplish this? Hi David, Generally, you would use (potentially abstract) factory methods to create you overridable components. So: public abstract class BasePage { public BasePage(){} // these are the factory methods to create the components. // I like to use the prefix createNew, you can change. protected abstract Component createNewHeader(String componentId); protected abstract Component createNewSideBar(String componentId); protected abstract Component createNewFooter(String componentId); // Then add the components in onInitialize(). // onInitialize() is much under used. It allows us to call overridden method // outside of the constructor. @Override public void onInitialize() { super.onInitialize(); add(createNewHeader(header)); add(createNewSideBar(sideBar)); add(createNewFooter(footer)); } } - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket Layout Design
Thanks Jesse for your reply. The only drawback of this method is that I will need to override theses 3 methods (createNewHeader, createNewFooter...) in all pages that extends BasePage.java.Ideally I would like to avoid copying code but I think it's the cleaner way to override layout components. Thanks again ! David -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Layout-Design-tp4650630p4650734.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: Wicket Layout Design
You can try using a TransparentWebMarkupContainer so that you won't always have to add them to the page hierarchy and only override your factory methods when you need to. For a code-snippet example see this thread: http://apache-wicket.1842946.n4.nabble.com/1-5-6-0-dynamically-named-CSS-JS- amp-images-resources-tc4650635.html#a4650638 ~ Thank you, Paul Bors -Original Message- From: divad91 [mailto:diva...@hotmail.com] Sent: Monday, July 23, 2012 12:40 PM To: users@wicket.apache.org Subject: Re: Wicket Layout Design Thanks Jesse for your reply. The only drawback of this method is that I will need to override theses 3 methods (createNewHeader, createNewFooter...) in all pages that extends BasePage.java.Ideally I would like to avoid copying code but I think it's the cleaner way to override layout components. Thanks again ! David -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Layout-Design-tp4650630p46 50734.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Wicket Layout Design
Hi, I am new to Wicket. I'm working on a multi province web application. The goal is to use the same web application for all provinces. CSS and some business logic will differ for each province. I want to know the best ways to instantiate my layout components in my base page. (Using markup inheritance for page composition) * Each layout component could be subclassed. public class BasePage extends WebPage { public BasePage() { // Want to know the best way to instanciate // HeaderXXX or HeaderYYY for example base on the province. add(new Header()); add(new SideBar()); add(new Footer()); } } My BasePage is in a common maven module. Each province subclassed pages and components are in a different maven module. I read that using factories to instanciate components was not a good idea (http://blog.comsysto.com/2011/05/09/apache-wicket-best-practices-2/) Do you have a better approach to accomplish this? Thanks a lot and sorry for my english David -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Layout-Design-tp4650630.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org