0

I created component BannerUpload which extends core Upload component. I have property UploadedFile inside this component. But I don't see any way to pass it to the value parameter of parent class. I've tried to define method UploadedFile defaultValue() but it didn't help as it's meant for container...

public class BannerUpload extends Upload {
    @Property
    private UploadedFile bannerUpload;

    public void doUpload() {
        // ... upload file ....
    }
}
4

1 回答 1

0

您可以使用 mixin 和 @BindParameter 而不是扩展上传组件。如果你设置了一个用@BindParameter 标记的字段,这将被推送到组件。我不确定这个注释是否也适用于子类?

例如

<t:upload t:mixins="mymixin" />

public class MyMixin {
    @BindParameter
    private UploadedFile value;

    @SetupRender
    void initializeValue() {
        // set value here
    }
}

http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/BindParameter.html

于 2013-09-12T15:21:01.257 回答