开发者

Model Object in GWT with Blob as an Attribute

开发者 https://www.devze.com 2023-03-09 01:22 出处:网络
I have a GWT application based on the MVP+App Controller Design. I also have a MySQL database as the back-end persistence storage.

I have a GWT application based on the MVP+App Controller Design. I also have a MySQL database as the back-end persistence storage.

In my shared folder I have a *Feed * model object. Feed objects are to be fetched as an ArrayList by my application(Imagining it to be a twitter like Application)

Each Feed Model object in my Application can have an attached document with it. However it is optional. If the user requests for the attachment by clicking I would want to server the Attached document.

I had in mind of keeping a Blob refrence as one of the Attribute of my Feed object. However GWT does not allow using Blob class for Client side code.(shared folder is used by client as well as server side code) Getting the attached documents for all the Feeds and passing around a byte of Array will take a lot of ban开发者_运维知识库dwidth. :|

What can be a possible way around?


You can't use a Blob on client side. And as you said you don't want to pass such large data in your model object anyway.

What you want to do is only have a reference to a uniqueId for the Blob in your Feed object. When the user tries to access the document, send an http request with that id as a parameter to a Servlet on your server side. This servlet will use the id to get the Blob from the database and return the file as an attachment (see here for example to set headers)

0

精彩评论

暂无评论...
验证码 换一张
取 消