Re: Re2: file upload in nested form with CPM needs dummy model

2013-08-05 Thread Martin Grigorov
Hi,


On Mon, Aug 5, 2013 at 2:03 PM, Tom Eicher  wrote:

> Hello Martin & List,
>
>  Would it not be much more straightforward to just instantiate one of the
>>> existing models, like
>>> new FileUploadField("UploadFileField", new
>>> Model>()));
>>>
>>> or some Model.of() variant ?
>>>
>>>
>> You mean Wicket automatically to do this for you ?
>>
>> In current Wicket if a component has no model then its parent is asked.
>> If the parent's model
>> implements org.apache.wicket.model.**IComponentInheritedModel then Wicket
>> asks it for a model for the child. This is how CompoundPropertyModel
>> works.
>>
>> If there is no IComponentInheritedModel up in the hierarchy then the
>> component just has model == null.
>>
>> For your use case we can introduce Component#newDefaultModel() that can
>> return a sane default model per component. And this method should be
>> called
>> only when org.apache.wicket.Component#**initModel returns null.
>>
>> I don't like much such automatic/automagic behaviors. I prefer to see an
>> exception message telling me what I forgot to do. But some people may like
>> this solution.
>>
>
> No, that would be too much.
>
> How about making FileUpload Serializable ?
> Then I could just Model.of(new FileUpload()) couldn't I ?


It seems I cannot understand what is the issue you try to explain.

You can do: new FileUploadField("fileUpload", new ListModel())

Since HTML5  can support multiple files and that's why
FileUploadField works with a List.


>


>
> Cheers, Tom.
>
>
>
> --**--**-
> To unsubscribe, e-mail: 
> users-unsubscribe@wicket.**apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re2: file upload in nested form with CPM needs dummy model

2013-08-05 Thread Tom Eicher

Hello Martin & List,


Would it not be much more straightforward to just instantiate one of the
existing models, like
new FileUploadField("**UploadFileField", new Model>()));
or some Model.of() variant ?



You mean Wicket automatically to do this for you ?

In current Wicket if a component has no model then its parent is asked.
If the parent's model
implements org.apache.wicket.model.IComponentInheritedModel then Wicket
asks it for a model for the child. This is how CompoundPropertyModel works.

If there is no IComponentInheritedModel up in the hierarchy then the
component just has model == null.

For your use case we can introduce Component#newDefaultModel() that can
return a sane default model per component. And this method should be called
only when org.apache.wicket.Component#initModel returns null.

I don't like much such automatic/automagic behaviors. I prefer to see an
exception message telling me what I forgot to do. But some people may like
this solution.


No, that would be too much.

How about making FileUpload Serializable ?
Then I could just Model.of(new FileUpload()) couldn't I ?


Cheers, Tom.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org