This issue has come up many, many times before:

http://www.mail-archive.com/users@wicket.apache.org/msg06381.html
http://www.mail-archive.com/wicket-u...@lists.sourceforge.net/msg26247.h
tml

Unfortunately some people try to convince the group that proposals like
the one you have presented here are not in line with Java's 'single
inheritance' model and therefore must be 'multiple inheritance' but they
are clearly not understanding the issue properly. 

What you are suggesting here is not 'the horror of multiple
inheritance'. 

It is simply single inheritance with 'multiple overridable markup
sections' and therefore would IMHO be an excellent enhancement to
Wicket. Stefan and I were discussing multiple options more than a year
ago and Stefan even went to the effort of creating a Wicket patch that
implemented support for overriding multiple sections but I'm pretty sure
it hasn't yet been added to SVN.

Stefan raised a feature request for this in JIRA:

https://issues.apache.org/jira/browse/WICKET-1134

The only thing extra that we discussed that you have not included in
your sample is that when we move from ONE overridable markup section to
MULTIPLE overridable sections (but still only a single super
class/markup!) we need to introduce and a way of identifying each
section (which obviously isn't required when you limit the number of
overridable sections to 1.

The great thing about identifying which section you are overriding is
that you can pick and choose which sections you override and which you
just 'default' to the markup of the super class/markup file.

I'm actually thinking that using specific <wicket:extend> and
<wicket:child> is a big hinderance to chaining in a hierarchy because
you have a different tag depending on whether you are providing a
'markup section' to be overridden or whether you are overriding a
'markup section'. This gets awkward and clumsy when it comes to flexible
'chaining' down an inheritance hierarchy and Java has no such
equivalent. We could probably have a single tag to be used consistently
in super or subclass to allow very simple syntax that supports fluid
inheritance down a markup hierarchy:

<wicket:namedsection id="header"> (or whatever) 

Overriding is then optional: absence of a named section in a subclass
markup simply means that the markup from the closest superclass markup
should be used.

I really hope this gets implemented soon. The 'workaround' that is often
suggested is a 'component based' workaround rather than a truly object
oriented approach that allows multiple sections to be overridden. As a
hard line OOer that doesn't quite cut it.

I have even gone to the extent of creating a special markup preparser
that lets me write markup with multiple overridable sections which are
then compiled to 'flattened' markup for Wicket to process at run time.
It works extremely well and satisfies my needs but it would be nicer if
it was supported natively in Wicket.

>-----Original Message-----
>From: Arjun Dhar [mailto:dhar...@yahoo.com]
>Sent: Monday, 5 July 2010 3:40 PM
>To: users@wicket.apache.org
>Subject: Single inheritence in parts
>
>
>Hi,
> all the examples etc suggest that Single inheritence is possible but I
>cant
>break it up. The break up is essential when you want to merge common
parts
>of your MARKUP with multiple specific parts of the Child page.
>
>Example:
>
>
><HTML>
><HEAD><title>BASE TEMPLATE / PARENT PAGE</title></HEAD>
>
><BODY>
>       <wicket:child />
>       <br />
>       <h2>Some other Html common</h2>
>       <wicket:child />
></BODY>
></HTML>
>
>
>-------------------------------------------
>
><HTML>
><HEAD><title>CHILD PAGE 1</title></HEAD>
>
><BODY>
>       <wicket:extend>
>                    Part 1 specific to Child Page
>        </wicket:extend>
>        Any HTML here can be ignored as conceptually anyway what
appears in
><extend> is what should be rendered from a child page.
>       <wicket:extend>
>                    Part 2 Specific to Child Page (will appear after
common
>HTML in parent page)
>        </wicket:extend>
></BODY>
></HTML>
>
>
>I tried this, only the first part renders. I'm wondering if we can add
such
>capability. Conceptually I don't see why not. If already possible do
let me
>know or consider as a feature request?!
>
>-Thanks Arjun
>--
>View this message in context: http://apache-
>wicket.1842946.n4.nabble.com/Single-inheritence-in-parts-
>tp2278064p2278064.html
>Sent from the Wicket - User 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

Reply via email to