-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi there ...
im trying to implement my code with the zul to read my txt file, but im having problems to make it work could anyone tell me what im doing wrong.
Thanks
<?page title="texto" contentType="text/html;charset=UTF-8"?> <zk> <window title="texto" border="normal"> <grid> <rows> <row align="center"> <label value="Name of the log file" /> <label value = "" id = "name_log"/> </row> <row align="center"> <label value = "Last update "/> <label id = "l_update" /> </row> <row align="center"> <button label=" Process " width="90px" id = "" onClientInfo="" onClick="show()"/> </row> </rows> </grid> <grid> <rows> <row align="center"> <vlayout> <label value = "Aca van ultmas 20 lineas"/> <label value = "Aca van ultmas 20 lineas"/> <label value = "Aca van ultmas 20 lineas"/> <label value = "Aca van ultmas 20 lineas"/> <label value = "Aca van ultmas 20 lineas"/> <label value = "Aca van ultmas 20 lineas"/> <label value = "Aca van ultmas 20 lineas"/> </vlayout> </row> </rows> </grid> </window> <zscript><![CDATA[ import java.io.*; public class ReadFile { public void show(){ { try{ FileInputStream fstream = new FileInputStream ("texto.txt"); DataInputStream in = new DataInputStream (fstream); BufferedReader br = new BufferedReader (new InputStreamReader(in)); String strLine; while ((strLine = br.readLine()) != null ) { System.out.println(strLine); } in.close (); }catch (Exception e) { System.err.println("Error" + e.getMessage()); } } } ]]></zscript> </zk>
Mmmh... you simply call show() but you have a complete "nested/inner" class defined there.
Is it meant to work like this? In tutorials there are examples on how to include functions on the fly in .zul pages.
And take care where are you taking the file texto.txt from (i.e. its position on the file system) - this way I think it must be at the same level of your .zul file.
Asked: 2011-05-23 11:09:36 +0800
Seen: 408 times
Last updated: May 26 '11