我想通过从dataprovider获取数据,使用zk在列表中显示数据

时间:2015-07-26 08:10:08

标签: listbox zk

我有这些文件,我想在列表中显示数据。

Person.java

package com.person.info;

public class Person {

    private int id;
    private String name;
    private String address;
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    public Person(int id, String name, String address) {
        super();
        this.id = id;
        this.name = name;
        this.address = address;
    }


}

PersonDataProvider.java

package com.person.info;

import java.util.ArrayList;
import java.util.List;

public class PersonDataProvider {
    public  static List<Person> getPerson() {


        List<Person> person=new ArrayList<Person>();
        person.add( new Person(1,"Prabin","Thimi"));
        person.add( new Person(2,"Rabin","Bhaktapur"));

        return person;
    }

}

PersonController.java

package com.person.info;

import java.util.List;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.select.SelectorComposer;

public class PersonController extends SelectorComposer<Component> {

    /**
     *
     */
    private static final long serialVersionUID = 1L;
    List<Person> person = PersonDataProvider.getPerson();



    public List<Person> getPerson()
    {
        return person;

    }

Person.zul

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
    <window title="new page title" border="normal" apply="com.person.info.PersonController">
        <listbox model="${$composer.person}">
            <listhead>
                <listheader label="ID" sort="auto" />
                <listheader label="Name" sort="auto" />
                <listheader label="Address" sort="auto" />


            </listhead>
            <template name="model">
                <listitem>
                    <listcell label="${each.id}" />
                    <listcell label="${each.name}" />
                    <listcell label="${each.address}" />
                </listitem>
            </template>



        </listbox>
    </window>
</zk>

1 个答案:

答案 0 :(得分:0)

Here Zk Listbox 您可以查看zk列表框的删除和填充示例