-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi, this is my first programme in ZK.
I installed apache tomcat 7.02, and put the zk library jar files in a folder myZK under webapps of tomcat.Then i created the web.xml file and a hello.zul file . Finallly i made a WAR file . When i run the hello.zul file, i do not get the output. Its just a blank page displayed.
Here is my hello.zul file:
<?page title="hello zk" contentType="text/html;charset=UTF-8"?> <zk> <window title = "My first ZUL programme" border = "normal" width = "250 px"> <vlayout> <textbox id="txtbx" onChange="lbl.value=self.value"/> <label id="lbl"/> </window> </zk> Thanks.
Streetfi8er,
zknewbie1 is right on - your zul file is incorrect. However, since you said you just get a blank page, my sense is that there is something more going on than just mal-formed XML.
It seems like Tomcat is not aware of your ZK libraries. If it was, the zul above would have come back complaining of the missing </vlayout> tag error.
You might check to ensure you have the web.xml file in the right place. For more info on setting up Tomcat with ZK, click here.
Hope that helps,
Todd
thanks for the replies but even when i closed the tag, i still get no ouput.
@twiegand: if I add a "hello " after window tag, it gets displayed.
<?page title="hello zk" contentType="text/html;charset=UTF-8"?> <zk> <window title = "My first ZUL programme" border = "normal" width = "250 px"> Hello <vlayout> <textbox id="txtbx" onChange="lbl.value=self.value"/> <label id="lbl"/> </vlayout> </window> </zk>
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <description><My ZK Application></description> <display-name>MyApp</display-name> </web-app>
If that is all your web.xml file has in it, that is probably the problem. I believe it should look more like this:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <description><![CDATA[My ZK Application]]></description> <display-name>MyApp</display-name> <listener> <description>ZK listener for session cleanup</description> <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class> </listener> <servlet> <description>ZK loader for ZUML pages</description> <servlet-name>zkLoader</servlet-name> <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class> <init-param> <param-name>update-uri</param-name> <param-value>/zkau</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.zul</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.zhtml</url-pattern> </servlet-mapping> <!-- Optional. Uncomment it if you want to use richlets. <servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>/zk/*</url-pattern> </servlet-mapping> --> <servlet> <description>The asynchronous update engine for ZK</description> <servlet-name>auEngine</servlet-name> <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>auEngine</servlet-name> <url-pattern>/zkau/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.zul</welcome-file> <welcome-file>index.zhtml</welcome-file> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> </welcome-file-list> </web-app>
Todd
thanks Todd.... i modified my xml file as you suggestedl,still just getting the "hello" as the output and no other component :(
My directory structure is :
tomcat\webapps\myZk\myZK\hello.zul
tomcat\webapps\myZK\myZK\WEB-INF\web.xml
tomcat\webapps\myZK\myZK\WEB-INF\lib
where lib contains all jars extracted from the zk-bin .
Hmmm, it seems like you have one too many myZK directory levels in your structure. I would remove one of those and see if that helps.
Failing that, lets take a step back and see if Tomcat is coming up at all. Start your Tomcat server, go to the browser and navigate to the URL http://localhost:8080 (change the port from 8080 to whatever you use). When you press Enter, do you get the Tomcat landing page? If not, then we have a bigger problem.
Assuming that you do indeed get the Tomcat landing page, one way you could ensure the ZK libraries are getting loaded is to drop them directly into the lib folder in Tomcat (\<tomcat home>\lib).
Hope that helps,
Todd
Asked: 2011-09-15 12:58:43 +0800
Seen: 197 times
Last updated: Sep 16 '11