0

not getting the output

asked 2011-09-15 12:58:43 +0800

streetfi8er gravatar image streetfi8er
36

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.

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2011-09-15 13:13:30 +0800

zknewbie1 gravatar image zknewbie1
370 4

Hi Streetfi8er, since ZUL file is actually XML file, you'll need to make sure it's well-formed. In your case, you have an open <vlayout> tag without the end tag </vlayout>..

link publish delete flag offensive edit

answered 2011-09-15 13:26:22 +0800

twiegand gravatar image twiegand
1807 3

updated 2011-09-15 13:28:02 +0800

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

link publish delete flag offensive edit

answered 2011-09-15 14:15:20 +0800

streetfi8er gravatar image streetfi8er
36

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>

Then i get Hello written .
Also i've kept the xml file under the 'myZk/WEB-INF' folder where myZK is the name of my app.
here is the xml file:

<?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>

link publish delete flag offensive edit

answered 2011-09-15 16:17:57 +0800

twiegand gravatar image twiegand
1807 3

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

link publish delete flag offensive edit

answered 2011-09-15 22:45:43 +0800

streetfi8er gravatar image streetfi8er
36

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 .

link publish delete flag offensive edit

answered 2011-09-16 01:29:30 +0800

gsim gravatar image gsim
81

When adding code to zk events, write java code using ZK's API.

Just try to change

<textbox id="txtbx" onChange="lbl.value=self.value"/>

with

<textbox id="txtbx" onChange="lbl.setValue(self.getValue())"/>

link publish delete flag offensive edit

answered 2011-09-16 10:22:20 +0800

twiegand gravatar image twiegand
1807 3

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

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: 2011-09-15 12:58:43 +0800

Seen: 197 times

Last updated: Sep 16 '11

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