[jboss-user] [JBoss Seam] - s:fileUpload woes

chrismalan do-not-reply at jboss.com
Wed Jul 18 02:09:53 EDT 2007


s:fileUpload doesn't work for me.  Here is what I have: Seam 1.2.1.GA, JBoss-4.2.0.  I use xhtml, not jsp's.

In the ear I have jboss-seam.jar and in WEB-INF/lib jboss-seam-ui.jar, jboss-seam-debug.jar and jsf-facelets.jar.

This is what is in web.xml:


  | <listener>
  |   <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
  | </listener>
  | 
  | <filter>
  |   <filter-name>Seam Filter</filter-name>
  |   <filter-class>org.jboss.seam.web.SeamFilter</filter-class>
  | </filter>
  | 
  | <filter-mapping>
  |  <filter-name>Seam Filter</filter-name>
  |  <url-pattern>/*</url-pattern>
  | </filter-mapping>
  | 

This is the relevant part of the xhtml file:

  | <h:form enctype="multipart/formdata">
  |   <fieldset>
  |     <legend>Add an Image to <h:outputText value="#{hotelSessionBean.hotel.name}" /></legend>
  |        <div>
  | 	  <h:outputLabel for="hotelimage">Image File to Load</h:outputLabel><br />
  | 	   <s:fileUpload id="hotelimage" data="#{hotelSessionBean.imageData}" contentType="#{hotelSessionBean.contentType}" fileName="#{hotelSessionBean.filename}" />
  | 	</div>
  | 	<div class="buttonBox">
  | 	  <h:commandButton action="#{hotelSessionBean.addImage()}" value="Add an Image" class="button" />
  | 	 </div>
  |   </fieldset>
  | </h:form>
  | 

This is the relevant part of hotelSessionBean:

  | @Stateful
  | @Scope(ScopeType.SESSION)
  | @Name("hotelSessionBean")
  | public class HotelSessionBean implements HotelSession {
  | 
  | 	@In 
  | 	Identity identity;
  | 	
  | 	@PersistenceContext
  | 	EntityManager em;
  | 	
  | 	private Hotel hotel;
  | 	private String contentType, filename, description;
  | 	private byte[] imageData;
  | 

When I test in hotelSessionBean.addImage() to see if the values (contentType, filename, imageData) arrived in the hotelSessionBean after clicking the Add an Image button, all those values are null.

When these values return null, the method returns with an error message I created.  So, no exceptions are thrown.  Before I tested the exeptions stated that one could not persist an Image with null values where the database stipulatd non-null values.

On logging in and going to the page from where to upload the image, I get this:

  | INFO  [Lifecycle] starting up: org.jboss.seam.security.identity
  | ERROR [STDERR] 18/07/2007 14:38:08 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
  | INFO: Added Library from: jar:file:/C:/JBoss/jboss-4.2.0.GA/server/default/tmp/deploy/tmp50450bookings.ear-contents/bookings-exp.war/WEB-INF/lib/jboss-seam-ui.jar!/META-INF/seam-ui.taglib.xml
  | ERROR [STDERR] 18/07/2007 14:38:08 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
  | INFO: Added Library from: jar:file:/C:/JBoss/jboss-4.2.0.GA/server/default/tmp/deploy/tmp50450bookings.ear-contents/bookings-exp.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-core.taglib.xml
  | ERROR [STDERR] 18/07/2007 14:38:08 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
  | INFO: Added Library from: jar:file:/C:/JBoss/jboss-4.2.0.GA/server/default/tmp/deploy/tmp50450bookings.ear-contents/bookings-exp.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-html.taglib.xml
  | ERROR [STDERR] 18/07/2007 14:38:08 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
  | INFO: Added Library from: jar:file:/C:/JBoss/jboss-4.2.0.GA/server/default/tmp/deploy/tmp50450bookings.ear-contents/bookings-exp.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jstl-fn.taglib.xml
  | ERROR [STDERR] 18/07/2007 14:38:08 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
  | INFO: Added Library from: jar:file:/C:/JBoss/jboss-4.2.0.GA/server/default/tmp/deploy/tmp50450bookings.ear-contents/bookings-exp.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jstl-core.taglib.xml
  | ERROR [STDERR] 18/07/2007 14:38:08 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
  | INFO: Added Library from: jar:file:/C:/JBoss/jboss-4.2.0.GA/server/default/tmp/deploy/tmp50450bookings.ear-contents/bookings-exp.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jsf-ui.taglib.xml
  | ***                      logging in up to here
  | INFO  [STDOUT] Hibernate: select principal0_.username as username7_, principal0_.name as name7_, principal0_.password as password7_, principal0_.hotel_hotelID as hotel7_7_, principal0_.email as email7_, principal0_.surname as surname7_, principal0_.created as created7_ from Principal principal0_ where principal0_.username=? and principal0_.password=?
  | INFO  [STDOUT] Hibernate: select hotel0_.hotelID as hotelID5_1_, hotel0_.name as name5_1_, hotel0_.state as state5_1_, hotel0_.country as country5_1_, hotel0_.description as descript4_5_1_, hotel0_.city as city5_1_, hotel0_.stars as stars5_1_, hotel0_.street as street5_1_, hotel0_.suburb as suburb5_1_, country1_.ID as ID2_0_, country1_.country as country2_0_ from Hotel hotel0_ inner join Country country1_ on hotel0_.country=country1_.ID where hotel0_.hotelID=?
  | INFO  [STDOUT] Hibernate: select principalr0_.ID as ID8_, principalr0_.principal as principal8_, principalr0_.user_role as user3_8_ from PrincipalRole principalr0_ where principalr0_.principal=?
  | INFO  [STDOUT] Hibernate: select role0_.name as name9_0_, role0_.description as descript2_9_0_ from Role role0_ where role0_.name=?
  | INFO  [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
  | 

Note that the page find the right hotel for the logged in user to upload the image to the right hotel.

Where is my mistake?

Thanks,


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

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



More information about the jboss-user mailing list