Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7529627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:42:46+00:00 2026-05-30T04:42:46+00:00

I am developing a web app on JBOSS AS 7 using Richaces 4, SEAM

  • 0

I am developing a web app on JBOSS AS 7 using Richaces 4, SEAM and JPA. I can not get rich:fileUpload working. I have no idea how to make it. When uploading image through rich:fileUpload, I need it to be inserted into the database. What I did right now:

  1. I have an .xhtml page where there is a form for Uploading files (used one from Richfaces demo);
  2. Created an entity bean UploadedImage.java (with @Lob annotation for image column);
  3. DAO class to persist uploadedimage using entitymanager;
  4. And UploadBean.java for view to connect it with EJB project;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:42:48+00:00Added an answer on May 30, 2026 at 4:42 am

    If anyone will have the same issue, here is how to get it working:

    Upload.xhtml (contains form for image upload):

    <rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"
                            stopButtonClass="file-upload-stop-button"
                            addButtonClass="file-upload-button" listHeight="0" listWidth="0"
                            id="upload" acceptedTypes="jpg, gif, png, bmp" allowFlush="true" maxFileQuantity="10">
                            <a4j:ajax event="uploadcomplete" execute="@none"
                                render="info, imgs" />
                        </rich:fileUpload>
    

    FileUploadBean.java (delivering data to ejb class):

    @Named()
    @RequestScoped
    public class FileUploadBean implements Serializable {
    
        private static final long serialVersionUID = 1L;
    
    
        @Inject
        private CMSDao cms;
    
        private Integer pid;
        private String name;
        private String aname;
        private byte[] data;
    
    
        public FileUploadBean() {}
        private ArrayList<UploadedImage> files = new ArrayList<UploadedImage>();
        private List<UploadedImage> filess;
    
        public void listener(FileUploadEvent event) throws Exception {
                UploadedFile item = event.getUploadedFile();
                UploadedImage file = new UploadedImage();
                file.setName(item.getName());
                file.setData(item.getData());
                files.add(file);
                cms.insertImg(file);
    
            }
        //getters and setters
    

    EJB class:

      public void insertImg(UploadedImage img)  {
                em.persist(img);
                em.flush();
            }
    

    UploadedImage.java (entity bean):

    @Entity
    @Table(name="photo")
    public class UploadedImage implements Serializable {
        private static final long serialVersionUID = -8192553629588066292L;
        @Id
        @GeneratedValue
        @Column(name="pid")
        private Integer pid;
        @Column(name="name")
        private String name;
        @Column(name="aid")
        private String aname;
        @Lob
        @Column(name="data")
        @Basic(fetch = FetchType.LAZY)
        private byte[] data;
    // getters and setters
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java web app that I'm developing, using JBoss Seam as the
I have been developing my web-app using JPA 2.0 implementation EclipseLink 2.2.0. I finally
I am developing a web app using servlets and jsps. I have a question
I am developing a java webapp, using jsp/jquery/ejb/jboss. I have a web-form that enables
I am developing web app using asp.net. I have plenty of javascript files which
I am developing a web app. using struts2 and jboss url rewrite valve as
I'm developing an web app using asp.net mvc. I have a List in Cache
I am developing web app using Scala and Lift framework. I have record in
I'm developing web app that user can save his/her work to server. The data
I'm developing a web app and currently using sql server 2008 for it. But,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.