-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am new to ZK studio.when I click a button, I want to show up a msg box displaying a file content or string array. when I use the string array, I am getting errors.
Please help me out in resolving this problem.
Which error are you getting ?
My code is:
<window title="" id='win1'>
<html>
<![CDATA[
<body style = "background color: blue;font-family:courier new; color:red; font-size:20px" >
</body>
]]>
</html>
<button label="Available Free IPs" height="50" width="200"
popup="pop">
<attribute name="onClick">{
<![CDATA[
java.io.File file = new java.io.File("c:\\test.txt");
java.io.FileReader fr = new java.io.FileReader(file);
java.io.BufferedReader bfr = new java.io.BufferedReader(fr);
String[] str = null;
String line;
int i = 0;
while((line = bfr.readLine())!= null)
{
str = line;
i++;
}
Messagebox.show(""+str,"title", Messagebox.OK, Messagebox.EXCLAMATION);
]]>
}
</attribute>
</button>
</window>
ERROR that I got :Sourced file: inline evaluation of: `` { java.io.File file = new java.io.File("c:\\ . . . '' : Not an array : at Line: 24 : in file: inline evaluation of: `` { java.io.File file = new java.io.File("c:\\ . . . '' : [ i ]
My file content is list of names. I want display them on msgbox once i click on the button. If you know any alternate method to accomplish this, please share with me.
Hi,
ZK provides utils for reading files, so I would recommend to use them.
<window> <button label="Available Free IPs"> <attribute name="onClick">{ <![CDATA[ java.io.File file = new java.io.File("c:\\test.txt"); String result = org.zkoss.io.Files.readAll(new java.io.FileReader(file)).toString(); Messagebox.show(result, "title", Messagebox.OK, Messagebox.EXCLAMATION); ]]> } </attribute> </button> </window>
Cheers, Maik
Asked: 2010-05-25 16:33:36 +0800
Seen: 738 times
Last updated: May 26 '10