0

message box to show the file content/string array

asked 2010-05-25 16:33:36 +0800

chethan gravatar image chethan
12

updated 2010-05-25 16:36:56 +0800

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.

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2010-05-25 17:27:56 +0800

YamilBracho gravatar image YamilBracho
1722 2

Which error are you getting ?

link publish delete flag offensive edit

answered 2010-05-26 03:24:01 +0800

chethan gravatar image chethan
12

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.

link publish delete flag offensive edit

answered 2010-05-26 03:49:29 +0800

mjablonski gravatar image mjablonski
1284 3 5
http://www.jease.org/

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

link publish delete flag offensive edit

answered 2010-05-26 13:01:58 +0800

chethan gravatar image chethan
12

Thanks a lot for your help Maik.. How could we display the file content in the listbox? Please share your ideas.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-05-25 16:33:36 +0800

Seen: 738 times

Last updated: May 26 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More