1 2 Previous Next 22 Replies Latest reply on Mar 17, 2010 11:06 AM by hakanm Go to original post
      • 15. Re: rich:FileUpload @ Seam
        javicho

        hi,


        ive got the same problem  dataa null  at uploadlistener method.
        to solved it i just modify my web xml  following this  :


        http://www.jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/faq/faq.html


        and see rich:fileUpload with Seam


        i hope it helps.

        • 16. Re: rich:FileUpload @ Seam
          infinity2heaven

          I've tried everything but item is null in sfsb


          web.xml


          <filter>
                  <filter-name>Seam Filter</filter-name>
                  <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
                  <init-param>
                          <param-name>createTempFiles</param-name>
                          <param-value>false</param-value>
                  </init-param>
                  <init-param>
                          <param-name>maxRequestSize</param-name>
                          <param-value>200000</param-value>
                  </init-param>
          </filter>



          facelets



          <rich:fileUpload id="uploadBox" addControlLabel="Add file..."  styleClass="attachDocsEnabled"
                  stopEntryControlLabel="Stop upload" uploadControlLabel="Upload file" 
                  fileUploadListener="#{attachmentTab.listener}" 
                  maxFilesQuantity="1" listHeight="65" listWidth="610" immediateUpload="true">
                  <a4j:support event="onuploadcomplete" reRender="attachmentsList"/>
                   <f:facet name="label">
                           <h:outputText value="{_KB}KB from {MB}MB uploaded --- {mm}:{ss}" />
                   </f:facet>
          </rich:fileUpload>



          sfsb



          public void listener(UploadEvent event) throws IOException {
                  UploadItem item = event.getUploadItem();
                  byte[] data = item.getData();
                                                                                                       
                  Attachment attachment = new Attachment(); // null pointer! item is null
                  attachment.setAttachment(data);
                  deal.addAttachment(attachment);
          }



          PL suggest!

          • 17. Re: rich:FileUpload @ Seam
            gregtk

            All problems with that component keeps in that code



            UploadItem item = event.getUploadItem();
            byte[] data = item.getData();




            Don't use method getData()!!! Just try get item.getFile() and than transform it to ByteArray.

            • 18. Re: rich:FileUpload @ Seam
              trouby

              Hey,


              Let me clarify this for you,



              When the filter parameter


              createTempFiles is set to 'true' that means the component saves the file as a temporary file, so the file would be accessible through


              UploadItem.getFile() , UploadItem.isTempFile() set to true


              when the filter parameter is set to false the data would be available through UploadItem.getData().




              Do not forget that you have to set this parameter as a seam parameter which will set the Ajax4Jsf Filer when seam starts up,


              (Check this link: http://www.jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/faq/faq.html)





              Regards,



              Asaf.

              • 19. Re: rich:FileUpload @ Seam
                bayrak

                Heyyy guys,
                I av som trouble with rich:fileUpload and seam configuration. I have tried many ways to point the debugger to the listener in action bean but i couldnt manage.
                I am using facelets 1.1.14 and richfaces 3.3.0.GA and seam 2.1.1GA.


                My codes are shown below. I need ur suggestions...



                components.xml

                <component class="org.jboss.seam.web.MultipartFilter">
                       <property name="createTempFiles">true</property>
                       <property name="maxRequestSize">200000</property>
                </component>
                <web:multipart-filter create-temp-files="true" max-request-size="1000000" url-pattern="*.seam"/>
                



                web.xml
                <filter>
                     <filter-name>Seam Multipart Filter</filter-name>
                     <filter-class>org.jboss.seam.web.MultipartFilter</filter-class>
                     <init-param>
                          <param-name>createTempFiles</param-name>
                          <param-value>true</param-value>
                     </init-param>
                     <init-param>
                          <param-name>maxRequestSize</param-name>
                          <param-value>200000</param-value>
                     </init-param>
                </filter>
                <filter-mapping>
                     <filter-name>Seam Multipart Filter</filter-name>
                     <url-pattern>/*</url-pattern>
                </filter-mapping>
                





                my xhtml

                <h:form enctype="multipart/form-data">
                <rich:fileUpload fileUploadListener="#{fileUploadHome.listener}" maxFilesQuantity="1" addControlLabel="Ekle" progressLabel="yükleniyor..."
                uploadControlLabel="Yükle" clearControlLabel="Sil" stopControlLabel="Durdur" stopEntryControlLabel="İşlemi Durdur!"      clearAllControlLabel="Tümünü Sil" cancelEntryControlLabel="İşlemi İptal Et!" doneLabel="İşlem Tamamlandı." id="upload"     acceptedTypes="txt" listHeight="65" listWidth="610" >
                <a4j:support event="onupload" reRender="info" />
                <f:facet name="label">
                     <h:outputText value="{_KB}KB from {_KB}KB yüklendi --{mm}:{ss}" />
                </f:facet>
                </rich:fileUpload>
                </h:form>
                




                my bean
                //No Annotation used
                public class FileUpload{
                
                     private Long Id;
                     private String fileName;
                     private String fileType;
                     private Integer length;
                     private byte[] data;




                my session bean
                @Name("fileUploadHome")
                public class FileUploadHome extends EntityHome<FileUpload> {
                
                     @RequestParameter
                     Long fileUploadId;
                
                     @Override
                     public Object getId() {
                          if (fileUploadId == null) {
                               return super.getId();
                          } else {
                               return fileUploadId;
                          }
                     }
                
                
                     private ArrayList<FileUpload> files = new ArrayList<FileUpload>();
                     private int uploadsAvailable = 5;
                     private boolean autoUpload = false;
                     private boolean useFlash = false;
                
                     public void listener(UploadEvent event) throws Exception {
                          UploadItem uploadItem = event.getUploadItem();
                          uploadItem.getData();
                
                          java.io.File file = uploadItem.getFile();
                          getInstance().setLength(uploadItem.getFileSize());
                          int extDot = uploadItem.getFileName().lastIndexOf('.');
                          String fileName = uploadItem.getFileName().substring(0, extDot);
                          getInstance().setFileName(fileName);
                
                          FileUpload fileUpload = new FileUpload();
                          fileUpload.setLength(uploadItem.getData().length);
                          fileUpload.setFileName(uploadItem.getFileName());
                          fileUpload.setData(uploadItem.getData());
                          files.add(fileUpload);
                          uploadsAvailable--;
                     }
                
                }



                • 20. Re: rich:FileUpload @ Seam
                  bayrak

                  any suggestions?

                  • 21. Re: rich:FileUpload @ Seam
                    cosmo

                    Hello Ismail,
                    can you clarify if you are having problems using your debbuging functions within your IDE or if the action method is not being called or if it is being called but you get an exception or a faces message?

                    • 22. Re: rich:FileUpload @ Seam
                      hakanm

                      hello,
                      I have the same problem as ismail have and the action method is not called in my case. I have seam 2.2.1 and richfaces 3.x. i have a seam-gen generated project. I have been looking for a solution. some wrote that it is about multipart filter and etc .
                      any suggestions. I can send the code if needed.


                      thanks

                      1 2 Previous Next