zk框架之Connecting to Java World

一、EL表达式在页面上被访问到时会被当做server,因此它可以访问下面的:

1、Components by using its id

2、variables defined in zscript

3、隐含对象

 

<window title="EL">

<textbox id="tb" value="${self.parent.title}"/>

${tb.value}

<button label="Enter" if="${not empty param.edit}"/>

<zscript>Date now = new Date();</zscript>

<datebox value="${now]"/>

</window>

 

二、Variable Resolver

 

 

 

 

三、Associate with java method

引用static的方法,如下:

 

package com.jing.zk;

 

import java.util.ArrayList;

import java.util.Collection;

import java.util.List;

 

public class Customer {

private String name;

private String age;

public static Collection<Customer> getAll(String condition){

List<Customer> customerList = new ArrayList<Customer>();

Customer c = new Customer();

c.setName("王京晶");

c.setAge("24");

Customer c1 = new Customer();

c1.setName("王伟");

c1.setAge("23");

customerList.add(c);

customerList.add(c1);

return customerList;

}

 

public String getName() {

return name;

}

 

public void setName(String name) {

this.name = name;

}

 

public String getAge() {

return age;

}

 

public void setAge(String age) {

this.age = age;

}

}

 

zul文件如下:

<?page title="new page title" contentType="text/html;charset=UTF-8"?>

<?xel-method prefix="c" name="getAllCustomers" class="com.jing.zk.Customer"

signature="java.util.Collection  getAll(java.lang.String)"?>

<zk>

<window title="new page title" border="normal">

<listbox >

<listitem label="${ each.name}" forEach="${c:getAllCustomers('*') }"> </listitem>

</listbox>

</window>

</zk>

 

四、Associate with multiple java method

<?page title="new page title" contentType="text/html;charset=UTF-8"?>

<?taglib uri="/WEB-INF/tld/my.tld" prefix="my"?>

<zk>

<window title="new page title" border="normal">

<listbox >

<listitem label="${ each.name}" forEach="${my:getAllCustomers('*') }"> </listitem>

</listbox>

</window>

</zk>

 

其中,my.tld文件如下:

<taglib>

<function>

<name>getAllCustomers</name>

<function-class>com.jing.zk.Customer</function-class>

<function-signature>java.util.Collection  getAll(java.lang.String)</function-signature>

</function>

<!-- any member of functions are allowed -->

</taglib>


你可能感兴趣的:(java,C++,c,框架,zk)