You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Kennedy <jg...@mindspring.com> on 2004/06/24 22:35:40 UTC

Trouble rendering a dynamic form (index=true) with html-el:file

I'm trying to upload a set of files using an indexed multipart form.

Here's the JSP code:

	<html-el:form action="/owner/saveimages.exe" method="post"
enctype="multipart/form-data">

		<logic-el:iterate id="imageFiles"
collection="${imageUploadForm.map.imageFiles}" >

		<html-el:file size="30" name="imageFiles" property="file"
indexed="true"
			accept="jpg,jpeg,gif" style="{font-family:
Arial;font-size: 11px;}" />
			</td>
        </logic-el:iterate>

	<br>
	<html-el:submit value="Upload All Images"/>
	</html-el:form>



Here's the Struts config:

		<form-bean name="imageUploadForm"
type="org.apache.struts.validator.DynaValidatorForm">
			<form-property name="imageFiles"
type="com.je.common.UploadHelper[]"/>			
		</form-bean>



Here's UploadHelper class:

public class UploadHelper implements Serializable
{
	
	private String id = null;
	private String description = null;
	private String label = null;
	private FormFile file = null;
	
	.....
Getters and setters....

}


I get a useless error from Tomcat (I think it's a ClassCastException):

2004-06-24 16:19:56,971 ERROR [org.jboss.web.lbstpa08.Engine] ----- Root
Cause -----
javax.servlet.ServletException: org/apache/struts/upload/FormFile
        at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:531)
        at
org.apache.jsp.tmpl_owner2_jsp._jspService(tmpl_owner2_jsp.java:256)
        at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
10)
        at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)


Idea's anyone?  This indexed stuff is always very tricky.

Thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Trouble rendering a dynamic form (index=true) with html-el:file

Posted by Jim Kennedy <jg...@mindspring.com>.
In case anyone is interested, which it looks like you are not :(

I did resolve my issue.  Changing the scope from request to session made all
the dif. Object type is correct which is FormFile.

It's actually pretty cool the way this works, but a pain to troubleshoot and
setup.

L8r

-----Original Message-----
From: Jim Kennedy [mailto:jgkennedy@mindspring.com] 
Sent: Thursday, June 24, 2004 5:32 PM
To: 'Struts Users Mailing List'; jgkennedy@mindspring.com
Subject: RE: Trouble rendering a dynamic form (index=true) with html-el:file

If it's a classcastexception, does that mean when indexed=true we can only
deal with Strings? 

It would follow that this does not make sense for an html:file tag.  

I have the following working just fine in other places thoughout my
application.
<html-el:file size="30" property="file" /> I'm also using a
DynaValidatorForm to define the org.apache.struts.upload.FormFile.  Works
fine without the indexed=true attribute.



-----Original Message-----
From: Jim Kennedy [mailto:jgkennedy@mindspring.com]
Sent: Thursday, June 24, 2004 4:36 PM
To: 'Struts Users Mailing List'
Subject: Trouble rendering a dynamic form (index=true) with html-el:file

I'm trying to upload a set of files using an indexed multipart form.

Here's the JSP code:

	<html-el:form action="/owner/saveimages.exe" method="post"
enctype="multipart/form-data">

		<logic-el:iterate id="imageFiles"
collection="${imageUploadForm.map.imageFiles}" >

		<html-el:file size="30" name="imageFiles" property="file"
indexed="true"
			accept="jpg,jpeg,gif" style="{font-family:
Arial;font-size: 11px;}" />
			</td>
        </logic-el:iterate>

	<br>
	<html-el:submit value="Upload All Images"/>
	</html-el:form>



Here's the Struts config:

		<form-bean name="imageUploadForm"
type="org.apache.struts.validator.DynaValidatorForm">
			<form-property name="imageFiles"
type="com.je.common.UploadHelper[]"/>			
		</form-bean>



Here's UploadHelper class:

public class UploadHelper implements Serializable {
	
	private String id = null;
	private String description = null;
	private String label = null;
	private FormFile file = null;
	
	.....
Getters and setters....

}


I get a useless error from Tomcat (I think it's a ClassCastException):

2004-06-24 16:19:56,971 ERROR [org.jboss.web.lbstpa08.Engine] ----- Root
Cause -----
javax.servlet.ServletException: org/apache/struts/upload/FormFile
        at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:531)
        at
org.apache.jsp.tmpl_owner2_jsp._jspService(tmpl_owner2_jsp.java:256)
        at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
10)
        at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)


Idea's anyone?  This indexed stuff is always very tricky.

Thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Trouble rendering a dynamic form (index=true) with html-el:file

Posted by Jim Kennedy <jg...@mindspring.com>.
If it's a classcastexception, does that mean when indexed=true we can only
deal with Strings? 

It would follow that this does not make sense for an html:file tag.  

I have the following working just fine in other places thoughout my
application.
<html-el:file size="30" property="file" />
I'm also using a DynaValidatorForm to define the
org.apache.struts.upload.FormFile.  Works fine without the indexed=true
attribute.



-----Original Message-----
From: Jim Kennedy [mailto:jgkennedy@mindspring.com] 
Sent: Thursday, June 24, 2004 4:36 PM
To: 'Struts Users Mailing List'
Subject: Trouble rendering a dynamic form (index=true) with html-el:file

I'm trying to upload a set of files using an indexed multipart form.

Here's the JSP code:

	<html-el:form action="/owner/saveimages.exe" method="post"
enctype="multipart/form-data">

		<logic-el:iterate id="imageFiles"
collection="${imageUploadForm.map.imageFiles}" >

		<html-el:file size="30" name="imageFiles" property="file"
indexed="true"
			accept="jpg,jpeg,gif" style="{font-family:
Arial;font-size: 11px;}" />
			</td>
        </logic-el:iterate>

	<br>
	<html-el:submit value="Upload All Images"/>
	</html-el:form>



Here's the Struts config:

		<form-bean name="imageUploadForm"
type="org.apache.struts.validator.DynaValidatorForm">
			<form-property name="imageFiles"
type="com.je.common.UploadHelper[]"/>			
		</form-bean>



Here's UploadHelper class:

public class UploadHelper implements Serializable {
	
	private String id = null;
	private String description = null;
	private String label = null;
	private FormFile file = null;
	
	.....
Getters and setters....

}


I get a useless error from Tomcat (I think it's a ClassCastException):

2004-06-24 16:19:56,971 ERROR [org.jboss.web.lbstpa08.Engine] ----- Root
Cause -----
javax.servlet.ServletException: org/apache/struts/upload/FormFile
        at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:531)
        at
org.apache.jsp.tmpl_owner2_jsp._jspService(tmpl_owner2_jsp.java:256)
        at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
10)
        at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)


Idea's anyone?  This indexed stuff is always very tricky.

Thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org