You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ned Collyer <ne...@gmail.com> on 2008/09/03 08:22:12 UTC

FileUpload - need to set a model to get updateModel working?

I have a form with a CompoundPropertyModel.  One of the fields inside this
model is a FileUpload.

Why do I need to pass a dummy model, (or the current model) through to the
FileUploadField - is this an oversight?

I cannot find details surrounding the private "hasExplicitModel" boolean in
FileUploadField.

Other fields - eg, TextField automatically use and update their parent CPM.

Rgds

Ned
-- 
View this message in context: http://www.nabble.com/FileUpload---need-to-set-a-model-to-get-updateModel-working--tp19283571p19283571.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: FileUpload - need to set a model to get updateModel working?

Posted by Igor Vaynberg <ig...@gmail.com>.
i removed the explicit model business from 1.4, there is nothing wrong
with always using a model, i think the whole thing was somewhat
legacy.

i cant do that in 1.3 because it will break existing apps.

-igor

On Wed, Sep 3, 2008 at 3:26 PM, Ned Collyer <ne...@gmail.com> wrote:
>
>
> class MyObj {
>    transient FileUpload fileUpload;
>    String description;
> }
>
>
> Form form = new Form("form", new CompoundPropertyModel(new MyObj));
> form.add(new TextField("description"));  <-- this works
> form.add(new FileUploadField("fileUpload"));   <-- this doesnt
> form.add(new FileUploadField("fileUpload"), getModel());   <-- this works
>
>
> form.add(new FileUploadField("fileUpload"), null);  <-- havent tried this -
> assume it may work.
>
> hasexcplicitmodel is private, so the only way to toggle it is by calling one
> of the methods on FileUpload.
>
>
> The method in FileUploadField
> @Override
> public void updateModel()
> {
>        // Only update the model if one was passed in
>        if (hasExplicitModel)
>        {
>                setModelObject(getFileUpload());
>        }
> }
>
> I'm using wicket 1.4-m1 at the moment.
>
>
>
> igor.vaynberg wrote:
>>
>> if you do not give it a model explicitly then it will try to stick the
>> inputstream into the cpm, thats how cpms work...
>>
>> if you set hasexcplicitmodel(false) then the model will not be
>> updated, instead you will have to call getfileupload() yourself.
>>
>> what exactly are you trying to do?
>>
>> -igor
>>
>> On Tue, Sep 2, 2008 at 11:22 PM, Ned Collyer <ne...@gmail.com>
>> wrote:
>>>
>>> I have a form with a CompoundPropertyModel.  One of the fields inside
>>> this
>>> model is a FileUpload.
>>>
>>> Why do I need to pass a dummy model, (or the current model) through to
>>> the
>>> FileUploadField - is this an oversight?
>>>
>>> I cannot find details surrounding the private "hasExplicitModel" boolean
>>> in
>>> FileUploadField.
>>>
>>> Other fields - eg, TextField automatically use and update their parent
>>> CPM.
>>>
>>> Rgds
>>>
>>> Ned
>>> --
>>> View this message in context:
>>> http://www.nabble.com/FileUpload---need-to-set-a-model-to-get-updateModel-working--tp19283571p19283571.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/FileUpload---need-to-set-a-model-to-get-updateModel-working--tp19283571p19299551.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: FileUpload - need to set a model to get updateModel working?

Posted by Ned Collyer <ne...@gmail.com>.

class MyObj {
    transient FileUpload fileUpload;
    String description;
}


Form form = new Form("form", new CompoundPropertyModel(new MyObj));
form.add(new TextField("description"));  <-- this works
form.add(new FileUploadField("fileUpload"));   <-- this doesnt
form.add(new FileUploadField("fileUpload"), getModel());   <-- this works


form.add(new FileUploadField("fileUpload"), null);  <-- havent tried this -
assume it may work.

hasexcplicitmodel is private, so the only way to toggle it is by calling one
of the methods on FileUpload.


The method in FileUploadField
@Override
public void updateModel()
{
	// Only update the model if one was passed in
	if (hasExplicitModel)
	{
		setModelObject(getFileUpload());
	}
}

I'm using wicket 1.4-m1 at the moment.



igor.vaynberg wrote:
> 
> if you do not give it a model explicitly then it will try to stick the
> inputstream into the cpm, thats how cpms work...
> 
> if you set hasexcplicitmodel(false) then the model will not be
> updated, instead you will have to call getfileupload() yourself.
> 
> what exactly are you trying to do?
> 
> -igor
> 
> On Tue, Sep 2, 2008 at 11:22 PM, Ned Collyer <ne...@gmail.com>
> wrote:
>>
>> I have a form with a CompoundPropertyModel.  One of the fields inside
>> this
>> model is a FileUpload.
>>
>> Why do I need to pass a dummy model, (or the current model) through to
>> the
>> FileUploadField - is this an oversight?
>>
>> I cannot find details surrounding the private "hasExplicitModel" boolean
>> in
>> FileUploadField.
>>
>> Other fields - eg, TextField automatically use and update their parent
>> CPM.
>>
>> Rgds
>>
>> Ned
>> --
>> View this message in context:
>> http://www.nabble.com/FileUpload---need-to-set-a-model-to-get-updateModel-working--tp19283571p19283571.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/FileUpload---need-to-set-a-model-to-get-updateModel-working--tp19283571p19299551.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: FileUpload - need to set a model to get updateModel working?

Posted by Igor Vaynberg <ig...@gmail.com>.
if you do not give it a model explicitly then it will try to stick the
inputstream into the cpm, thats how cpms work...

if you set hasexcplicitmodel(false) then the model will not be
updated, instead you will have to call getfileupload() yourself.

what exactly are you trying to do?

-igor

On Tue, Sep 2, 2008 at 11:22 PM, Ned Collyer <ne...@gmail.com> wrote:
>
> I have a form with a CompoundPropertyModel.  One of the fields inside this
> model is a FileUpload.
>
> Why do I need to pass a dummy model, (or the current model) through to the
> FileUploadField - is this an oversight?
>
> I cannot find details surrounding the private "hasExplicitModel" boolean in
> FileUploadField.
>
> Other fields - eg, TextField automatically use and update their parent CPM.
>
> Rgds
>
> Ned
> --
> View this message in context: http://www.nabble.com/FileUpload---need-to-set-a-model-to-get-updateModel-working--tp19283571p19283571.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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