Processing...

Suggested case list:

Using timer to refresh a grid

383guest172.69.33.12125nk0uiMay 7, 2020 7:23:47 AMlink

user model to move item to another listbox

120guest162.158.193.148d0n3krApr 2, 2020 5:28:28 AMlink

Disabled list item row passed to VM-1981

296fatih123160.83.36.13025nk0uiFeb 13, 2018 4:25:44 PMlink

Disabled list item row passed to VM-1981

295fatih123160.83.36.13025nk0uiFeb 13, 2018 4:25:16 PMlink

Disabled list item row passed to VM-1981

294fatih123160.83.36.13225nk0uiFeb 13, 2018 3:30:44 PMlink

grid sample with ListModel/RowRenderer

816guest80.82.2.1312vah9ajFeb 21, 2017 11:42:21 AMlink

grid sample with ListModel/RowRenderer

809guest175.98.113.1622vah9ajJan 26, 2017 9:19:33 AMlink

grid sample with ListModel/RowRenderer

196guest79.185.142.402vah9ajApr 26, 2014 10:53:57 PMlink

grid sample with ListModel/RowRenderer

195guest79.185.142.402vah9ajApr 26, 2014 10:53:54 PMlink

grid sample with ListModel/RowRenderer

194guest79.185.142.402vah9ajApr 26, 2014 10:53:51 PMlink

grid sample with ListModel/RowRenderer

193guest79.185.142.402vah9ajApr 26, 2014 10:53:48 PMlink

grid sample with ListModel/RowRenderer

192guest79.185.142.402vah9ajApr 26, 2014 10:53:44 PMlink

grid sample with ListModel/RowRenderer

191guest79.185.142.402vah9ajApr 26, 2014 10:53:40 PMlink

Hierarchy table without using ZK PE/EE

1aaknai151.28.135.2131s871daJul 29, 2013 11:02:46 PMlink

grid sample with ListModel/RowRenderer

128aaknai151.28.135.2132vah9ajJul 29, 2013 7:20:00 PMlink

user model to move item to another listbox

1TonyQ114.25.109.94d0n3krApr 21, 2012 10:43:27 AMlink

Using timer to refresh a grid

1TonyQ220.133.44.3725nk0uiFeb 17, 2012 3:17:34 AMlink

Fire a event from child iframe

1TonyQ220.133.44.372eupjotFeb 3, 2012 5:04:52 AMlink

Textbox input restriction sample

1TonyQ72.21.245.2431b3nlr0Dec 20, 2011 10:09:10 AMlink

Test web core taglib in ZUL

1TonyQ198.203.175.175ofqkemDec 17, 2011 3:36:08 AMlink

Latest 10 Fiddles :

constraint binding textbox

3guest172.68.151.16220peldaDec 5, 2025 5:08:19 PMlink

Another new ZK fiddle

2guest172.68.151.16320peldaDec 5, 2025 5:07:51 PMlink

Another new ZK fiddle

1guest172.68.151.16220peldaDec 5, 2025 5:07:32 PMlink

Another new ZK fiddle

1peggypeng172.71.154.99364f4neDec 5, 2025 9:24:31 AMlink

tooltip example

2guest104.22.23.13rc1ntoDec 4, 2025 2:23:45 PMlink

Another new ZK fiddle

1guest172.69.134.2277t7602Dec 4, 2025 1:40:46 PMlink

Another new ZK fiddle

1peggypeng104.22.17.1802df6e3oDec 4, 2025 8:41:29 AMlink

onClose

1peggypeng172.68.87.248j8kd8aDec 3, 2025 4:10:26 AMlink

Another new ZK fiddle

1peggypeng172.69.134.2271rm7f4eNov 26, 2025 3:31:24 AMlink

ZK-5912-Suggestion

2rebeccalai104.22.20.1442qrmiiuNov 26, 2025 2:07:15 AMlink

ZK MVVM focus (js patch)

8guest172.70.85.2053c7chdgNov 5, 2021 12:28:36 PMlink

resources

