On 09 Mar 2011, at 19:15, Gary Thomas wrote:
> 
> On 3/9/11 2:18 AM, Maarten Billemont wrote:
>> 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
>>    })
>> })
>> 
> 
> Thanks for the reply -
> Yes it would be as simple as that - but again, not quite as elegant (imho).

I actually think that it's more elegant to be explicit about the fact that your 
components are constructed lazily during initialization rather than object 
construction.

Given the recent feedback, cede that forcing onInitialize on everybody may not 
be necessary, although I am still very convinced that it is the right thing to 
do design-wise.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to