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

青春壹個敷衍的年華 提交于 2019-12-12 03:41:19

问题


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 image 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??


回答1:


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.



来源:https://stackoverflow.com/questions/4301070/placing-an-image-in-an-object-sending-the-object-over-rpc-and-then-using-hibern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!