You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tom Eicher <ro...@teicher.net> on 2013/08/05 14:03:05 UTC

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

Hello Martin & List,

>> Would it not be much more straightforward to just instantiate one of the
>> existing models, like
>> new FileUploadField("**UploadFileField", new Model<List<FileUpload>>()));
>> 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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


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

Posted by Martin Grigorov <mg...@apache.org>.
Hi,


On Mon, Aug 5, 2013 at 2:03 PM, Tom Eicher <ro...@teicher.net> 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<List<FileUpload>>()));
>>>
>>> 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<FileUpload>())

Since HTML5 <input type="file"> can support multiple files and that's why
FileUploadField works with a List.


>


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