Problem with FormFile
Hi I have a problem with FormFile, in that when it has no file entered it throws an error: I belive this is the cause of the error: 15 Dec 2003 13:21:10 - DEBUG [Thread-2] (BeanUtils.java:873) - setProperty([EMAIL PROTECTED], photo, []) 15 Dec 2003 13:21:10 - DEBUG [Thread-2] (ConvertUtils.java:369) - Convert string '' to class 'org.apache.struts.upload.FormFile' 15 Dec 2003 13:21:10 - DEBUG [Thread-2] (ConvertUtils.java:377) - Using converter [EMAIL PROTECTED] This is the web output: javax.servlet.ServletException: BeanUtils.populate at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254) at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) ... root cause java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.java:1789) at org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.java:1684) at org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:1713) at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019) at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808) at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252) ... The ACtionForm package... import... public class ChangeContactForm extends org.apache.struts.action.ActionForm { private FormFile photo=null; public FormFile getPhoto() { return this.photo; } public void setPhoto(Object photo) { System.out.println((String)photo.class:+photo.getClass()); this.photo=null; } public void setPhoto(FormFile photo) { System.out.println((FormFile)photo.class:+photo.getClass()); this.photo=photo; } } There is more code, I have just removed for sending purposes, the setPhoto with the object parater was to try and work round the error, though I actually believe the error is in ConvertUtils. Any ideas? Mvh Benjamin A. Janes BLUEWAVE SVERIGE M. +46 (0)40-631 1068 F. +46 (0)40 -631 10 50 F. +46 (0)46-540 03 50 Drottninggatan 18, S-211 49 Malmö, Sweden - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problem with FormFile
Is html:file property=photo/ within any iterate/loop ? -Original Message- From: Ben Janes [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 16, 2003 1:22 PM To: [EMAIL PROTECTED] Subject: Problem with FormFile Hi I have a problem with FormFile, in that when it has no file entered it throws an error: I belive this is the cause of the error: 15 Dec 2003 13:21:10 - DEBUG [Thread-2] (BeanUtils.java:873) - setProperty([EMAIL PROTECTED], photo, []) 15 Dec 2003 13:21:10 - DEBUG [Thread-2] (ConvertUtils.java:369) - Convert string '' to class 'org.apache.struts.upload.FormFile' 15 Dec 2003 13:21:10 - DEBUG [Thread-2] (ConvertUtils.java:377) - Using converter [EMAIL PROTECTED] This is the web output: javax.servlet.ServletException: BeanUtils.populate at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254) at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j ava:821) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) ... root cause java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(PropertyUtils.j ava:1789) at org.apache.commons.beanutils.PropertyUtils.setNestedProperty(PropertyUtils.j ava:1684) at org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:17 13) at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1019) at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808) at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1252) ... The ACtionForm package... import... public class ChangeContactForm extends org.apache.struts.action.ActionForm { private FormFile photo=null; public FormFile getPhoto() { return this.photo; } public void setPhoto(Object photo) { System.out.println((String)photo.class:+photo.getClass()); this.photo=null; } public void setPhoto(FormFile photo) { System.out.println((FormFile)photo.class:+photo.getClass()); this.photo=photo; } } There is more code, I have just removed for sending purposes, the setPhoto with the object parater was to try and work round the error, though I actually believe the error is in ConvertUtils. Any ideas? Mvh Benjamin A. Janes BLUEWAVE SVERIGE M. +46 (0)40-631 1068 F. +46 (0)40 -631 10 50 F. +46 (0)46-540 03 50 Drottninggatan 18, S-211 49 Malmö, Sweden - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problem with FormFile
=%= curUser.getAddrStreet() % //td /tr tr td class=clsFormDatabean:message key=prompt.addrTown//td td class=clsFormDatahtml:text property=addrTown size=25 maxlength=150 value=%= curUser.getAddrTown() % //td /tr tr td class=clsFormDatabean:message key=prompt.addrCounty//td td class=clsFormDatahtml:text property=addrCounty size=25 maxlength=150 value=%= curUser.getAddrCounty() % //td /tr tr td class=clsFormDatabean:message key=prompt.addrPCode//td td class=clsFormDatahtml:text property=addrPCode size=25 maxlength=150 value=%= curUser.getAddrPCode() % //td /tr tr td class=clsFormDatabean:message key=prompt.addrCountry//td td class=clsFormData html:select property=addrCountryId value=%= Integer.toString(curUser.getAddrCountryId()) % html:optionsCollection name=sessionCountryList value=id label=country / /html:select /td /tr tr td class=clsFormDatabean:message key=prompt.phone//td td class=clsFormDatahtml:text property=phone size=25 maxlength=150 value=%= curUser.getPhone() % //td /tr tr td class=clsFormDatabean:message key=prompt.mobile//td td class=clsFormDatahtml:text property=mobile size=25 maxlength=150 value=%= curUser.getMobile() % //td /tr tr td class=clsFormDatabean:message key=prompt.fax//td td class=clsFormDatahtml:text property=fax size=25 maxlength=150 value=%= curUser.getFax() % //td /tr tr td class=clsFormDatabean:message key=prompt.email//td td class=clsFormDatahtml:text property=email size=25 maxlength=150 value=%= curUser.getEmail() % //td /tr tr td class=clsFormDatabean:message key=prompt.notes//td td class=clsFormData colspan=2html:textarea property=notes rows=5 cols=60 value=%= curUser.getNotes() % //td /tr tr td class=clsFormDatabean:message key=prompt.photo//td td class=clsFormDatahtml:file property=photo accept=image/jpeg,image/gif//td /tr tr th class=clsFormData colspan=2 html:submit bean:message key=button.submit/ /html:submit #160;#160;#160; html:reset bean:message key=button.reset/ /html:reset /th /tr /table /html:form html:javascript formName=changeContactForm dynamicJavascript=true staticJavascript=false/ script language=Javascript1.1 src=staticJavascript.jsp/script /div /td /tr /table /body /html:html Benjamin A. Janes BLUEWAVE SVERIGE M. +46 (0)40-631 1068 F. +46 (0)40 -631 10 50 F. +46 (0)46-540 03 50 Drottninggatan 18, S-211 49 Malmö, Sweden Aswathy R [EMAIL PROTECTED]To: 'Struts Users Mailing List' [EMAIL PROTECTED] t.com cc: Subject: RE: Problem with FormFile
RE: Problem with FormFile
Does anyone have any ideas, or is it a bug? ;vh Benjamin A. Janes BLUEWAVE SVERIGE M. +46 (0)40-631 1068 F. +46 (0)40 -631 10 50 F. +46 (0)46-540 03 50 Drottninggatan 18, S-211 49 Malmö, Sweden Ben Janes [EMAIL PROTECTED]To: Struts Users Mailing List [EMAIL PROTECTED] com cc: Subject: RE: Problem with FormFile 2003-12-16 12:31 Please respond to Struts Users Mailing List No iterate loop %@ pagelanguage=java contentType=text/html; charset=UTF-8% %@ taglib uri=/WEB-INF/struts-html.tld prefix=html % %@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean % %@ taglib uri=/WEB-INF/meganexus.tld prefix=mg % [EMAIL PROTECTED] file=sessionManager.jsp % % Integer curUserID=mSes.getUserId(session.getId()); // Get Node for User com.meganexus.networking.map.GraphNodeContainer gnc=com.meganexus.networking.map.GraphBuilder.getNode(curUserID.intValue()); if (gnc.isGraphBeingRebuilt()) { mSes.addMessage(session.getId(),messages.graphbeingrebuilt); } com.meganexus.networking.info.Person curUser=gnc.getNode().getPerson(); % ?xml version=1.0 encoding=UTF-8? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.1//EN http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd; html:html locale=true [EMAIL PROTECTED] file=head.jsp % body table cellpadding=0 cellspacing=5 border=1 tr td valign=top [EMAIL PROTECTED] file=optionsMenu.jsp % /td td valign=top [EMAIL PROTECTED] file=aMessage.jsp % !-- Output information goes here -- div class=clsFormContainer html:form method=POST enctype=multipart/form-data action=/changeContact focus=fname onsubmit=return validateChangeContactForm(this); fieldset class=clsDialogGroup legendbean:message key=legend.changecontact //legend table cellpadding=0 cellspacing=5 tr td class=clsFormDataError colspan=2 html:errors/ /td /tr tr th class=clsFormData colspan=6bean:message key=prompt.personaldetails //th /tr tr td class=clsFormDatabean:message key=prompt.firstname//td td class=clsFormDatahtml:text property=fname size=25 maxlength=50 value=%= curUser.getFname() % //td td class=clsFormData rowspan=17mg:showThumbnail personId=%= Integer.toString(curUser.getId()) % //td /tr tr td class=clsFormDatabean:message key=prompt.lastname//td td class=clsFormDatahtml:text property=lname size=25 maxlength=50 value=%= curUser.getLname() % //td /tr
problem with FormFile
Hi, I have created file upload.jsp: %@ page contentType=text/html; charset=ISO-8859-2 % %@ page language=java % %@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean % %@ taglib uri=/WEB-INF/struts-html.tld prefix=html % html:html head meta http-equiv=Content-Type content=text/html; charset=ISO-8859-2 META NAME=Author CONTENT=Bartlomiej Pawlowski titleupload/title /head body html:form action=/upload File html:file property=file maxlength=30 styleClass=form2/ html:submitUpload/html:submit /html:form /body /html:html and ActionForm bean: public class UploadForm extends ActionForm { private FormFile file; public UploadForm() { } public void setFile(FormFile file) { this.file = file; } public FormFile getFile() { return file; } } when I submit this form I receive following exception: Internal Servlet Error: javax.servlet.ServletException: BeanUtils.populate at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:486) at org.apache.struts.action.ActionServlet.processPopulate(ActionServlet.java:1910) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1521) Root cause: java.lang.IllegalArgumentException: argument type mismatch at java.lang.reflect.Method.invoke(Native Method) at org.apache.struts.util.PropertyUtils.setSimpleProperty(PropertyUtils.java:825) at org.apache.struts.util.PropertyUtils.setNestedProperty(PropertyUtils.java:756) at org.apache.struts.util.PropertyUtils.setProperty(PropertyUtils.java:782) What is wrong? Who can help me?
Re: problem with FormFile
To use file upload, you need to specify the method and encoding for the form, like this: html:form action=/upload method=post enctype=multipart/form-data ... /html:form -- Martin Cooper - Original Message - From: Bar³omiej Paw³owski [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 01, 2001 7:24 AM Subject: problem with FormFile Hi, I have created file upload.jsp: %@ page contentType=text/html; charset=ISO-8859-2 % %@ page language=java % %@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean % %@ taglib uri=/WEB-INF/struts-html.tld prefix=html % html:html head meta http-equiv=Content-Type content=text/html; charset=ISO-8859-2 META NAME=Author CONTENT=Bartlomiej Pawlowski titleupload/title /head body html:form action=/upload File html:file property=file maxlength=30 styleClass=form2/ html:submitUpload/html:submit /html:form /body /html:html and ActionForm bean: public class UploadForm extends ActionForm { private FormFile file; public UploadForm() { } public void setFile(FormFile file) { this.file = file; } public FormFile getFile() { return file; } } when I submit this form I receive following exception: Internal Servlet Error: javax.servlet.ServletException: BeanUtils.populate at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:486) at org.apache.struts.action.ActionServlet.processPopulate(ActionServlet.java:19 10) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1521) Root cause: java.lang.IllegalArgumentException: argument type mismatch at java.lang.reflect.Method.invoke(Native Method) at org.apache.struts.util.PropertyUtils.setSimpleProperty(PropertyUtils.java:82 5) at org.apache.struts.util.PropertyUtils.setNestedProperty(PropertyUtils.java:75 6) at org.apache.struts.util.PropertyUtils.setProperty(PropertyUtils.java:782) What is wrong? Who can help me?