开发者

Placing an image in an object, sending the object over rpc and then using hibernate

开发者 https://www.devze.com 2023-01-28 11:12 出处:网络
I am using gwt rpc and hibernate on the back end. I have an object in which one of the field is an image. I have to place the imag开发者_JAVA技巧e in the object, send the file over rpc and saving it b

I am using gwt rpc and hibernate on the back end. I have an object in which one of the field is an image. I have to place the imag开发者_JAVA技巧e in the object, send the file over rpc and saving it back to database using hibernate.

Does anyone of you have an idea about this??


It can't be done exactly as described. In javascript, you can't capture the binary contents of a file into the javascript VM. You have to use file upload to send it to the server. Your flow needs to be something like:

  1. Capture non-binary fields (text) into the POJO. I.e. a form.
  2. Transfer the object using GWT RPC to the server.
  3. Upload image to server.
  4. Join the image into the POJO on the server.
  5. Save to database.

The image field needs to be annotated @GwtTransient to be transient in GWT, not transferred in the ajax requests, but still persisted by hibernate.

0

精彩评论

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