Saturday, 24 August 2013

SpringFramework set selected FilePath to a "path attribute" of form

SpringFramework set selected FilePath to a "path attribute" of form

When a file is selected it must set the fileName with path to a textField
with path="inputFileName". I tried to below code which is not working as
setFileName is not called either onClick nor onSelect.
Any pointers how this can be done will be great help to me.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="f" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%!
public void setFileName(){
System.out.println("In SetFile Name for InputFile");
}
%>
<html>
<body>
File Convertor
<PRE>
<f:form method="PUT" commandName="file2" >
Input File <f:input path="inputFileName"/><input type="file"
name="ChooseMyFile" value="A" onclick="setFileName()"
onselect="setFileName()"/>
Output File <f:input path="outputFileName"/>
</f:form>
</PRE>
</body>
</html>

No comments:

Post a Comment