On 09 Mar 2011, at 10:44, Gary Thomas wrote: > > While a minority use-case, this allows for very elegant Wicket code when > using Scala: > > add(new Form[Person]("form", model) { > add (new TextArea[String]("text", (getModel -> "text")) { > override def isVisible: Boolean = false > }) > })
Style is great when there are no issues involved with doing it. If it turns out that adding components from the constructor is indeed dangerous when combined with other components (eg. in libraries) that use onInitialize then we should reconsider. I think the best solution so far would be to not invoke onInitialize when adding components to a page, that would allow the constructor to be used still if the developer really wants to. With regards to your Scala code, while I don't know any Scala whatsoever, wouldn't it be just as easy to do something like this: add(new Form[Person]("form", model) { override def onInitialize: add (new TextArea[String]("text", (getModel -> "text")) { override def isVisible: Boolean = false }) }) Which would give you the added lazy component construction bonus that onInitialize provides, as well as your elegance. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org