Suggested case list:
Using timer to refresh a grid
383guest172.69.33.12125nk0uiMay 7, 2020 7:23:47 AMlinkuser model to move item to another listbox
120guest162.158.193.148d0n3krApr 2, 2020 5:28:28 AMlinkDisabled list item row passed to VM-1981
296fatih123160.83.36.13025nk0uiFeb 13, 2018 4:25:44 PMlinkDisabled list item row passed to VM-1981
295fatih123160.83.36.13025nk0uiFeb 13, 2018 4:25:16 PMlinkDisabled list item row passed to VM-1981
294fatih123160.83.36.13225nk0uiFeb 13, 2018 3:30:44 PMlinkgrid sample with ListModel/RowRenderer
816guest80.82.2.1312vah9ajFeb 21, 2017 11:42:21 AMlinkgrid sample with ListModel/RowRenderer
809guest175.98.113.1622vah9ajJan 26, 2017 9:19:33 AMlinkgrid sample with ListModel/RowRenderer
196guest79.185.142.402vah9ajApr 26, 2014 10:53:57 PMlinkgrid sample with ListModel/RowRenderer
195guest79.185.142.402vah9ajApr 26, 2014 10:53:54 PMlinkgrid sample with ListModel/RowRenderer
194guest79.185.142.402vah9ajApr 26, 2014 10:53:51 PMlinkgrid sample with ListModel/RowRenderer
193guest79.185.142.402vah9ajApr 26, 2014 10:53:48 PMlinkgrid sample with ListModel/RowRenderer
192guest79.185.142.402vah9ajApr 26, 2014 10:53:44 PMlinkgrid sample with ListModel/RowRenderer
191guest79.185.142.402vah9ajApr 26, 2014 10:53:40 PMlinkHierarchy table without using ZK PE/EE
1aaknai151.28.135.2131s871daJul 29, 2013 11:02:46 PMlinkgrid sample with ListModel/RowRenderer
128aaknai151.28.135.2132vah9ajJul 29, 2013 7:20:00 PMlinkuser model to move item to another listbox
1TonyQ114.25.109.94d0n3krApr 21, 2012 10:43:27 AMlinkUsing timer to refresh a grid
1TonyQ220.133.44.3725nk0uiFeb 17, 2012 3:17:34 AMlinkFire a event from child iframe
1TonyQ220.133.44.372eupjotFeb 3, 2012 5:04:52 AMlinkTextbox input restriction sample
1TonyQ72.21.245.2431b3nlr0Dec 20, 2011 10:09:10 AMlinkTest web core taglib in ZUL
1TonyQ198.203.175.175ofqkemDec 17, 2011 3:36:08 AMlinkLatest 10 Fiddles :
constraint binding textbox
3guest172.68.151.16220peldaDec 5, 2025 5:08:19 PMlinkAnother new ZK fiddle
2guest172.68.151.16320peldaDec 5, 2025 5:07:51 PMlinkAnother new ZK fiddle
1guest172.68.151.16220peldaDec 5, 2025 5:07:32 PMlinkAnother new ZK fiddle
1peggypeng172.71.154.99364f4neDec 5, 2025 9:24:31 AMlinktooltip example
2guest104.22.23.13rc1ntoDec 4, 2025 2:23:45 PMlinkAnother new ZK fiddle
1guest172.69.134.2277t7602Dec 4, 2025 1:40:46 PMlinkAnother new ZK fiddle
1peggypeng104.22.17.1802df6e3oDec 4, 2025 8:41:29 AMlinkonClose
1peggypeng172.68.87.248j8kd8aDec 3, 2025 4:10:26 AMlinkAnother new ZK fiddle
1peggypeng172.69.134.2271rm7f4eNov 26, 2025 3:31:24 AMlinkZK-5912-Suggestion
2rebeccalai104.22.20.1442qrmiiuNov 26, 2025 2:07:15 AMlinkIframe detach exception
2hubin183.69.214.1782hm9phoNov 28, 2016 2:18:41 AMlinkresources
index.zulzul<?xml version="1.0" encoding="UTF-8"?>
<?page id="index_page" contentType="text/html;charset=UTF-8"?>
<?link rel="icon" href="favicon.ico" type="image/x-icon"?>
<?link rel="shortcut icon" href="favicon.ico" type="image/x-icon"?>
<zk xmlns:h="http://www.w3.org/1999/xhtml">
<window id="index" 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"
apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('pkg$.IndexViewModel')"
width="100%" height="100%" border="normal" onCreate="@command('initWind')">
<vlayout width="100%" height="100%" vflex="true" hflex="true"
style="overflow:auto;background-color:#F5F5F5;">
<hlayout width="100%" height="51px" hflex="true" style="background-color:#99cccc;">
<image src="/view/zul/images/indexheadfont2.png" width="300px"/>
<div vflex="true" hflex="true" align="right">
<separator spacing="25px"/>
<hlayout>
<image
src="/view/zul/images/exit_net_24.png" tooltiptext="退出登录"
style="cursor:pointer;" onClick="@command('leave')" />
<space spacing="5px"/>
</hlayout>
</div>
</hlayout>
<!-- Iframe -->
<iframe id="body" hflex="true" vflex="true" src="@load(vm.bodySrc)">
</iframe>
</vlayout>
</window>
</zk>IndexViewModel.javajava
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.SuspendNotAllowedException;
import org.zkoss.zk.ui.select.Selectors;
import org.zkoss.zkplus.spring.SpringUtil;
import org.zkoss.zul.Iframe;
import org.zkoss.zul.Window;
import com.kyny.hibernate.entity.sons.Coremenu;
import com.kyny.hibernate.entity.sons.Exam;
import com.kyny.hibernate.entity.sons.Permission;
import com.kyny.hibernate.entity.sons.Question;
import com.kyny.hibernate.entity.sons.Strategy;
import com.kyny.hibernate.entity.sons.User;
import com.kyny.service.ICoremenuService;
import com.kyny.service.IExamService;
import com.kyny.service.IStrategyService;
import com.kyny.service.IUserService;
import com.kyny.tools.DateUtil;
import com.kyny.tools.SystemConstant;
import com.kyny.zk.tools.ZkUtils;
/**
* 首页的绑定器
* @author 张雪松
*
*/
public class IndexViewModel {
/**绑定的数据**/
private String time;//系统显示日期
private String realname;//当前用户真实姓名
private List<Coremenu> menus;//用户可以点击的按钮
private String bodySrc;//页身引用的页面路径
//add by hubin on 2016-8-29
private User user;
/**常量**/
private final String TURNOFF_BTN_IMG = "/view/zul/images/tabbox_close_all.png";
private final String MENU_PAGE = "/index/bg_navigationpage.smvc";
private final String HELP_PAGE = "/index/bg_helppage.smvc";
private final String EDITUSER_ZULPATH = "/view/zul/macro/editUserInfo.zul";
//add by hubin on 2016-5-12
private final String SHOWUSEREXAM_ZULPATH = "/view/zul/macro/macroshowuserexam.zul";
/**Spring Bean**/
private IUserService uService =
(IUserService) SpringUtil.getBean("UserService");
private ICoremenuService cService =
(ICoremenuService) SpringUtil.getBean("CoremenuService");
//add by hubin on 2016-8-29
final private IStrategyService stservice =
(IStrategyService) SpringUtil.getBean("StrategyService");
private final IExamService service =
(IExamService) SpringUtil.getBean("ExamService");
@Command("initWind")
@NotifyChange({"time","realname","turnoffbtn","menus","bodySrc"})
public void initWindow(){
getRealName();//初始化姓名
getCurrentTime();//初始化当前时间
initTargetPage(MENU_PAGE);//初始化导航界面
ZkUtils.setSessionAttribute("userexamdsp", true);
}
//add by hubin on 2016-5-12 如果用户有未结束的考试,弹出提示窗口!
@AfterCompose
public void afterCompose(@ContextParam(ContextType.VIEW) Window win){
/*User user = (User) ZkUtils.getSessionAttribute(SystemConstant.KEY_OF_USER);
if(user != null){
List<Exam> le = this.service.findUserNotEndExam(user,new Date());
//System.out.println(le.size());
if((le!=null) && (le.size() > 0)){
Map param = new HashMap();
param.put("LEXAM", le);
//创建并打开新增的窗体
Window window = (Window) Executions.createComponents(SHOWUSEREXAM_ZULPATH, win, param);
try {
window.doPopup();
} catch (SuspendNotAllowedException e) {
System.out.println(e.getMessage());
//e.printStackTrace();
}
}
}*/
}
/**
* 获取当前系统时间
*/
private void getCurrentTime() {
this.time = DateUtil.getCurrentDate(new SimpleDateFormat(DateUtil.DATETIME_PATTERN), Locale.CHINA);
}
/**
* 时钟timer
*
*/
@Command("getTime")
@NotifyChange({"time"})
public void getNowTime(@ContextParam(ContextType.VIEW) Window win){
getCurrentTime();
//自动检查有无考试 alter by hubin on 2016-8-23
if(user != null && ((Boolean)ZkUtils.getSessionAttribute("userexamdsp")).booleanValue()){
List<Exam> le = this.service.findUserNotEndExam(user,new Date());
//System.out.println(le.size());
if((le!=null) && (le.size() > 0)){
Map param = new HashMap();
param.put("LEXAM", le);
//创建并打开新增的窗体
try {
if(win.getFellow("_11")==null){
}else{
return;
}
} catch (org.zkoss.zk.ui.ComponentNotFoundException e) {
//e.printStackTrace();
//System.out.println(e.getMessage());
Window window = (Window) Executions.createComponents(SHOWUSEREXAM_ZULPATH, win, param);
window.doPopup();
//e.printStackTrace();
}
}
}
}
@Command("leave")
public void leave(){
if(ZkUtils.showQuestion("确定要退出吗?", "提示信息")){
/*Collection<Component> cl = ZkUtils.getCurrentPage().getFellows();
for(Component com:cl){
System.out.println("com="+com);
if(com instanceof Window){
System.out.println("win="+com);
Iframe ifr = (Iframe)com.getFellow("body");
System.out.println("iframe="+ifr);
ifr.invalidate();
ifr.detach();
}
}*/
ZkUtils.getCurrentSession().invalidate();//清空session
ZkUtils.sendRedirect(ZkUtils.getRootUrl()+"/login/bg_gtlgpg.smvc");//重定向到登录页面
}
}
@Command("editUser")
public void editUserInfo(@ContextParam(ContextType.VIEW) Window win){
Map data = new HashMap();
data.put("currentUser", (User)ZkUtils.getSessionAttribute(SystemConstant.KEY_OF_USER));
ZkUtils.popupWindow(EDITUSER_ZULPATH, win, data);
}
/**
* 获取当前用户的真实姓名
*/
@Command("changeName")
@NotifyChange({"realname"})
public void getRealName() {
//alter by hubin on 2016-8-29
this.user = (User) ZkUtils.getSessionAttribute(SystemConstant.KEY_OF_USER);
if(user == null){
ZkUtils.sendRedirect(ZkUtils.getRootUrl()+"/login/bg_gtlgpg.smvc");//重定向到登录页面
return;
}
this.realname = user.getRealname();
}
/**
* 点击首页按钮触发的事件
*/
@Command("tonavigation")
@NotifyChange({"bodySrc"})
public void tonavigation(){
initTargetPage(MENU_PAGE);
}
/**
* 点击帮助文档触发的事件
* @return
*/
@Command("toLookHelp")
@NotifyChange("bodySrc")
public void toHelpPage(){
initTargetPage(HELP_PAGE);
}
/**
* 初始化指定页面页面
*/
private void initTargetPage(String page) {
this.bodySrc = ZkUtils.getRootUrl()+page+"?time="+new Date().getTime();
}
public String getTime() {
return time;
}
public String getRealname() {
return realname;
}
public void setTime(String time) {
this.time = time;
}
public void setRealname(String realname) {
this.realname = realname;
}
public List<Coremenu> getMenus() {
return menus;
}
public void setMenus(List<Coremenu> menus) {
this.menus = menus;
}
public String getBodySrc() {
return bodySrc;
}
public void setBodySrc(String bodySrc) {
this.bodySrc = bodySrc;
}
}