当前位置: 代码迷 >> JavaScript >> 施用zk-JspTags练习zkdemo的例子1
  详细解决方案

施用zk-JspTags练习zkdemo的例子1

热度:350   发布时间:2012-11-07 09:56:10.0
使用zk-JspTags练习zkdemo的例子1
web.xml
<?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[zkproject]]></description>
	<display-name>zkproject</display-name>
	
	<!-- ZK -->
	<listener>
		<description>ZK listener for cleanup when a session is destroyed</description>
		<listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
	</listener>
	<listener>
		<description>
		Used to cleanup when a session is destroyed</description>
		<display-name>
		ZK Session Cleaner</display-name>
		<listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
	</listener>
	<listener>
		<description>ZK JspTags EL environment initiation </description>
		<display-name>ZK Jsp Factory initiator</display-name>
		<listener-class>org.zkoss.jsp.spec.JspFactoryContextListener</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>
		<!-- Must. Specifies URI of the update engine (DHtmlUpdateServlet).
		It must be the same as <url-pattern> for the update engine.
		-->
		<init-param>
			<param-name>update-uri</param-name>
			<param-value>/zkau</param-value>
		</init-param>
		<!-- Optional. Specifies the default log level: OFF, ERROR, WARNING,
			INFO, DEBUG and FINER. If not specified, the system default is used.
		<init-param>
			<param-name>log-level</param-name>
			<param-value>OFF</param-value>
		</init-param>
		-->
		<load-on-startup>1</load-on-startup><!-- Must -->
	</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-mapping>
		<servlet-name>zkLoader</servlet-name>
		<url-pattern>*.zxml</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>
		<description>
		The servlet loads the DSP pages.</description>
		<servlet-name>dspLoader</servlet-name>
		<servlet-class>
		org.zkoss.web.servlet.dsp.InterpreterServlet</servlet-class>
	</servlet>
	
	<servlet-mapping>
		<servlet-name>auEngine</servlet-name>
		<url-pattern>/zkau/*</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>dspLoader</servlet-name>
		<url-pattern>*.dsp</url-pattern>
	</servlet-mapping>



	<!-- Uncomment if you want to use the ZK filter to post process the HTML output
	generated by other technology, such as JSP and velocity.
	<filter>
		<filter-name>zkFilter</filter-name>
		<filter-class>org.zkoss.zk.ui.http.DHtmlLayoutFilter</filter-class>
		<init-param>
			<param-name>extension</param-name>
			<param-value>html</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>zkFilter</filter-name>
		<url-pattern>/test/filter.dsp</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>zkFilter</filter-name>
		<url-pattern>/test/filter2.dsp</url-pattern>
	</filter-mapping>
	-->

	<!-- ///////////// -->
	<!-- DSP (optional) -->
	<!-- Uncomment if you want to use Potix DSP in your Website
	<servlet>
		<servlet-name>dspLoader</servlet-name>
		<servlet-class>org.zkoss.web.servlet.dsp.InterpreterServlet</servlet-class>
		<init-param>
			<param-name>class-resource</param-name>
			<param-value>true</param-value>
		</init-param>
	</servlet>
	<servlet-mapping>
		<servlet-name>dspLoader</servlet-name>
		<url-pattern>*.dsp</url-pattern>
	</servlet-mapping>
	-->

	<!-- /////////// -->
	<!-- Miscellaneous -->
	<session-config>
		<session-timeout>120</session-timeout>
	</session-config>

	<!-- MIME mapping -->
	<mime-mapping>
		<extension>doc</extension>
		<mime-type>application/vnd.ms-word</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>gif</extension>
		<mime-type>image/gif</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>htm</extension>
		<mime-type>text/html</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>html</extension>
		<mime-type>text/html</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>jad</extension>
		<mime-type>text/vnd.sun.j2me.app-descriptor</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>jnlp</extension>
		<mime-type>application/x-java-jnlp-file</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>jpeg</extension>
		<mime-type>image/jpeg</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>jpg</extension>
		<mime-type>image/jpeg</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>js</extension>
		<mime-type>application/x-javascript</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>pdf</extension>
		<mime-type>application/pdf</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>png</extension>
		<mime-type>image/png</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>rar</extension>
		<mime-type>application/x-rar-compressed</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>txt</extension>
		<mime-type>text/plain</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>xls</extension>
		<mime-type>application/vnd.ms-excel</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>xml</extension>
		<mime-type>text/xml</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>xul</extension>
		<mime-type>application/vnd.mozilla.xul-xml</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>zhtml</extension>
		<mime-type>text/html</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>zip</extension>
		<mime-type>application/x-zip</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>zul</extension>
		<mime-type>text/html</mime-type>
	</mime-mapping>
	
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

main.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.zkoss.org/jsp/zul" prefix="z"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>ZK Live Demo</title>
  </head>
  
  <body>
  	<div>
  		<ul>
  			<li><a href="zk_HelloWorld.jsp">Hello World</a></li>
  			<li><a href="zk_VariousForm.jsp">Various Form</a></li>
  		</ul>
  	</div>
  </body>
</html>

zk_HelloWorld.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.zkoss.org/jsp/zul" prefix="z"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title></title>
    

  </head>
  
  <body>
    <z:page>
  		<z:window title="我的第一个窗口" border="normal" width="200px">
  			Hello, World!
  		</z:window>
  	</z:page>
  </body>
</html>

zk_VariousForm.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.zkoss.org/jsp/zul" prefix="z"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Various Form</title>
  </head>
  
  <body>
    <z:page>
    	<z:window width="600">
    	<z:grid fixedLayout="true">
    		<z:columns sizable="false">
    			<z:column label="Types" width="150px"/>
    			<z:column label="Content"/>
    		</z:columns>
    		<z:rows>
    			<z:row>
    				<z:label value="UserName" width="150px" />
    				<z:textbox value="Jerry" width="150px"/>
    			</z:row>
    			<z:row> 
    				Password 
    				<z:textbox type="password" value="123456789" width="150px"/>
    			</z:row>
    			<z:row>
    				Re-type Password
    				<z:textbox type="password" value="123456789" width="150px"/>
    			</z:row>
    			<z:row>
    				Age
    				<z:intbox value="19" constraint="no negative,no zero" width="150px"/>
    			</z:row>
    			<z:row>
    				Phone
    				<z:intbox value="12345678" constraint="no negative,no zero" width="150px"/>
    			</z:row>
    			<z:row>
    				Weight
    				<z:decimalbox value="154.32" format="###.##" width="150px"/>
    			</z:row>
    			<z:row>
    				Birthday
    				<z:hbox>
    					<z:datebox id="db" width="150px"/>
    					<z:listbox onSelect="db.setFormat(self.selectedItem.value)" mold="select" rows="1">
    						<z:listitem label="Default" value=""/>
    						<z:listitem label="yyyy/MM/dd" value="yyyy/MM/dd"/>
    						<z:listitem label="MM-dd-yy" value="MM-dd-yy"/>
    					</z:listbox>
    				</z:hbox>
    			</z:row>
    			<z:row>
    				Address
    				<z:vbox>
    					<z:textbox width="250px" value="123 W.45 Street,New York,NY 10001"/>
						<z:hbox>
							<z:label value="Zip code:"/>
							<z:intbox constraint="no negative,no zero" width="150px"/>
						</z:hbox>
    				</z:vbox>
    			</z:row>
    			
    			<z:row>
    				E-mail
    				<z:textbox width="150px" value="zk@zkoss.org" constraint="/.+@.+\.[a-z]+/:Please enter an e-mail address"/>
    			</z:row>
    			
    			<z:row>
    				Introduction
    				<z:hbox>
    					<z:textbox id="intro" rows="3" width="250px">
    						<z:attribute name="value">I think ZK is the best!</z:attribute>
    					</z:textbox>
    					<z:vbox>
    						More line:
    						<z:spinner value="3" constraint="no negative,no zero" 
    							onChanging="if (event.value.length() > 0 && Integer.parseInt(event.value) > 0) intro.rows = Integer.parseInt(event.value);" />
    						
    					</z:vbox>
    				</z:hbox>
    			</z:row>
    			
    			<z:row>
    				Validation
    				<z:hbox>
    					<z:vbox>
    						<z:textbox value="qwasdf" width="150px"/>
    						<z:captcha id="cpa" length="6" width="150px" height="50px"/>
    					</z:vbox>
    					<z:vbox>
    						(Case Insensitive)
    						<z:button label="Regenerate" onClick="cpa.randomValue();val.value=cpa.value;"/>
    					</z:vbox>
    				</z:hbox>
    			</z:row>
    			
    		</z:rows>
    	</z:grid>
    	</z:window>
    </z:page>
  </body>
</html>


运行时<z:column label="Types" width="150px"/>
<z:column label="Content"/>
的文字出不来,不知道为什么,知道的朋友请指点一下。