-
1. Re: how to store image to database
danielc.roth Oct 21, 2008 3:54 PM (in response to swathis)Ask at the Hibernate forum.
-
2. Re: how to store image to database
swathis Oct 22, 2008 7:46 AM (in response to swathis)I want it to be done in seam framework, as seam framework internally uses hibernate, am asking how to do using hibernate entity.....
-
3. Re: how to store image to database
danielc.roth Oct 22, 2008 9:41 AM (in response to swathis)Yes, Seam supports Hibernate (and other JPA providers). You want to save a byte[] using a particlular JPA provider to a particular database. It's just an entity that should be persisted to a database, which has nothing to do with Seam.
I suggest, again, you ask at the Hibernate forum.
-
4. Re: how to store image to database
shane.bryzak Oct 22, 2008 11:06 AM (in response to swathis)Look at the Seamspace example, in particular RegisterAction.uploadPicture().
-
5. Re: how to store image to database
danielc.roth Oct 22, 2008 10:17 PM (in response to swathis)http://www.seamframework.org/Community/HowToInsertAnImageUsingHibernateEntityInSeam
You got an answer here I guess :)
-
6. Re: how to store image to database
swathis Oct 23, 2008 7:37 AM (in response to swathis)Yeah Daniel I got it... it worked perfectly.. but again I got one small problem.... I hope u can help me out...
Actually it uploads all types of files... but I want only images like png,gif,bmp,jpg to be uploaded... I have tried it by making small changes in xhtml code like
xhtml:
------
<s:fileUpload id="file"
data="#{attachmentHome.instance.data}" accept="jpg,png,bmp,gif"
contentType="#{attachmentHome.instance.contentType}"
fileName="#{attachmentHome.instance.name}"
fileSize="#{attachmentHome.instance.size}"/> -
7. Re: how to store image to database
swathis Oct 23, 2008 8:09 AM (in response to swathis)Yeah I have tried it also
<s:fileUpload id="file" data="#{attachmentHome.instance.data}" accept="image/jpg,image/png,image/bmp,image/gif" contentType="#{attachmentHome.instance.contentType}" fileName="#{attachmentHome.instance.name}" fileSize="#{attachmentHome.instance.size}" />
its not working...... can u help me
-
8. Re: how to store image to database
swathis Oct 23, 2008 8:45 AM (in response to swathis)I have written persist method in action class (i.e in attachmentHome.java) so now I can restrict others file from uploading...
attachmentHome.java
@Override public String persist(){ if(!(attachmentcontentType == "jpg,png,gif,bmp") && attachmentcontentType != null){ facesMessages.add("Content type is not Image"); } return "/attachment.xhtml"; }
it worked....