New Features of ZK JSP Tags 1.2.0"

From Documentation
 
Line 86: Line 86:
 
</source>
 
</source>
  
The URL must be http://www.zkoss.org/jsp/zul. It is the key to access correct ZK library.
+
The URL must be <nowiki>http://www.zkoss.org/jsp/zul</nowiki>. It is the key to access correct ZK library.
  
  

Latest revision as of 10:07, 30 December 2011

DocumentationSmall Talks2008AprilNew Features of ZK JSP Tags 1.2.0
New Features of ZK JSP Tags 1.2.0

Author
Ian Tsai, Engineer, Potix Corporation
Date
April 1, 2008
Version


Support More Components

ZK JSP Tags 1.2 now supports ZK Google Maps and Jasperreport components. For example:

<z:gmaps id="map" zoom="14">
	<z:attribute name="lng">121.55298871046938</z:attribute>
	<z:attribute name="lat">25.042063183495276</z:attribute>
</z:gmaps>
...


As you can see, the rules of how to use ZK Google Map are the same as its in pure ZK. For more complexed demonstration, please take a look at /guide/index.jsp in ZK JSP Demo 1.2.0 :

Gmap.jpg


If you want to know more about how to use ZK Gmaps, please refer to these smalltalks:

Supports variable-resolver Directive

Now in ZK JSP Tags, you can declare variable resolvers in topmost of JSP documents. Then you can use the variables of your resolvers in EL and zscript.

//assume there is a person bean in spring context...
<z:variable-resolver use="org.zkoss.zkplus.spring.DelegatingVariableResolver"/>
...
<z:page>
	<z:label value="${person.address}"/>
	<z:zscript>
		 String A = person.name;
	</z:zscript>
</z:page>

For more detailed information about how to use ZK variable resolver, please refer to the the variable-resolver directive.

Supports ZK Expression Language in JSP

Now, you can use ZK components and zscript variables in EL expressions. For example:

<%@ taglib uri="http://www.zkoss.org/jsp/zul" prefix="z" %>
<%@ taglib uri="http://www.zkoss.org/dsp/web/core" prefix="zfunc" %>
...

<z:page id="eltests">
	<p>${zfunc:encodeURL("el.jsp")}</p>
	<z:zscript>
		 String A = "This is page scope str A";
	</z:zscript>
	<z:window id="myWin">
		<z:zscript>
			 String A = "This is myWin's A";
		</z:zscript>
		<z:label value="${A}"/>
		<z:label value="${self.title}"/>
	</z:window>
	<z:label value="${A}"/>
	<z:label value="${myWin.id}'s title is: ${myWin.title}"/>
</z:page>
...

As you can see, the behaviors of ZK variable resolving are the same as pure ZK. For more detailed information, please refer to the ZK JSP Tags User Guide.

Use ZK in JSP Document

To use ZK JSP Tags in JSP document is very easy. In JSP, ZK is a normal JSP tag library. So first, you must declare a taglib definition:

<%@ taglib uri="http://www.zkoss.org/jsp/zul" prefix="zk" %>
...

The URL must be http://www.zkoss.org/jsp/zul. It is the key to access correct ZK library.


In ZK world, every ZK components must be contained by a Desktop instance. It will manage the Ajax connections of each component. In JSP, you have to specify a <zk:page> tag to initialize the Desktop instance if it's not existed:

<%@ taglib uri="http://www.zkoss.org/jsp/zul" prefix="zk" %>
...
<zk:page zscriptlanguage="java" >
...
// The ZK Component Tags declaration Area...
...
</zk:page>
// Wrong place to put ZK Component Tags...


And remember, all ZK JSP tag instances you declared must be rooted in a ZK page tag.


Finally, you can start to write ZK JSP tags you want. The usage of how to use all the features in ZK JSP is in [Small_Talks/2008/April/New_Features_of_ZK_JSP_Tags_1.2.0| ZK JSP Tags User Guide]]. Here is a sample:

<%@ taglib uri="http://www.zkoss.org/jsp/zul" prefix="zk" %>
...
<zk:page zscriptlanguage="java" >
...
<zk:window title="My First Window" border="normal" width="200px">
	<zk:label id="labl" value="Hello, World!"/>
		<zk:button label="click me!"  onClick="labl.value='Hello ZK!'" />
</zk:window>
...
</zk:page>

Compare to pure ZK:

<window title="My First Window" border="normal" width="200px">
	<label id="labl" value="Hello, World!"/>
		<button label="click me!"  onClick='labl.value="Hello ZK!"' />
</window>

Both the result will looked like this.

Qs.png

Unsupported features in ZK JSP

Although ZK JSP almost supports all the features from pure ZK in this version, still there are some unsupported features:

  • "fufill" Attribute
  • <?xel-method?> Directive
  • <?evaluator?> Directive


Summary

ZK JSP Tags is a JSP Tag library that provides you a painless and powerfull solution to migrate your existent JSP web site to Ajax application. It implements all ZK components, almost all ZK features and supported all browsers. I hope you enjoy this release and give us feedbacks. Thank you.




Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.