index.zulzul<zk> <script><![CDATA[ zk.afterLoad('zul.sel,zkmax', function() { var xTree = {}; zk.override(zul.sel.Tree.prototype, xTree, { onResponse : function() { var shallSyncFocus = this._shallSyncFocus; xTree.onResponse.apply(this, arguments); // call original method if(this._focusItem && shallSyncFocus === true) { this._syncFocus(this._focusItem); // restore focus anchor position } } });//zk.override });//zk.afterLoad ]]></script> <hlayout width="100%"> <div viewModel="@id('vm')@init('pkg$.FocusViewModel')" hflex="1"> <button label="add row" onClick="@command('addRow')"/> <listbox checkmark="true" model="@load(vm.listModel)" selectedItems="@bind(vm.selectedItems)" height="200px"> <template name="model"> <apply template="listitem1" /> </template> </listbox> </div> <space width="20px" /> <div viewModel="@id('vm')@init('pkg$.FocusViewModel2')" hflex="1"> <button disabled="true" label="@load(empty vm.selectedItem ? 'empty selection' : 'selected: ' .concat(vm.selectedItem))" /> <listbox checkmark="true" model="@load(vm.listModel)" selectedItem="@bind(vm.selectedItem)" height="200px" > <template name="model"> <apply template="listitem2" /> </template> </listbox> <listbox > </listbox> </div> <space width="20px"/> <div viewModel="@id('vm')@init('pkg$.TreeVM')" hflex="1"> <button disabled="true" label="@load(empty vm.selectedItems ? 'empty selection' : 'selected: ' .concat(vm.selectedItems.iterator().next()))" /> <tree height="200px" model="@load(vm.model)" selectedItems="@bind(vm.selectedItems)" checkmark="true"> <template name="model"> <treeitem focus="@load(vm.isItemSelected(each))"> <treerow> <treecell label="@load(each)" /> </treerow> </treeitem> </template> </tree> </div> <template name="listitem1"> <listitem focus="@load(vm.isItemSelected(each))" draggable="true" droppable="@load(self.draggable)" onDrop="@command('drop')"> <apply template="listcell11" /> <apply template="listcell12" /> </listitem> </template> <template name="listcell11"> <apply template="listcell21" /> </template> <template name="listcell12"> <listcell label="@load(vm.isItemSelected(each))"/> </template> <template name="listitem2"> <listitem focus="@load(vm.isItemSelected(each))" draggable="true" droppable="@load(self.draggable)" onDrop="@command('drop')"> <listcell label="@load(each)"/> </listitem> </template> <template name="listcell21"> <listcell label="@load(each)"/> </template> </hlayout> </zk>FocusViewModel.javajavaimport org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.GlobalCommand; import org.zkoss.bind.BindUtils; import org.zkoss.bind.annotation.Init; import org.zkoss.zul.ListModelList; import java.util.*; public class FocusViewModel { private ListModelList<MyBean> listModel; private Set<MyBean> selectedItems = new HashSet<>(); @Init public void init() { listModel = new ListModelList<MyBean>(); listModel.setMultiple(true); for (int i=1; i < 40 ; i++) { listModel.add(new MyBean("left-item-" + i, i)); } selectedItems.clear(); } @GlobalCommand public void refreshModel() { org.zkoss.zul.Messagebox.show("refreshing left model"); Set<MyBean> cache = new HashSet<>(selectedItems); init(); // similuate re-load from db selectedItems = cache; // set previous selection BindUtils.postNotifyChange(null, null, this, "selectedItems"); BindUtils.postNotifyChange(null, null, this, "listModel"); } @Command public void addRow() { int index = listModel.size() + 1; MyBean bean = new MyBean("new-left-item-" + index, index); listModel.add(bean); getSelectedItems().clear(); getSelectedItems().add(bean); BindUtils.postGlobalCommand(null, null, "refreshModel2", Collections.emptyMap()); BindUtils.postGlobalCommand(null, null, "refreshTreeModel", Collections.emptyMap()); } @Command public void drop() { } public ListModelList<MyBean> getListModel() { return listModel; } public Set<MyBean> getSelectedItems() { return selectedItems; } public void setSelectedItems(Set<MyBean> set) { selectedItems = set; } public boolean isItemSelected(MyBean bean) { return getSelectedItems().contains(bean); } } MyBean.javajavapublic class MyBean { private String prop1; private int prop3; public MyBean(String prop1, int index) { super(); this.prop1 = prop1; this.prop3 = index; } public String getProp1() { return prop1; } public void setProp1(String prop1) { this.prop1 = prop1; } public int getProp3() { return prop3; } public void setProp3(int prop3) { this.prop3 = prop3; } public String toString () { return getProp1() + "_" + hashCode(); } public boolean equals(Object other) { if (this == other) return true; if (other == null || getClass() != other.getClass()) return false; return prop3 == ((MyBean) other).getProp3(); } @Override public int hashCode() { return java.util.Objects.hash(getProp1(), getProp3()); } } FocusViewModel2.javajavaimport org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.GlobalCommand; import org.zkoss.bind.annotation.Init; import org.zkoss.bind.BindUtils; import org.zkoss.zul.ListModelList; import java.util.*; public class FocusViewModel2 { private ListModelList<MyBean> listModel; private MyBean selectedItem = null; @Init public void focusVMInit() { init(); selectedItem = listModel.get(13); } public void init() { listModel = new ListModelList<MyBean>(); listModel.setMultiple(false); for (int i=1; i < 40 ; i++) { listModel.add(new MyBean("right-item-" + i, i)); } } @GlobalCommand public void refreshModel2() { //org.zkoss.zul.Messagebox.show("refreshing right model"); MyBean cache = selectedItem; init(); // similuate re-load from db //org.zkoss.zul.Messagebox.show("right model refreshed"); BindUtils.postNotifyChange(null, null, this, "listModel"); //org.zkoss.zul.Messagebox.show("listModel notfied"); setSelectedItem(cache); // set previous selection BindUtils.postNotifyChange(null, null, this, "selectedItem"); //org.zkoss.zul.Messagebox.show("right model refreshed. listModel notfied. selectedItem notfied. selected " + (getSelectedItem() != null ? getSelectedItem().getProp1() : " nothing")); } @Command public void drop() { } public ListModelList<MyBean> getListModel() { return listModel; } public MyBean getSelectedItem() { return selectedItem; } public void setSelectedItem(MyBean bean) { selectedItem = bean; } public boolean isItemSelected(MyBean bean) { return bean.equals(getSelectedItem()); } } FooNode.javajavaimport java.util.ArrayList; import java.util.Collections; import java.util.List; public class FooNode { private FooNode _parent; private List<FooNode> _children; private int _index; private String _label = ""; public FooNode (FooNode parent, int index, String label) { _parent = parent; _index = index; _label = label; } public void setParent (FooNode parent) { _parent = parent; } public FooNode getParent () { return _parent; } public void appendChild (FooNode child) { if (_children == null) _children = new ArrayList(); _children.add(child); } public List<FooNode> getChildren () { if (_children == null) return Collections.EMPTY_LIST; return _children; } public void setIndex (int index) { _index = index; } public int getIndex () { return _index; } public String getLabel () { return _label; } public String toString () { return getLabel() + "_" + hashCode(); } public boolean equals(Object other) { if (this == other) return true; if (other == null || getClass() != other.getClass()) return false; return java.util.Objects.equals(getIndex(), ((FooNode) other).getIndex()) && java.util.Objects.equals(getLabel(), ((FooNode) other).getLabel()) && java.util.Objects.equals(getParent(), ((FooNode) other).getParent()); } @Override public int hashCode() { return java.util.Objects.hash(getIndex(), getLabel(), getParent()); } } FooModel.javajava import java.util.List; import org.zkoss.zul.AbstractTreeModel; public class FooModel extends AbstractTreeModel<Object> { private FooNode _root; public FooModel(Object root) { // set the root super(root); _root = (FooNode)root; setMultiple(true); } public boolean isLeaf(Object node) { return ((FooNode)node).getChildren().size() == 0; //at most 4 levels } public Object getChild(Object parent, int index) { return ((FooNode)parent).getChildren().get(index); } public int getChildCount(Object parent) { return ((FooNode)parent).getChildren().size(); //each node has 5 children } public int getIndexOfChild(Object parent, Object child) { List<FooNode> children = ((FooNode)parent).getChildren(); for (int i = 0; i < children.size(); i++) { if (children.get(i).equals(children)) return i; } return -1; } };TreeVM.javajavaimport org.zkoss.zk.ui.*; import org.zkoss.zk.ui.event.*; import org.zkoss.zk.ui.util.*; import org.zkoss.zk.ui.ext.*; import org.zkoss.zk.au.*; import org.zkoss.zk.au.out.*; import org.zkoss.zul.*; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.GlobalCommand; import org.zkoss.bind.annotation.Init; import org.zkoss.bind.BindUtils; import java.util.*; public class TreeVM { FooNode root; FooModel _model; Set<FooNode> selectedItems = new HashSet<>(); private void init(boolean sel) { selectedItems = new HashSet<>(); root = new FooNode(null, 0, ""); _model = new FooModel(root); for (int i = 0; i < 21; i++) { FooNode firstLevelNode = new FooNode(root, i, "first - " + i); for (int j = 0; j <= i; j++) { FooNode secondLevelNode = new FooNode(firstLevelNode, j, "second - " + j); firstLevelNode.appendChild(secondLevelNode); } root.appendChild(firstLevelNode); if (sel && i == 15) { getSelectedItems().add(firstLevelNode); BindUtils.postNotifyChange(null, null, this, "selectedItems"); } } } public FooModel getModel() { if (_model == null) { init(true); } return _model; } private FooNode getFooRoot() { return root; } public Set<FooNode> getSelectedItems() { return selectedItems; } public void setSelectedItems(Set<FooNode> items) { selectedItems = items; } public boolean isItemSelected(FooNode node) { return getSelectedItems().contains(node); } @GlobalCommand public void refreshTreeModel() { //org.zkoss.zul.Messagebox.show("refreshing tree model"); Set<FooNode> cache = new HashSet<>(getSelectedItems()); init(false); // similuate re-load from db //org.zkoss.zul.Messagebox.show("tree model refreshed"); BindUtils.postNotifyChange(null, null, this, "model"); //org.zkoss.zul.Messagebox.show("treeModel notfied"); setSelectedItems(cache); // set previous selection BindUtils.postNotifyChange(null, null, this, "selectedItems"); } }