关闭

zkoss显示各种类型的值

标签: zkosszkoss显示listzkoss显示mapzkoss显示值
440人阅读 评论(0) 收藏 举报
分类:

    在zul页面上显示各种类型的值,包括有int,long,float,double,boolean,char,String,List,Set,Map,Object,List<Object>

    java class:

package com.wit.li.viewmodel;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;


import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.Component;


public class ShowValueViewMode {
private int intValue;
private long longValue;
private double doubleValue;
private float floatValue;
private boolean booleanValue;
private char charValue;
private String stringValue;
private List listValue;
private Set setValue;
private Map<String , String> mapValue;
private UserVo vo;
private List<UserVo> listVo;
private Map<String , UserVo> mapVo;
public int getIntValue() {
return intValue;
}
public long getLongValue() {
return longValue;
}
public double getDoubleValue() {
return doubleValue;
}
public float getFloatValue() {
return floatValue;
}
public boolean isBooleanValue() {
return booleanValue;
}
public char getCharValue() {
return charValue;
}
public String getStringValue() {
return stringValue;
}
public List getListValue() {
return listValue;
}
public Set getSetValue() {
return setValue;
}
public Map<String, String> getMapValue() {
return mapValue;
}
public UserVo getVo() {
return vo;
}
public List<UserVo> getListVo() {
return listVo;
}
public Map<String, UserVo> getMapVo() {
return mapVo;
}


@SuppressWarnings({ "unchecked", "rawtypes" })
@Init
public void init(@ContextParam(ContextType.VIEW) Component view) {
intValue = 100;
longValue = 1000;
doubleValue = 1000.0001;
floatValue = 100.001f;
booleanValue = false;
charValue = 'a';
stringValue = "I'm string";
listValue = new ArrayList();
for (int i = 1; i < 5; i++) {
listValue.add(i + "0000");
}
setValue = new HashSet();
for (int i = 5; i < 10; i++) {
setValue.add(i + "0000");
}
mapValue = new HashMap<String, String>();
for (int i = 10; i < 15; i++) {
mapValue.put(i + "0000", i + "0001");
}
vo = new UserVo("root", "root");
listVo = new ArrayList<UserVo>();
for (int i = 1; i < 5; i++) {
listVo.add(new UserVo("root" + i, "root" + i));
}
mapVo = new HashMap<String , UserVo>();
for (int i = 10; i < 15; i++) {
mapVo.put("root" + i, new UserVo("root" + i, "root" + i));
}
}


}



ZUL代码:

<window  width="100%" title="Box layout" border="normal" apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('com.wit.li.viewmodel.ShowValueViewMode')">
<hbox spacing="0">
<window border="normal">类型名称</window>
<window border="normal">值</window>
</hbox>
<hbox spacing="0">
<window border="normal">int</window>
<window border="normal">${vm.intValue}</window>
</hbox>
<hbox spacing="0">
<window border="normal">long</window>
<window border="normal">${vm.longValue}</window>
</hbox>
<hbox spacing="0">
<window border="normal">float</window>
<window border="normal">${vm.floatValue}</window>
</hbox>
<hbox spacing="0">
<window border="normal">double</window>
<window border="normal">${vm.doubleValue}</window>
</hbox>
<hbox spacing="0">
<window border="normal">boolean</window>
<window border="normal">${vm.booleanValue}</window>
</hbox>
<hbox spacing="0">
<window border="normal">char</window>
<window border="normal">${vm.charValue}</window>
</hbox>
<hbox spacing="0">
<window border="normal">string</window>
<window border="normal">${vm.stringValue}</window>
</hbox>
<listbox id="box" multiple="true" checkmark="true" >
<listitem forEach="${vm.listValue}">
<listcell>${each}</listcell>
</listitem>
</listbox>
<listbox id="setbox" multiple="true" checkmark="true" >
<listitem forEach="${vm.setValue}">
<listcell>${each}</listcell>
</listitem>
</listbox>


<listbox id="mapbox" multiple="true" checkmark="true" >
<listitem forEach="${vm.mapValue}">
<listcell>${each.key}${each.value}</listcell>
</listitem>
</listbox>


<listbox id="vobox" multiple="true" checkmark="true" >
<listitem>
<listcell>${vm.vo.name} : ${vm.vo.password}</listcell>
</listitem>
</listbox>


<listbox id="listvobox" multiple="true" checkmark="true" >
<listitem forEach="${vm.listVo}">
<listcell>${each.name} : ${each.password}</listcell>
</listitem>
</listbox>


<listbox id="mapVobox" multiple="true" checkmark="true" >
<listitem forEach="${vm.mapVo}">
<listcell>${each.key} : ${each.value.name} : ${each.value.password}</listcell>
</listitem>
</listbox>






</window>

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:22490次
    • 积分:369
    • 等级:
    • 排名:千里之外
    • 原创:14篇
    • 转载:8篇
    • 译文:0篇
    • 评论:14条
    文章分类
    最新评论