-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi, I am working on ZK5 Spring3 application with existing JSP pages, and would like to integrate ZK/JSP content. i am new to ZK so please forgive me.
My project view is setup as *.zul pages and i can include existing header.jsp and footer.jsp and render correctly however, any ZK elements between the include statements renders outside the page(eg. below the footer)
here is my code:
<?page title="ZK TEST" contentType="text/html;charset=UTF-8" style="height:100%"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<zk xmlns:html="http://www.w3.org/1999/xhtml">
<include id="header" sclass="header" src="/WEB-INF/includes/header.jsp" />
<window title="test">
<textbox></textbox>
</window>
<include id="footer" sclass="footer" src="/WEB-INF/includes/footer.jsp" />
</zk>
I am only interested in integrating existing header and footer to follow organization branding. any help is greatly appreciated.
Thank you
Hi
the include component has different mode for different situation
the default mode: auto, will loaded component by createComponents(), which is suitable for zul
the defer mode: will include page by servlet container
in here, we should use defer mode in include jsp file
Hey Sam, i updated my includes to override default auto mode to defer but it didn't help.
<?page title="directory@UCSF" contentType="text/html;charset=UTF-8" style="height:100%"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<zk xmlns:html="http://www.w3.org/1999/xhtml">
<include id="header" sclass="header" src="/WEB-INF/includes/header.jsp" mode="defer" />
<textbox></textbox>
<include id="footer" sclass="footer" src="/WEB-INF/includes/footer.jsp" mode="defer" />
</zk>
do you have any other suggestions?
I am wondering if this is doable at all. my header.jsp has
<html>
<header></header>
<body>
<div>
...
and my footer.jsp has:
</div>
</body>
</html>
can I enclose zul elements between standard <html> tages in a zul page?
Thank you
Hi
below is my test sample code, it's working on my computer, hope it could help you
There are 4 files: includeJspPage.zul, databinding.jsp (these two put in jsp folder) and DatabindingInit.java MyValue.java
includeJspPage.zul
<?page title="new page title" contentType="text/html;charset=UTF-8"?> <zk> <window title="Include another Jsp Page" border="normal"> <include src="/jsp/databinding.jsp" mode="defer" /> </window> </zk>
databinding.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://www.zkoss.org/jsp/zul" prefix="z" %> <z:init use="org.zkoss.zkplus.databind.AnnotateDataBinderInit"/> <z:init use="demo.jsp.DatabindingInit"/> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Use Annotated Data Binding</title> </head> <body> <z:page> <z:zscript> System.out.println("fire when load page..." ); </z:zscript> <z:window id="mainPanel" width="600px" title="RSS Reader with Aggregate Feed" border="normal" > <z:caption id="mainCap" label="Add New Feed"> <z:button id="cancelBtn" label="test"> <z:attribute name="onClick"> System.out.println("zscript.pageVariable()= "+current_date ); </z:attribute> </z:button> </z:caption> <z:listbox id="feedListBox" model="@{my_list}" rows="8" selectedItem="@{selected}"> <z:listitem self="@{bind(each='my')}"> <z:listcell label="@{my.value}"/> <z:listcell label="@{my.date}"/> </z:listitem> </z:listbox> </z:window> </z:page> </body> </html>
DatabindingInit.java
package demo.jsp; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.Map; import org.zkoss.zk.ui.Page; import org.zkoss.zk.ui.util.Initiator; /** * @author Sam * */ public class DatabindingInit implements Initiator{ public void doAfterCompose(Page page) throws Exception { Object a = page.getAttribute("current_date"); System.out.println("MyInit::doAfterCompose(): current_date= "+a); } public boolean doCatch(Throwable ex) { // TODO Auto-generated method stub return false; } public void doFinally() { // TODO Auto-generated method stub } private SimpleDateFormat form = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); public void doInit(Page page, Map args) throws Exception { ArrayList list = new ArrayList(); page.getAttribute("current_date"); for(int i=0;i<10;i++) { final String ref = "index: "+i; list.add(new MyValue(){ public String getDate() { return form.format(new Date()); } public String getValue() { return ref; } }); } page.setAttribute("my_list", list); } }
MyValue.java
public interface MyValue { String getValue(); String getDate(); }
Hi Sam, thanks for your reply.
I tried your suggestion and now getting the following error:
Failed to load /WEB-INF/jsp/search.jsp
Cause: javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/zkoss/web/servlet/xel/PageRequestContext
org.zkoss.zk.ui.UiException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/zkoss/web/servlet/xel/PageRequestContext
at org.zkoss.zk.ui.http.ExecutionImpl.include(ExecutionImpl.java:205)
at org.zkoss.zul.Include.include(Include.java:523)
at org.zkoss.zul.Include.renderProperties(Include.java:483)
at org.zkoss.zk.ui.AbstractComponent.redraw(AbstractComponent.java:1677)
at org.zkoss.zk.ui.AbstractComponent.redrawChildren(AbstractComponent.java:1750)
at org.zkoss.zk.ui.AbstractComponent.redraw(AbstractComponent.java:1690)
here is my ZK Maven includes:
<zk.version>5.0.3</zk.version>
<!-- Start ZK Framework -->
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkspring-core</artifactId>
<version>3.0RC</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkspring-security</artifactId>
<version>3.0RC</version>
</dependency>
<dependency>
<groupId>org.beanshell</groupId>
<artifactId>bsh-core</artifactId>
<version>2.0b4</version>
</dependency>
<dependency>
<groupId>org.zkoss.common</groupId>
<artifactId>zcommon</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.common</groupId>
<artifactId>zweb</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zk</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zhtml</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkplus</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zml</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zul</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zuljsf</artifactId>
<version>0.8.1</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zuljsp</artifactId>
<version>1.0.0</version>
</dependency>
<!-- End ZK Framework -->
I got this to work by downloading and integrating the latest zkjsp package (zk-JspTags-bin-1.4.0-RC.zip) from http://www.zkoss.org/download/other.dsp
there doesn't seem to be an up-to-date maven artifact for this package in zkoss maven repository.
Thank you!
-T
Asked: 2010-07-14 15:47:51 +0800
Seen: 499 times
Last updated: Jul 16 '10