[
https://issues.apache.org/jira/browse/WICKET-1108?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12539892
]
Brill Pappin commented on WICKET-1108:
--------------------------------------
Maybe I wasn't clear on what my problem with it was.
1) doing any extensive amount of work in a constructor is an anti-pattern AFAIK.
2) If the API is designed so that I am expected to build a complex component in
it's constructor then I should be able to override any of the constructors and
expect it to be called.
If you don't want to include a specialized method for initializing a component
(e.g. the way Servlet works) and expect the constructor to be the "primary"
means of building up the component, then the constructors should follow good
practice and all get called.
This is a common Java pattern. There should be only one place in the code where
properties are set from a constructor, all other constructors should pass on
their parameters, defaults if required, to the one constructor that actually
sets the properties.
If you don't code well, you have three immediate problems which as an agile
fan, I would cringe at:
1) You have duplicate code, no way around it.
2) you can never be certain which constructor is called by the API and any
given point. You may be able to get it to work, but a future change to the API
could break your code, and you might well not catch it with your own unit test
(you have some right?).
3) in order to support having two overridden constructors, I now am *forced* to
duplicate my own code (granted it could be one line, but its still duplication).
Now... fixing the constructor calls is not impossible but may require a bit of
thought (I don't believe thinking is a problem for the developers of Wicket as
they have clearly done a lot of it already) however I personally would prefer a
specific method call for initializing the component... at the very least so I
don't have to do all that work in the constructor, but it also has the benefit
of being *very* easy to implement with the current codebase.
Despite my preference for an init override, I think the correct thing to do
with or without it is to fix the constructor calls.
> Inherited Pages don't include components from super page.
> ---------------------------------------------------------
>
> Key: WICKET-1108
> URL: https://issues.apache.org/jira/browse/WICKET-1108
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Affects Versions: 1.3.0-beta3
> Reporter: Brill Pappin
> Assignee: Igor Vaynberg
> Fix For: 1.3.0-beta5
>
> Attachments: test-wicket-1108.zip
>
>
> I've got two pages:
> an abstract base page that has items included in all pages (BasePAge in this
> spike), and a concrete page (Index in this spike):
> - BasePage includes items like the title
> - Index only has content that applies to the index page.
> What I expected to happen was that the BasePage would include its components
> and the index page would include its one component.
> However when run, I get an error that not all the wicket tags have components.
> This was unexpected and counter intuitive to a java developer.
> Of course, being very new to Wicket, I may simply have done something wrong
> (which is why this is not marked as a bug).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.