ways of doing markup Inheritance [WAS Re: Page title when using markup inheritance]
Sure there a dozens of ways todo this, mine is just one of them. Im starting a new thread since it'll be more exposed then. The idea is following: Parent: public class BasePage extends WebPage { protected final String LINK_LABEL_ID = linkText; protected final String LINK_ID = link; protected final String FOOTER_ID = item; protected final String HEADER_ID = item; protected ListWebMarkupContainer generalAccordionItem = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer footer = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer header = new ArrayListWebMarkupContainer(); private AccordionPanel accordionPanel; /** * Constructor that is invoked when page is invoked without a session. * * @param parameters *Page parameters */ public BasePage() { accordionPanel = new AccordionPanel(accordionMenu); add(accordionPanel); add(new ListView(footerContent, footer) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); add(new ListView(headerContent, header) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); } protected void addMenu(AccordionPanelItem accordionPanelItem) { accordionPanel.addMenu(accordionPanelItem); }; protected void addFooter(WebMarkupContainer webMarkupContainer) { footer.add(webMarkupContainer); }; protected void addHeader(WebMarkupContainer webMarkupContainer) { header.add(webMarkupContainer); }; Subs/Children then calls the methods... Problem with this technique is that you need to use the right markup id's.. To make sure they are always set, and giving full control to the child/sub on what to add, I'd suggest that you create a BasePanel which encapsules the id, and then required that instead of a markupcontainer, that way subs/child only need to have panels that extend the basepanel... But it depends on your needs, mine weren't that tricky.. regards Nino Jonathan Locke wrote: could you share this technique? i think this might be a good idea. Nino.Martinez wrote: On the other hand, I've also done something with listviews.. Allowing sub pages adding markup items to menus etc Using the listviews as place holders... Kaspar Fischer wrote: Ah, 'course! Should have thought of it, that's an option they mention in Wicket in Action. However, Sebastiaan's solution can be reused in places where the markup you have to change is not in head. -- Good to know. On 04.03.2008, at 15:27, richardwilko wrote: The way I do it is; dont specify a title in your base page then just add the title in the subpage: base page.html html !-- anything shared in all the pages eg a base.css file -- head /head body wicket:child/ /body /html subpage.html: wicket:head titlehard code or use wicket label to add this/title /wicket:head wicket:extend !-- anything ... -- /wicket:extend subpage.java Richard hbf wrote: I am using markup inheritance (wicket:child and wicket:extend) and need to set the page title from my subpage. I currently add a label in the base class (BasePage.java) and make it use an abstract method getTitle(), which is overridden in the subclass (SubPage.java). Has anybody found a better way? Here's my solution: !-- BasePage.html -- html head title wicket:id=title[Page title]/title /head body wicket:child/ /body /html !-- SubPage.html -- wicket:extend !-- anything ... -- /wicket:extend public abstract class BasePage extends WebPage { // ... public BasePage(final PageParameters parameters) { add(new Label(title, new PropertyModel(this, title))); } public abstract String getTitle(); } public class SubPage extends BasePage { // ... public String getTitle() { return whatever title; } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Page-title-when-using-markup-inheritance-tp15827853p15828280.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ways of doing markup Inheritance [WAS Re: Page title when using markup inheritance]
EEK!, I'll try once more to create a new thread! Nino Saturnino Martinez Vazquez Wael wrote: Sure there a dozens of ways todo this, mine is just one of them. Im starting a new thread since it'll be more exposed then. The idea is following: Parent: public class BasePage extends WebPage { protected final String LINK_LABEL_ID = linkText; protected final String LINK_ID = link; protected final String FOOTER_ID = item; protected final String HEADER_ID = item; protected ListWebMarkupContainer generalAccordionItem = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer footer = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer header = new ArrayListWebMarkupContainer(); private AccordionPanel accordionPanel; /** * Constructor that is invoked when page is invoked without a session. * * @param parameters *Page parameters */ public BasePage() { accordionPanel = new AccordionPanel(accordionMenu); add(accordionPanel); add(new ListView(footerContent, footer) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); add(new ListView(headerContent, header) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); } protected void addMenu(AccordionPanelItem accordionPanelItem) { accordionPanel.addMenu(accordionPanelItem); }; protected void addFooter(WebMarkupContainer webMarkupContainer) { footer.add(webMarkupContainer); }; protected void addHeader(WebMarkupContainer webMarkupContainer) { header.add(webMarkupContainer); }; Subs/Children then calls the methods... Problem with this technique is that you need to use the right markup id's.. To make sure they are always set, and giving full control to the child/sub on what to add, I'd suggest that you create a BasePanel which encapsules the id, and then required that instead of a markupcontainer, that way subs/child only need to have panels that extend the basepanel... But it depends on your needs, mine weren't that tricky.. regards Nino Jonathan Locke wrote: could you share this technique? i think this might be a good idea. Nino.Martinez wrote: On the other hand, I've also done something with listviews.. Allowing sub pages adding markup items to menus etc Using the listviews as place holders... Kaspar Fischer wrote: Ah, 'course! Should have thought of it, that's an option they mention in Wicket in Action. However, Sebastiaan's solution can be reused in places where the markup you have to change is not in head. -- Good to know. On 04.03.2008, at 15:27, richardwilko wrote: The way I do it is; dont specify a title in your base page then just add the title in the subpage: base page.html html !-- anything shared in all the pages eg a base.css file -- head /head body wicket:child/ /body /html subpage.html: wicket:head titlehard code or use wicket label to add this/title /wicket:head wicket:extend !-- anything ... -- /wicket:extend subpage.java Richard hbf wrote: I am using markup inheritance (wicket:child and wicket:extend) and need to set the page title from my subpage. I currently add a label in the base class (BasePage.java) and make it use an abstract method getTitle(), which is overridden in the subclass (SubPage.java). Has anybody found a better way? Here's my solution: !-- BasePage.html -- html head title wicket:id=title[Page title]/title /head body wicket:child/ /body /html !-- SubPage.html -- wicket:extend !-- anything ... -- /wicket:extend public abstract class BasePage extends WebPage { // ... public BasePage(final PageParameters parameters) { add(new Label(title, new PropertyModel(this, title))); } public abstract String getTitle(); } public class SubPage extends BasePage { // ... public String getTitle() { return whatever title; } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Page-title-when-using-markup-inheritance-tp15827853p15828280.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -
ways of doing markup Inheritance [WAS Re: Page title when using markup inheritance]
Sure there a dozens of ways todo this, mine is just one of them. Im starting a new thread since it'll be more exposed then. The idea is following: Parent: public class BasePage extends WebPage { protected final String LINK_LABEL_ID = linkText; protected final String LINK_ID = link; protected final String FOOTER_ID = item; protected final String HEADER_ID = item; protected ListWebMarkupContainer generalAccordionItem = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer footer = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer header = new ArrayListWebMarkupContainer(); private AccordionPanel accordionPanel; /** * Constructor that is invoked when page is invoked without a session. * * @param parameters *Page parameters */ public BasePage() { accordionPanel = new AccordionPanel(accordionMenu); add(accordionPanel); add(new ListView(footerContent, footer) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); add(new ListView(headerContent, header) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); } protected void addMenu(AccordionPanelItem accordionPanelItem) { accordionPanel.addMenu(accordionPanelItem); }; protected void addFooter(WebMarkupContainer webMarkupContainer) { footer.add(webMarkupContainer); }; protected void addHeader(WebMarkupContainer webMarkupContainer) { header.add(webMarkupContainer); }; Subs/Children then calls the methods... Problem with this technique is that you need to use the right markup id's.. To make sure they are always set, and giving full control to the child/sub on what to add, I'd suggest that you create a BasePanel which encapsules the id, and then required that instead of a markupcontainer, that way subs/child only need to have panels that extend the basepanel... But it depends on your needs, mine weren't that tricky.. regards Nino -- -Wicket for love -Jme for fun Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ways of doing markup Inheritance [WAS Re: Page title when using markup inheritance]
On 3/5/08, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: Sure there a dozens of ways todo this, mine is just one of them. Im starting a new thread since it'll be more exposed then. The idea is following: Parent: public class BasePage extends WebPage { protected final String LINK_LABEL_ID = linkText; protected final String LINK_ID = link; protected final String FOOTER_ID = item; protected final String HEADER_ID = item; protected ListWebMarkupContainer generalAccordionItem = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer footer = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer header = new ArrayListWebMarkupContainer(); private AccordionPanel accordionPanel; /** * Constructor that is invoked when page is invoked without a session. * * @param parameters *Page parameters */ public BasePage() { accordionPanel = new AccordionPanel(accordionMenu); add(accordionPanel); add(new ListView(footerContent, footer) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); add(new ListView(headerContent, header) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); } protected void addMenu(AccordionPanelItem accordionPanelItem) { accordionPanel.addMenu(accordionPanelItem); }; protected void addFooter(WebMarkupContainer webMarkupContainer) { footer.add(webMarkupContainer); }; protected void addHeader(WebMarkupContainer webMarkupContainer) { header.add(webMarkupContainer); }; Subs/Children then calls the methods... Problem with this technique is that you need to use the right markup id's.. To make sure they are always set, and giving full control to the child/sub on what to add, I'd suggest that you create a BasePanel which encapsules the id, and then required that instead of a markupcontainer, that way subs/child only need to have panels that extend the basepanel... Couldn't you use a VelocityPanel to generate your markup and have it parse the markup after it's generated to avoid the whole need to use the right markup ids part? I was thinking about doing something like this for generating dynamic editor forms (a la Trails) for objects, since Wicket doesn't like you putting TextFields on spans (you must use an input tag). I was going to have a Velocity script that decides what type of tag to spit out based on the type of component in the list. But it depends on your needs, mine weren't that tricky.. regards Nino Jonathan Locke wrote: could you share this technique? i think this might be a good idea. Nino.Martinez wrote: On the other hand, I've also done something with listviews.. Allowing sub pages adding markup items to menus etc Using the listviews as place holders... Kaspar Fischer wrote: Ah, 'course! Should have thought of it, that's an option they mention in Wicket in Action. However, Sebastiaan's solution can be reused in places where the markup you have to change is not in head. -- Good to know. On 04.03.2008, at 15:27, richardwilko wrote: The way I do it is; dont specify a title in your base page then just add the title in the subpage: base page.html html !-- anything shared in all the pages eg a base.css file -- head /head body wicket:child/ /body /html subpage.html: wicket:head titlehard code or use wicket label to add this/title /wicket:head wicket:extend !-- anything ... -- /wicket:extend subpage.java Richard hbf wrote: I am using markup inheritance (wicket:child and wicket:extend) and need to set the page title from my subpage. I currently add a label in the base class (BasePage.java) and make it use an abstract method getTitle(), which is overridden in the subclass (SubPage.java). Has anybody found a better way? Here's my solution: !-- BasePage.html -- html head title wicket:id=title[Page title]/title /head body wicket:child/ /body /html !-- SubPage.html -- wicket:extend !-- anything ... -- /wicket:extend public abstract class BasePage extends WebPage { // ... public BasePage(final PageParameters parameters) { add(new Label(title, new PropertyModel(this, title))); }
Re: ways of doing markup Inheritance [WAS Re: Page title when using markup inheritance]
James Carman wrote: On 3/5/08, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: Sure there a dozens of ways todo this, mine is just one of them. Im starting a new thread since it'll be more exposed then. The idea is following: Parent: public class BasePage extends WebPage { protected final String LINK_LABEL_ID = linkText; protected final String LINK_ID = link; protected final String FOOTER_ID = item; protected final String HEADER_ID = item; protected ListWebMarkupContainer generalAccordionItem = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer footer = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer header = new ArrayListWebMarkupContainer(); private AccordionPanel accordionPanel; /** * Constructor that is invoked when page is invoked without a session. * * @param parameters *Page parameters */ public BasePage() { accordionPanel = new AccordionPanel(accordionMenu); add(accordionPanel); add(new ListView(footerContent, footer) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); add(new ListView(headerContent, header) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); } protected void addMenu(AccordionPanelItem accordionPanelItem) { accordionPanel.addMenu(accordionPanelItem); }; protected void addFooter(WebMarkupContainer webMarkupContainer) { footer.add(webMarkupContainer); }; protected void addHeader(WebMarkupContainer webMarkupContainer) { header.add(webMarkupContainer); }; Subs/Children then calls the methods... Problem with this technique is that you need to use the right markup id's.. To make sure they are always set, and giving full control to the child/sub on what to add, I'd suggest that you create a BasePanel which encapsules the id, and then required that instead of a markupcontainer, that way subs/child only need to have panels that extend the basepanel... Couldn't you use a VelocityPanel to generate your markup and have it parse the markup after it's generated to avoid the whole need to use the right markup ids part? I was thinking about doing something like this for generating dynamic editor forms (a la Trails) for objects, since Wicket doesn't like you putting TextFields on spans (you must use an input tag). I was going to have a Velocity script that decides what type of tag to spit out based on the type of component in the list. i'll reply in the other thread... But it depends on your needs, mine weren't that tricky.. regards Nino Jonathan Locke wrote: could you share this technique? i think this might be a good idea. Nino.Martinez wrote: On the other hand, I've also done something with listviews.. Allowing sub pages adding markup items to menus etc Using the listviews as place holders... Kaspar Fischer wrote: Ah, 'course! Should have thought of it, that's an option they mention in Wicket in Action. However, Sebastiaan's solution can be reused in places where the markup you have to change is not in head. -- Good to know. On 04.03.2008, at 15:27, richardwilko wrote: The way I do it is; dont specify a title in your base page then just add the title in the subpage: base page.html html !-- anything shared in all the pages eg a base.css file -- head /head body wicket:child/ /body /html subpage.html: wicket:head titlehard code or use wicket label to add this/title /wicket:head wicket:extend !-- anything ... -- /wicket:extend subpage.java Richard hbf wrote: I am using markup inheritance (wicket:child and wicket:extend) and need to set the page title from my subpage. I currently add a label in the base class (BasePage.java) and make it use an abstract method getTitle(), which is overridden in the subclass (SubPage.java). Has anybody found a better way? Here's my solution: !-- BasePage.html -- html head title wicket:id=title[Page title]/title /head body wicket:child/ /body /html !-- SubPage.html -- wicket:extend !-- anything ... -- /wicket:extend public abstract class BasePage extends WebPage { // ... public BasePage(final PageParameters parameters) { add(new Label(title, new PropertyModel(this, title))); } public abstract String getTitle(); } public class SubPage extends
Re: ways of doing markup Inheritance [WAS Re: Page title when using markup inheritance]
Answer below: James Carman Wrote: Couldn't you use a VelocityPanel to generate your markup and have it parse the markup after it's generated to avoid the whole need to use the right markup ids part? I was thinking about doing something like this for generating dynamic editor forms (a la Trails) for objects, since Wicket doesn't like you putting TextFields on spans (you must use an input tag). I was going to have a Velocity script that decides what type of tag to spit out based on the type of component in the list. What I found simple, which I perhaps did not explain clearly.. Where to only accept basePanels in forexample addMenu method, that way a base panel would look something like this: public class BasePanelItem extends Panel { public final static String ITEM_ID = item; public AccordionPanelItem() { super(ITEM_ID); } Now we have the id fixed... Then the user only need add what ever user wants when user extends basePanelItem.. So this solves that too... And the problem with attaching to wrong tags are solved too... There might be some overhead because each time you want todo something special you need to create a panel, but I think it's worth it.. PS, youve seen the web beans project right? http://wicketwebbeans.sourceforge.net/ regards Nino Nino Saturnino Martinez Vazquez Wael wrote: Sure there a dozens of ways todo this, mine is just one of them. Im starting a new thread since it'll be more exposed then. The idea is following: Parent: public class BasePage extends WebPage { protected final String LINK_LABEL_ID = linkText; protected final String LINK_ID = link; protected final String FOOTER_ID = item; protected final String HEADER_ID = item; protected ListWebMarkupContainer generalAccordionItem = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer footer = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer header = new ArrayListWebMarkupContainer(); private AccordionPanel accordionPanel; /** * Constructor that is invoked when page is invoked without a session. * * @param parameters *Page parameters */ public BasePage() { accordionPanel = new AccordionPanel(accordionMenu); add(accordionPanel); add(new ListView(footerContent, footer) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); add(new ListView(headerContent, header) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); } protected void addMenu(AccordionPanelItem accordionPanelItem) { accordionPanel.addMenu(accordionPanelItem); }; protected void addFooter(WebMarkupContainer webMarkupContainer) { footer.add(webMarkupContainer); }; protected void addHeader(WebMarkupContainer webMarkupContainer) { header.add(webMarkupContainer); }; Subs/Children then calls the methods... Problem with this technique is that you need to use the right markup id's.. To make sure they are always set, and giving full control to the child/sub on what to add, I'd suggest that you create a BasePanel which encapsules the id, and then required that instead of a markupcontainer, that way subs/child only need to have panels that extend the basepanel... But it depends on your needs, mine weren't that tricky.. regards Nino -- -Wicket for love -Jme for fun Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ways of doing markup Inheritance [WAS Re: Page title when using markup inheritance]
On 3/5/08, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: Answer below: James Carman Wrote: Couldn't you use a VelocityPanel to generate your markup and have it parse the markup after it's generated to avoid the whole need to use the right markup ids part? I was thinking about doing something like this for generating dynamic editor forms (a la Trails) for objects, since Wicket doesn't like you putting TextFields on spans (you must use an input tag). I was going to have a Velocity script that decides what type of tag to spit out based on the type of component in the list. What I found simple, which I perhaps did not explain clearly.. Where to only accept basePanels in forexample addMenu method, that way a base panel would look something like this: public class BasePanelItem extends Panel { public final static String ITEM_ID = item; public AccordionPanelItem() { super(ITEM_ID); } Now we have the id fixed... Then the user only need add what ever user wants when user extends basePanelItem.. So this solves that too... And the problem with attaching to wrong tags are solved too... There might be some overhead because each time you want todo something special you need to create a panel, but I think it's worth it.. PS, youve seen the web beans project right? http://wicketwebbeans.sourceforge.net/ Yes, I've seen WWB. But, I'm a roll your own kind of guy. Actually, I'm going through this experiment to help me learn Wicket. I was part of the Trails team and I was wondering how we'd do the same thing in Wicket. regards Nino Nino Saturnino Martinez Vazquez Wael wrote: Sure there a dozens of ways todo this, mine is just one of them. Im starting a new thread since it'll be more exposed then. The idea is following: Parent: public class BasePage extends WebPage { protected final String LINK_LABEL_ID = linkText; protected final String LINK_ID = link; protected final String FOOTER_ID = item; protected final String HEADER_ID = item; protected ListWebMarkupContainer generalAccordionItem = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer footer = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer header = new ArrayListWebMarkupContainer(); private AccordionPanel accordionPanel; /** * Constructor that is invoked when page is invoked without a session. * * @param parameters *Page parameters */ public BasePage() { accordionPanel = new AccordionPanel(accordionMenu); add(accordionPanel); add(new ListView(footerContent, footer) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); add(new ListView(headerContent, header) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); } protected void addMenu(AccordionPanelItem accordionPanelItem) { accordionPanel.addMenu(accordionPanelItem); }; protected void addFooter(WebMarkupContainer webMarkupContainer) { footer.add(webMarkupContainer); }; protected void addHeader(WebMarkupContainer webMarkupContainer) { header.add(webMarkupContainer); }; Subs/Children then calls the methods... Problem with this technique is that you need to use the right markup id's.. To make sure they are always set, and giving full control to the child/sub on what to add, I'd suggest that you create a BasePanel which encapsules the id, and then required that instead of a markupcontainer, that way subs/child only need to have panels that extend the basepanel... But it depends on your needs, mine weren't that tricky.. regards Nino -- -Wicket for love -Jme for fun Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ways of doing markup Inheritance [WAS Re: Page title when using markup inheritance]
James Carman wrote: On 3/5/08, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: Answer below: James Carman Wrote: Couldn't you use a VelocityPanel to generate your markup and have it parse the markup after it's generated to avoid the whole need to use the right markup ids part? I was thinking about doing something like this for generating dynamic editor forms (a la Trails) for objects, since Wicket doesn't like you putting TextFields on spans (you must use an input tag). I was going to have a Velocity script that decides what type of tag to spit out based on the type of component in the list. What I found simple, which I perhaps did not explain clearly.. Where to only accept basePanels in forexample addMenu method, that way a base panel would look something like this: public class BasePanelItem extends Panel { public final static String ITEM_ID = item; public AccordionPanelItem() { super(ITEM_ID); } Now we have the id fixed... Then the user only need add what ever user wants when user extends basePanelItem.. So this solves that too... And the problem with attaching to wrong tags are solved too... There might be some overhead because each time you want todo something special you need to create a panel, but I think it's worth it.. What did you think of this approach? PS, youve seen the web beans project right? http://wicketwebbeans.sourceforge.net/ Yes, I've seen WWB. But, I'm a roll your own kind of guy. Actually, I'm going through this experiment to help me learn Wicket. I was part of the Trails team and I was wondering how we'd do the same thing in Wicket. regards Nino Nino Saturnino Martinez Vazquez Wael wrote: Sure there a dozens of ways todo this, mine is just one of them. Im starting a new thread since it'll be more exposed then. The idea is following: Parent: public class BasePage extends WebPage { protected final String LINK_LABEL_ID = linkText; protected final String LINK_ID = link; protected final String FOOTER_ID = item; protected final String HEADER_ID = item; protected ListWebMarkupContainer generalAccordionItem = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer footer = new ArrayListWebMarkupContainer(); protected ListWebMarkupContainer header = new ArrayListWebMarkupContainer(); private AccordionPanel accordionPanel; /** * Constructor that is invoked when page is invoked without a session. * * @param parameters *Page parameters */ public BasePage() { accordionPanel = new AccordionPanel(accordionMenu); add(accordionPanel); add(new ListView(footerContent, footer) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); add(new ListView(headerContent, header) { @Override protected void populateItem(ListItem item) { WebMarkupContainer webMarkupContainer = (WebMarkupContainer) item .getModelObject(); item.add(webMarkupContainer); } }); } protected void addMenu(AccordionPanelItem accordionPanelItem) { accordionPanel.addMenu(accordionPanelItem); }; protected void addFooter(WebMarkupContainer webMarkupContainer) { footer.add(webMarkupContainer); }; protected void addHeader(WebMarkupContainer webMarkupContainer) { header.add(webMarkupContainer); }; Subs/Children then calls the methods... Problem with this technique is that you need to use the right markup id's.. To make sure they are always set, and giving full control to the child/sub on what to add, I'd suggest that you create a BasePanel which encapsules the id, and then required that instead of a markupcontainer, that way subs/child only need to have panels that extend the basepanel... But it depends on your needs, mine weren't that tricky.. regards Nino -- -Wicket for love -Jme for fun Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -Wicket for love -Jme for fun Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL