I haven't tried with the latest CVS version of Seam. But i got it working with 
Seam-beta2 and Jboss-4.0.4-RC1. Here's what I did:

1. You need 2 Seam components. A "backing bean" required by Tomahawk and SLSB 
to deal with your JSF action:

1a. Backing Bean:


  | @Name("uploadBean")
  | public class UploadBackingBean {
  | 
  |     private UploadedFile file;
  |     
  |     public void setFile(UploadedFile file) {
  |         this.file = file;
  |     }
  | 
  |     @NotNull
  |     public UploadedFile getFile() {
  |         return this.file;
  |     }
  |     
  | }
  | 

1b. Action and its interface


  | @Stateless
  | @Name("upload")
  | @Interceptors(SeamInterceptor.class)
  | public class UploadAction implements Upload {
  | 
  |     private Logger logger;
  | 
  |     /**
  |      * O arquivo que foi enviado.
  |      */
  |     @In
  |     private UploadBackingBean uploadBean;
  | 
  |     @In
  |     private FacesContext facesContext;
  | 
  |     @PostConstruct
  |     public void init() {
  |         logger = Logger.getLogger(this.getClass());
  |         logger.debug("init()");
  |     }
  | 
  |     public String upload() {
  |         logger.debug("upload()");
  |         UploadedFile file = uploadBean.getFile();
  |         
  |         logger.debug("Abrindo o arquivo como DOM4J");
  | 
  |         logger.debug(file.getName());
  | 
  |         facesContext.addMessage(null, new FacesMessage("Nome do arquivo: "
  |                 + file.getName()));
  | 
  |         return "success";
  |     }
  | 
  | }
  | 


  | @Local
  | public interface Upload {
  | 
  |     public String upload();
  |     
  | }
  | 

2. You need to define a tomahawk.taglib.xml if you want to be able to access 
your tomahawk upload component via facelets. It shoud go in your .war WEB-INF


  | <?xml version="1.0"?>
  | <!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet 
Taglib 1.0//EN" "facelet-taglib_1_0.dtd">
  | <facelet-taglib>
  |     <!-- author: [EMAIL PROTECTED] -->
  |     <namespace>http://myfaces.apache.org/tomahawk</namespace>
  |     <tag>
  |         <tag-name>inputFileUpload</tag-name>
  |         <component>
  |             
<component-type>org.apache.myfaces.HtmlInputFileUpload</component-type>
  |         </component>
  |     </tag>
  | </facelet-taglib>
  | 

A full taglib definition is available here: 
http://wiki.apache.org/myfaces-data/attachments/Use_Facelets_with_Tomahawk/attachments/tomahawk.taglib.xml

3. Apart from the normal Seam stuff in your web.xml you need to reference 
whatever is that Tomahawk needs:


  |     <!-- My Faces Extensions Filter -->
  |     <filter>
  |         <filter-name>extensionsFilter</filter-name>
  |         
<filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
  |         <init-param>
  |             <param-name>uploadMaxFileSize</param-name>
  |             <param-value>100m</param-value>
  |                     <!-- 
  |             <description>Set the size limit for uploaded files.
  |                 Format: 10 - 10 bytes
  |                         10k - 10 KB
  |                         10m - 10 MB
  |                         1g - 1 GB
  |             </description>
  |              -->
  |         </init-param>
  |         <init-param>
  |             <param-name>uploadThresholdSize</param-name>
  |             <param-value>100k</param-value>
  |                     <!-- 
  |             <description>Set the threshold size - files
  |                     below this limit are stored in memory, files above
  |                     this limit are stored on disk.
  | 
  |                 Format: 10 - 10 bytes
  |                         10k - 10 KB
  |                         10m - 10 MB
  |                         1g - 1 GB
  |             </description>
  |              -->
  |         </init-param>
  |         <!--
  |         <init-param>
  |             <param-name>uploadRepositoryPath</param-name>
  |             <param-value>/temp</param-value>
  |             <description>Set the path where the intermediary files will be 
stored.
  |             </description>
  |         </init-param>
  |         -->
  |     </filter>
  | 
  |     <filter-mapping>
  |         <filter-name>extensionsFilter</filter-name>
  |         <url-pattern>*.seam</url-pattern>
  |     </filter-mapping>
  | 
  |     <!-- MyFaces Tomahawk Library -->
  | 
  |     <context-param>
  |         <param-name>facelets.LIBRARIES</param-name>
  |         <param-value>/WEB-INF/tomahawk.taglib.xml</param-value>
  |     </context-param>
  | 

4. The HTML would look something like this:


  | <h:form enctype="multipart/form-data">
  |     <t:inputFileUpload storage="file" value="#{uploadBean.file}"/>
  |         <h:commandButton value="Submit" action="#{upload.upload}"/>
  |         <h:messages/>
  | </h:form>
  | 

5. Finally I put the tomahawk.jar and the commons-file-upload.jar and 
common-io.jar in the .ear that packages the web application and the EJB's. Of 
course you need to add the class-path in the MANIFEST.MF of the .ear file.


  | Class-Path: jboss-seam.jar commons-fileupload-1.1.jar commons-io-1.2.jar 
tomahawk.jar
  | 

Hope it helps.
Regards.
Marcio Endo

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3937697#3937697

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3937697


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to