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 List<WebMarkupContainer> generalAccordionItem = new
> ArrayList<WebMarkupContainer>();
>
> protected List<WebMarkupContainer> footer = new
> ArrayList<WebMarkupContainer>();
>
> protected List<WebMarkupContainer> header = new
> ArrayList<WebMarkupContainer>();
>
> 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>
> >>>> <title>hard 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]
> >>>
> >>>
> >>>
> >> --
> >> -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]
> >>
> >>
> >>
> >>
> >
> >
>
> --
> -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]