Can you remove this part from your web.xml and try ...
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
also have you tried with the <h:messages> tag on your form ?
-----Original Message-----
From: Rashmi Kumari [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 29, 2005 8:56 AM
To: MyFaces Discussion
Subject: RE: File upload problem
url pattern for JSF is
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
I tried to simulate same thing in the actual sample of myfaces1.0.9 to see
if that is working but there also same problem.
FileUploadForm.java
public class FileUploadForm
{
private UploadedFile _upFile;
private String _name = "";
public UploadedFile getUpFile()
{
return _upFile;
}
public void setUpFile(UploadedFile upFile)
{
_upFile = upFile;
}
public String getName()
{
return _name;
}
public void setName(String name)
{
_name = name;
}
public String upload() throws IOException
{
FacesContext facesContext = FacesContext.getCurrentInstance();
facesContext.getExternalContext().getApplicationMap().put
("fileupload_bytes", _upFile.getBytes());
facesContext.getExternalContext().getApplicationMap().put
("fileupload_type", _upFile.getContentType());
facesContext.getExternalContext().getApplicationMap().put
("fileupload_name", _upFile.getName());
return "ok";
}
public boolean isUploaded()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
return facesContext.getExternalContext().getApplicationMap().get
("fileupload_bytes")!=null;
}
public String saveStyle()
{
System.out.println("Hello from saveStyle");
return "Hello from saveStyle";
}
}
fileupload.jsp
<h:form id="form1" name="form1" enctype="multipart/form-data" >
<h:outputText value=""/>
<h:outputText value="#{example_messages
['fileupload_gimmeimage']} "/>
<x:inputFileUpload id="fileupload"
accept="image/*"
value="#{fileUploadForm.upFile}"
storage="file"
styleClass="fileUploadInput"
required="true"/>
<f:verbatim><br></f:verbatim>
<h:outputText value="#{example_messages
['fileupload_name']}"/>
<h:inputText value="#{fileUploadForm.name}"/>
<h:commandButton value="#{example_messages
['fileupload_button']}" action="#{fileUploadForm.upload}" />
</h:form>
<h:panelGrid columns="1" rendered="
#{fileUploadForm.uploaded}">
<h:outputText value="#{example_messages
['fileupload_msg1']}" />
<h:graphicImage url="fileupload_showimg.jsf"/>
<h:outputText value="#{fileUploadForm.name}"/>
<h:outputText value="#{example_messages
['fileupload_msg2']}" />
<h:outputLink value="fileupload_showimg.jsf">
<f:param name="allowCache" value="true"/>
<f:param name="openDirectly" value="false"/>
<h:outputText value="#{example_messages
['fileupload_dlimg']}"/>
</h:outputLink>
<h:outputText value="#{example_messages
['fileupload_msg3']}" />
<h:outputLink value="fileupload_showimg.jsf">
<f:param name="allowCache" value="true"/>
<f:param name="openDirectly" value="true"/>
<h:outputText value="#{example_messages
['fileupload_dlimg']}"/>
</h:outputLink>
</h:panelGrid>
<f:verbatim></td></tr></table><p></f:verbatim>
<f:verbatim></p><p></f:verbatim>
<f:verbatim></p></f:verbatim>
<h:commandButton id="submit" action="#{fileUploadForm.saveStyle}"
value="Save"/>
Here also action is not getting called as the string in saveStyle method is
not getting printed on submit.
Regards,
Rashmi
"Srikanth Madarapu"
<[EMAIL PROTECTED] To: "MyFaces Discussion"
<[email protected]>
stems.com> cc:
Subject: RE: File upload
problem
06/29/2005 06:02 PM
Please respond to
"MyFaces Discussion"
Also check the filter mapping. Seems like you just cut and pasted the
extension filter setup into your web.xml. How is your url pattern for JSFs.
I am talking about this part...
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
HTH
Srikanth
-----Original Message-----
From: Rashmi Kumari [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 29, 2005 7:44 AM
To: MyFaces Discussion
Subject: Re: File upload problem
I have added enctype to the form tag----------
<h:form id="styleForm" enctype="multipart/form-data" >
I have also added Extensions filter in web.xml---------
<!-- 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>*.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
Regards,
Rashmi
Matthias
Wessendorf To: MyFaces Discussion
<[email protected]>
<[EMAIL PROTECTED] cc:
mail.com> Subject: Re: File upload
problem
06/29/2005
05:06 PM
Please respond
to "MyFaces
Discussion"
have you configured the extension filter
and added enctype to <h:form> ?
-Matthias
On 6/29/05, Rashmi Kumari <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have added File upload component in my application. User selects the
> image and can see the preview of it as it is happening in myfaces
examples.
> I have a save button also for calling the action but form is not getting
> submitted when this button is clicked.
> If I remove the file upload tag, then the action gets invoked. what could
> be the reason for this behaviour.
>
> The jsp is:
>
> <h:outputText value="#{Message.marker_style_import}" />
> <x:inputFileUpload id="fileupload"
> accept="image/*"
> value="#{fileUploadForm.upFile}"
> storage="file"
> styleClass="fileUploadInput"
> required="true"/>
>
>
> <f:verbatim><br></f:verbatim>
> <h:commandButton value="#{Message.image_upload_button}" action="
> #{fileUploadForm.upload}" />
>
> <h:panelGrid columns="1" rendered="#{fileUploadForm.uploaded}">
> <h:outputText value="#{Message.marker_style_preview}" />
> <h:graphicImage url="fileupload_showimg.jsf" width="50" height="50"
> style="border-style: solid; border-width: 2"/>
> </h:panelGrid>
> <h:commandButton id="submit" action="#{Persister.saveStyle}" value="
> #{Message.style_submit_button}"/>
>
> But it doesn't invoke saveStyle method of the backing bean.
>
> Thanx for any suggestions.
>
> Regards,
>
> Rashmi
>
>
--
Matthias Wessendorf