0 Replies Latest reply on Feb 14, 2011 5:13 AM by sumaprakash

    upload of text file in to rich:fileupload ....

    sumaprakash
      Hi all,
      iam facing a problm in uploading a text file into rich: fileupload >>>>>i am able to store JPG and PNG formats but text is not getting uploaded ......



      my jsp code :

      <h:panelGroup id="fileUploadPanel">
                                         <s:decorate id="filedec">
                                              <table cellspacing="0" cellpadding="0">
                                                   <tr><td>
                                                        <rich:fileUpload id="upload"
                                                             fileUploadListener="#{employeeSetup.fileListener}"
                                                             immediateUpload="true"
                                                             maxFilesQuantity="1" 
                                                             listHeight="80px"  acceptedTypes="jpg, png, bmp, txt">                                                       
                                                        </rich:fileUpload>
                                                   </td></tr>
                                                   <tr><td>
                                                        <s:message errorClass="error"/>
                                                   </td></tr>
                                              </table>



      my action for it >>>>

           public void confirmAttachment() {

              Resource oldResource = new Resource();
                if (this.employeeAttachment.getAttachment() != null) {
                     oldResource = this.employeeAttachment.getAttachment();
                }
                if (oldResource != null) {
                     if (this.resource == null || this.resource.getId() != oldResource.getId()) {
                          em.remove(oldResource);
                     }
                }

                if (this.resource != null) {
                     em.persist(this.resource);
                }

                if (selectedInstance instanceof IcBusiness) {
                     this.employeeAttachment.setInstance(((IcBusiness) selectedInstance)
                               .getMmsInstance());
                } else if (selectedInstance instanceof Provider) {
                     this.employeeAttachment.setInstance(((Provider) selectedInstance)
                               .getAffiliation().getMmsInstance());
                }

                employeeAttachment.setAttachment(attachment);
           
               employeeAttachment.setDescription(employeeAttachment.getDescription());
               System.out.println("*****************************"+employeeAttachment.getDescription());
               System.out.println("*****************************"+employeeAttachment.getId());
                em.persist(employeeAttachment);
                em.flush();
           }



      plz guide me in this if u have any ideas to share...