|
JSF Tags: Tomahawk Tags |
|
<%@taglib uri=”http://java.sun.com/jsf/
html” prefix=”h”%>
<%@taglib uri=”http://java.sun.com/jsf/
core” prefix=”f”%>
<%@ taglib uri=”http://
myfaces.apache.org/tomahawk”
prefix=”t”
%>
<html>
<head>
<title>t:inputFileUpload example</title>
</head>
<body>
<f:view>
<h:form id=”welcomeForm”
enctype=”multipart/form-data”>
<t:inputFileUpload id=”fileupload”
value=”#{FileUploadForm.upFile}
”size=”20" />
<p/>
<h:commandButton value=”Load the
file”
action=”#{FileUploadForm.upload}”
/>
<t:outputText value=”File Uploaded
Successfully.”
rendered=”#
{FileUploadForm.rendSuccess}”
style=”color:green;font-weight:bold”/>
<t:outputText value=”Error in File
Uploading.”
rendered=”#
{FileUploadForm.rendFailure}”
style=”color:red;font-weight:bold”/>
</h:form>
</f:view>
</body>
</html>
FileUploadForm.java :
package net.roseindia.web.ui;
import java.io.*;
import javax.servlet.http.*;
import
org.apache.myfaces.custom.
fileupload.UploadedFile;
import javax.faces.context.
FacesContext;
public class FileUploadForm{
private UploadedFile upFile;
boolean rendSuccess=false; |
|
boolean rendFailure=false;
public FileUploadForm(){
}
public UploadedFile getUpFile(){
return upFile;
}
public void setUpFile(UploadedFile
upFile){
this.upFile = upFile;
}
public boolean getRendSuccess(){
return rendSuccess;
}
public void setRendSuccess(boolean
rendSuccess){
this.rendSuccess = rendSuccess;
}
public boolean getRendFailure(){
return rendFailure;
}
public void setRendFailure(boolean
rendFailure){
this.rendFailure = rendFailure;
}
public String upload() throws
IOException{
try {
InputStream stream =
upFile.getInputStream();
long size = upFile.getSize();
byte [] buffer = new byte[(int)size];
stream.read(buffer, 0, (int)size);
stream.close();
rendSuccess=true;
rendFailure=false;
System.out.println(“File Upload
Successful.”);
return “ok”;
}
catch (Exception ioe) {
System.out.println(“File Upload
Unsuccessful.”); |
|
Sept 2007 | Java Jazz Up |15 |
|
|
|
Pages:
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53 ,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63 ,
64,
65 ,
66 ,
67 ,
68 ,
69 ,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79, Download PDF |
|
|
|
|
|
|
|
|
|