事例
<?taglib uri="http://www.zkoss.org/zktools/zktools" prefix="z"?> <window id="loginWin" xmlns:w="client" xmlns:n="native" xmlns="http://www.zkoss.org/2005/zul" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd" use="${z:ctrl('loginController')}" apply="${z:ctrl('loginController2')}"> spring集成 格式化日期 <label value="${z:fmtDate(birthday,'yyyy-MM-dd')}"/> 默认字符串 <label value="${z:defaultStr(name,'未知姓名')}"/> </window>
函数定义
<?xml version="1.0" encoding="UTF-8"?> <taglib> <uri>http://www.zkoss.org/zktools/zktools</uri> <description>字符处理函数</description> <!-- --> <!-- 字符串函数 --> <!-- --> <function> <name>endsWith</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>boolean endsWith(java.lang.String, java.lang.String)</function-signature> <description>检测字符串是否以某字符串结尾</description> </function> <function> <name>endsWithIgnoreCase</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>boolean endsWithIgnoreCase(java.lang.String, java.lang.String)</function-signature> <description>检测字符串是否以某字符串结尾, 忽略大小写</description> </function> <function> <name>startsWith</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>boolean startsWith(java.lang.String, java.lang.String)</function-signature> <description>检测字符串是否以某字符串开始</description> </function> <function> <name>startsWithIgnoreCase</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>boolean startsWithIgnoreCase(java.lang.String, java.lang.String)</function-signature> <description>检测字符串是否以某字符串开始, 忽略大小写</description> </function> <function> <name>abbreviate</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String abbreviate(java.lang.String, int) </function-signature> <description>缩略字符串</description> </function> <function> <name>defaultStr</name> <function-class>org.zkway.zktools.ZkCommonTools</function-class> <function-signature>java.lang.String defualtString(java.lang.String, java.lang.String)</function-signature> <description>如果字符串为null或空设置默认值</description> </function> <function> <name>isAllUpperCase</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>boolean isAllUpperCase(java.lang.String) </function-signature> <description>判断一个字符串是否全部为大写</description> </function> <function> <name>isAllLowerCase</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>boolean isAllLowerCase(java.lang.String) </function-signature> <description>判断一个字符串是否全部为小写</description> </function> <function> <name>isNumericStr</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>boolean isNumeric(java.lang.String) </function-signature> <description>判断一个字符串是否是纯数字字符</description> </function> <function> <name>leftStr</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String left(java.lang.String, int) </function-signature> <description>获取字符串左边指定长度的子字符串</description> </function> <function> <name>rightStr</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String right(java.lang.String, int) </function-signature> <description>获取字符串右边指定长度的子字符串</description> </function> <function> <name>substringBefore</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String substringBefore(java.lang.String, java.lang.String)</function-signature> <description>获取字符串第一个匹配指定分隔符之前的子字符串</description> </function> <function> <name>substringAfter</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String substringAfter(java.lang.String, java.lang.String)</function-signature> <description>获取字符串第一个匹配指定分隔符之后的子字符串</description> </function> <function> <name>substringBeforeLast</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String substringBeforeLast(java.lang.String, java.lang.String) </function-signature> <description>获取字符串最后一个匹配指定分隔符之前的子字符串</description> </function> <function> <name>substringAfterLast</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String substringAfterLast(java.lang.String, java.lang.String) </function-signature> <description>获取字符串最后一个匹配指定分隔符之后的子字符串</description> </function> <function> <name>substringBetween</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String substringBetween(java.lang.String, java.lang.String, java.lang.String)</function-signature> <description>从一个字符串中获取嵌套在两个字符串之间的子字符串</description> </function> <function> <name>leftPadStr</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String leftPad(java.lang.String, int, java.lang.String)</function-signature> <description>使用指定字符串左补丁一个字符串</description> </function> <function> <name>rightPadStr</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String rightPad(java.lang.String, int, java.lang.String)</function-signature> <description>使用指定字符串右补丁一个字符串</description> </function> <function> <name>centerStr</name> <function-class>org.apache.commons.lang.StringUtils</function-class> <function-signature>java.lang.String center(java.lang.String, int, java.lang.String)</function-signature> <description>使用补丁将字符串居中</description> </function> <!-- --> <!-- 获取spring 管理bean --> <!-- --> <function> <name>ctrl</name> <function-class>org.zkway.zktools.ZkCommonTools</function-class> <function-signature>java.lang.Object getController(java.lang.String) </function-signature> <description>获取spring 管理controller</description> </function> <function> <name>comp</name> <function-class>org.zkway.zktools.ZkCommonTools</function-class> <function-signature>java.lang.Object getComponent(java.lang.String) </function-signature> <description>获取spring 管理组件对象</description> </function> <function> <name>bean</name> <function-class>org.zkway.zktools.ZkCommonTools</function-class> <function-signature>java.lang.Object getBean(java.lang.String) </function-signature> <description>获取spring 管理bean对象</description> </function> <!-- --> <!-- 工具函数 --> <!-- --> <function> <name>size</name> <function-class>org.zkway.zktools.ZkCommonTools</function-class> <function-signature>int size(java.lang.Object)</function-signature> <description>获取一个对象的大小</description> </function> <function> <name>length</name> <function-class>org.zkway.zktools.ZkCommonTools</function-class> <function-signature>int size(java.lang.Object)</function-signature> <description>获取一个对象的大小</description> </function> <function> <name>empty</name> <function-class>org.zkway.zktools.ZkCommonTools</function-class> <function-signature>boolean isEmpty(java.lang.Object) </function-signature> <description>判断一个对象是否是空对象</description> </function> <!-- --> <!-- 日期工具函数 --> <!-- --> <function> <name>now</name> <function-class>org.zkway.zktools.ZkCommonTools</function-class> <function-signature>java.util.Date currentTime()</function-signature> <description>获取当前时间</description> </function> <function> <name>today</name> <function-class>org.zkway.zktools.ZkCommonTools</function-class> <function-signature>java.util.Date today(int, int, int) </function-signature> <description>获取今天的日期时间,可以指定今天时分秒,-1表示不设置</description> </function> <function> <name>firstDayOfMonth</name> <function-class>org.zkway.zktools.ZkCommonTools</function-class> <function-signature>java.util.Date firstDayOfMonth() </function-signature> <description>获取当前月的第一天</description> </function> <function> <name>lastDayOfMonth</name> <function-class>org.zkway.zktools.ZkCommonTools</function-class> <function-signature>java.util.Date lastDayOfMonth() </function-signature> <description>获取当前月的最后一天</description> </function> <function> <name>fmtDate</name> <function-class>org.zkway.zktools.ZkCommonTools</function-class> <function-signature>java.lang.String formatDate(java.util.Date,java.lang.String)</function-signature> <description>根据参数指定的模式,格式化给定日期</description> </function> <function> <name>parseDate</name> <function-class>org.zkway.zktools.ZkCommonTools</function-class> <function-signature>java.util.Date parseDate(java.lang.String,java.lang.String)</function-signature> <description>将字符串转换成日期类型</description> </function> </taglib>