ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

Zk + JSP

kumaryesu
10 Jan 2012 04:25:40 GMT
10 Jan 2012 04:25:40 GMT

Can we integrate ZK in JSP?

I would like to develop a JSP project where i can use ZK. is it possible?

mjablonskiTop Contributor
10 Jan 2012 06:41:34 GMT
10 Jan 2012 06:41:34 GMT

Hi,

yes, that's possible. You can either use ZK-JSP or integrate ZUL-files into your existing JSP templates via simple request dispatching. The ZK-based Jease-Content-Management-System does it this way and it works nicely. Here's a demo:

http://www.jease.org/demo/zul/

The page template is a simple JSP whereas the ZUL-Script is integrated via something like

... jsp-stuff ...
<% pageContext.include("/path/to/your/custom.zul"); %>
... jsp-stuff ...

HTH, Maik

kumaryesu
10 Jan 2012 08:44:35 GMT
10 Jan 2012 08:44:35 GMT

Thank you sir.

I tired what you told me. only the label and button are displayed when use this code (<% pageContext.include("/path/to/your/custom.zul"); %>)

textbox and other components of zk are not displyed. and also i am getting the same format of zk file in jsp when i integrate

can you pls give me some sample program in jsp?

mjablonskiTop Contributor
10 Jan 2012 10:15:32 GMT
10 Jan 2012 10:15:32 GMT

Make sure that your JSP uses the correct DOCTYPE (XHTML/Transitional) for ZK-Integration:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

HTH, Maik

kumaryesu
10 Jan 2012 11:09:23 GMT
10 Jan 2012 11:09:23 GMT

Sorry sir. i still have the same problem.

This is my index.jsp file

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<h1>B08MAD.in Home Page</h1>
<% pageContext.include("index1.zul"); %>

</body>
</html>

and this is my uploadFiles.zul file

<?page title="Uploading" contentType="text/html;charset=UTF-8"?>
<zk>
	<window id="uploadFiles" title="Uploads" border="normal"
		width="400px" closable="true" mode="modal"
		apply="" visible="false">
		<grid>
			<columns>
				<column width="20%" />
				<column width="80%" />
			</columns>
			<rows>
				<row spans="2" align="center">
					<label value="Max Upload size is 10 MB" id="error"
						style="color: red; font-weight:bold;" />
				</row>
				<row height="40px" id="rowCategory">
					<label value="Category" />
					<combobox id="category" width="40%"
						readonly="true">
						<comboitem label="Event" />
						<comboitem label="News" />
						<comboitem label="Jobs" />
						<comboitem label="Images" />
						<comboitem label="Banner" />
					</combobox>
				</row>
			</rows>
		</grid>
	</window>
</zk>

this is my URL : http://www.b08mad.in/

i could not get ZUL file..

only JSP file is running..

pls don't get me wrong if i ask any wrong question.

i am learning ZK Frmework..

pls provide me some sample code if you could....

thanks for answering me

mjablonskiTop Contributor
10 Jan 2012 11:48:05 GMT
10 Jan 2012 11:48:05 GMT

Did you properly configure ZK/ZUL-support in your web.xml? You need also to deploy the zk.jars to WEB-INF/lib of your application.

...
 <servlet>
                <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>

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

        <mime-mapping>
                <extension>zhtml</extension>
                <mime-type>text/html</mime-type>
        </mime-mapping>
        <mime-mapping>
                <extension>zul</extension>
                <mime-type>text/html</mime-type>
        </mime-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>index.jsp</welcome-file>
        </welcome-file-list>
 ...

kumaryesu
10 Jan 2012 12:23:13 GMT
10 Jan 2012 12:23:13 GMT

I have configured the web.zml file as bellow

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

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

        <mime-mapping>
                <extension>zhtml</extension>
                <mime-type>text/html</mime-type>
        </mime-mapping>
        <mime-mapping>
                <extension>zul</extension>
                <mime-type>text/html</mime-type>
        </mime-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>index.jsp</welcome-file>
        </welcome-file-list>


But i have the same proble

mjablonskiTop Contributor
10 Jan 2012 13:40:39 GMT
10 Jan 2012 13:40:39 GMT

Works for me:

http://www.jease.org/tst/test.jsp

But you need to change your ZUL-file from

...
<window ... visible="false">
...

to

...
<window ... visible="true">
...

If it doesn't work for you this way, I recommend to download the Jease distribution which contains a war-file with all the configs/libraries properly configured.

HTH, Maik

kumaryesu
10 Jan 2012 16:07:01 GMT
10 Jan 2012 16:07:01 GMT

I am really greateful to you sir...
Thank you veryyyyyyyyyyyyyyyyyyyyyyy veryyyyyyyyyyyyyyyyyyyyyyyyyyyy much sir...
I got it. Thank you very much sir.....

Thank you very much sir...

kumaryesu
12 Jan 2012 09:56:48 GMT
12 Jan 2012 09:56:48 GMT

Hai Sir,

Again i have problem. when i remove the web.xml file the following code works correctely


index.jsp

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Index</title> 
<!--  initialize the TN3 when the DOM is ready -->
</head>
<body>
<center>
<%
	pageContext.include("/uploadFiles.zul");
%>
</center>
</body>
</html>

and my uploadFiles.zul

<?page title="Adding New Student" contentType="text/html;charset=UTF-8"?>
<zk>
	<window id="uploadFiles" title="Uploads" border="normal"
		width="400px" height="500px" closable="true" mode="modal"
		apply="" visible="true">
		Why is not working...!!!
	</window>
</zk>

my website URL is http://www.b08mad.in/

its not working

but when i remove the web-inf folder it works. but label is shown. textbox, button etc... are not shwoing

pls help me sir !!!

thanks in advance..