Errors : Wicket RuntimeException “No get method defined for class–upload”

In a recent Wicket migration 1.3 to 1.6, my application was giving me trouble whenever used uploads an image.

Main exception

org.apache.wicket.WicketRuntimeException: No get method defined for class: class com.ptc.fusion.web.pages.admin.ManageCustomizationPage expression: upload
     at org.apache.wicket.core.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:499)
     at org.apache.wicket.core.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:341)
     at org.apache.wicket.core.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:244)
     at org.apache.wicket.core.util.lang.PropertyResolver.getValue(PropertyResolver.java:97)
     at org.apache.wicket.model.AbstractPropertyModel.getObject(AbstractPropertyModel.java:86)
     at org.apache.wicket.Component.getDefaultModelObject(Component.java:1616)

 

I spent several hours on this issue, and once again, I figured it out 20 minutes after I posted to SO about it. The fix is to turn the upload field declaration into one that provides a model, like this:

fuf = new FileUploadField("DocumentUpload", new Model<FileUpload>());

EDIT: It turns out this was related to 1.3 -> 1.4 migration. Per the migration guide,

FileUploadField – now requires model

The FileUploadField now REQUIRES a model. This means that if you previously used the ID-only >constructor (i.e. new FileUploadField(“myFileField”)), you will need to change it to include >a model (i.e. new FileUploadField(“myFileField”, new Model())).

 

Previously constructor was like :

final FileUploadField uploadField = new FileUploadField(“upload”);

 

The problem got resolved just by using the new constructor mentioned below :

        IModel uploadModel = new Model<FileUpload>();

    public IModel getUploadModel() {
        return uploadModel;
    }

    public void setUploadModel(IModel uploadModel) {
        this.uploadModel = uploadModel;
    }
   
    final FileUploadField uploadField = new FileUploadField(“upload”, uploadModel);

 

I found solution here :
http://stackoverflow.com/questions/1792310/problematic-wicket-runtimeexception

One thought on “Errors : Wicket RuntimeException “No get method defined for class–upload”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s