In fact, when I have a multipart form, none of the setters get called on
my beans, even for <h:inputText> fields
(with or without an upload control on the form). If I remove the
multipart flag, my setters get called, but of course you need a
multipart form for uploading binary files.
Could it be a MyFaces 1.1.3 bug? Or could it be the result of using
both ADF and MyFaces together?
My jars are below.
10,823 adf-facelets.jar
683,633 adf-faces-api-ea20-SNAPSHOT.jar
3,122,625 adf-faces-impl-ea20-SNAPSHOT.jar
48,742 common-annotations.jar
188,671 commons-beanutils-1.7.0.jar
46,725 commons-codec-1.3.jar
559,366 commons-collections-3.1.jar
168,446 commons-digester-1.6.jar
112,341 commons-el-1.0.jar
31,825 commons-fileupload-1.1.jar
65,621 commons-io-1.2.jar
207,723 commons-lang-2.1.jar
38,015 commons-logging-1.0.4.jar
26,089 el-api.jar
96,983 el-ri.jar
252,102 jsf-facelets1014.jar
50,491 jsp-api.jar
16,923 jstl-1.1.0.jar
123,206 mob-layer-interfaces.jar
252,169 myfaces-api-1.1.3-SNAPSHOT.jar
517,156 myfaces-impl-1.1.3-SNAPSHOT.jar
15,420 portlet.jar
188,993 serializer.jar
1,237,598 tomahawk-1.1.2-SNAPSHOT.jar
3,078,601 xalan.jar
1,203,860 xercesImpl.jar
194,205 xml-apis.jar
Murray Brandon wrote:
Hi all,
I'm having a problem trying to get file upload to work.
<h:form id="form1" name="form1" enctype="multipart/form-data" >
<h:outputText value="Please give me an image"/>
*<t:inputFileUpload id="fileupload"
accept="image/*"
value="#{ui.someUser.file}"
storage="file"
required="true"/>*
<h:commandButton value="Upload Now!"
action="#{ui.someUser.doUpload}" />
</h:form>
My bean effectively has this in it:
import org.apache.myfaces.custom.fileupload.UploadedFile;
:
:
public class MyBean
{
public void fileUploaded(ValueChangeEvent event)
{
UploadedFile file = (UploadedFile)event.getNewValue();
if (file != null)
{
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage("Successfully
uploaded file " + file.getName() + " (" + file.getSize() + " bytes)");
context.addMessage(event.getComponent().getClientId(context), message);
// Here's where we could call file.getInputStream()
}
else
{
System.out.println("fileUploaded called with no file");
}
}
public UploadedFile getFile()
{
return _file;
}
* public void setFile(UploadedFile file)
{
// never called!
_file = file;
}
*
public String doUpload()
{
UploadedFile file = getFile();
// ... and process it in some way
return (file != null ? file.getName() : "nullo");
}
private UploadedFile _file;
}
Please help!
Regards, Murray
================================================
extra notes:
1) I am using Facelets + Myfaces + Tomahawk + ADF faces.
2) For a start I get a javascript error on submit because
clear_form1(); does not exist not sure why it is missing.
The following html was generated:
<input id="form1:_id6" name="form1:_id6" type="submit" value="Upload
Now!" onclick="*clear_form1();*">
3) My web.xml
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<init-param>
<param-name>maxFileSize</param-name>
<param-value>20m</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>
</filter>
<!-- extension mapping for adding <script/>, <link/>, and other
resource tags to JSF-pages -->
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<servlet-name>FacesServlet</servlet-name>
</filter-mapping>
<!-- extension mapping for serving page-independent resources
(javascript, stylesheets, images, etc.) -->
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>
4) ADF faces file upload exhibits the same behaviour.
5) The file is definitely attempting to be uploaded because if I give
a really big file I get a SizeLimitExceededException.
Apr 11, 2006 4:58:58 AM
org.apache.myfaces.webapp.filter.MultipartRequestWrapper parseRequest
INFO: user tried to upload a file that exceeded file-size limitations.
org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException:
the request was rejected because its size (337407087) exceeds the
configured maximum (104857600)
at
org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:310)
at
org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:268)
at
org.apache.myfaces.webapp.filter.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:81)
at
org.apache.myfaces.webapp.filter.MultipartRequestWrapper.getParameterMap(MultipartRequestWrapper.java:177)
at
oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:184)
at
oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:80)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:130)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)