Processing...

Suggested case list:

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

identify firefox or not in server side

1TonyQ198.203.175.1751nv2qreDec 10, 2011 4:25:04 AMlink

Latest 10 Fiddles :

line-height breaks button alignement

1guest162.158.179.1142j3sh9qApr 6, 2020 9:47:11 AMlink

Autopaging vs PageSize

1guest162.158.94.124bs6vn2Apr 6, 2020 9:12:05 AMlink

Another new ZK fiddle

3rock210502162.158.179.541afp0iqApr 6, 2020 7:58:41 AMlink

Another new ZK fiddle

2rock210502162.158.179.541afp0iqApr 6, 2020 7:56:47 AMlink

Another new ZK fiddle

1rock210502162.158.179.541afp0iqApr 6, 2020 7:53:55 AMlink

Another new ZK fiddle

2rock210502162.158.179.542odmspbApr 6, 2020 7:52:55 AMlink

Another new ZK fiddle

1rock210502162.158.179.542odmspbApr 6, 2020 7:49:47 AMlink

uppercase textbox

2guest141.101.76.1302f0efq3Apr 6, 2020 6:05:07 AMlink

ZK-3516

1JamesChu162.158.178.811btfl4tApr 6, 2020 2:04:54 AMlink

PDF Viewer in ZK using Iframe

1guest141.101.69.1532ojq4irApr 5, 2020 10:03:06 PMlink

CustomGroupsModel expand collapse all

1vsriram92182.156.252.230nb4hk2Feb 17, 2020 5:37:54 PMlink

resources

index.zulzul<zk> <div apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('pkg$.SriListViewModel')"> <button label="Collapse All" onClick="@command('collapseAll')" /> <button label="Expand All" onClick="@command('expandAll')" /> <listbox focus="true" id="processList" onSelect="@command('showResult',listbox= self)" model="@load(vm.processList)"> <listhead sizable="true" children="@load(vm.headerList)"> <template name="children" var="headerName"> <zk> <listheader id="${headerName}" label="@load(headerName)" tooltiptext="@load(headerName)" width="200 px" /> </zk> </template> </listhead> <template name="model:group" var="groupNameList"> <listgroup label="@load(groupNameList)" open="false" onClick="@command('groupCloseAndOpen',listGroup = self.listgroup)" onOpen="@command('toggleGroupOpen',listGroup = self.listgroup)"> </listgroup> </template> <template name="model" var="process"> <listitem> <listcell> <zk> <label tooltiptext="@load(process.processName)" value="@load(process.processName)" /> </zk> </listcell> <listcell> <zk> <label tooltiptext="@load(process.processId)" value="@load(process.processId)" /> </zk> </listcell> </listitem> </template> </listbox> </div> </zk>SriListViewModel.javajavaimport java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; import org.zkoss.bind.BindUtils; import org.zkoss.bind.annotation.AfterCompose; import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.ContextParam; import org.zkoss.bind.annotation.ContextType; import org.zkoss.zk.ui.Component; import org.zkoss.zul.GroupsModel; import org.zkoss.zul.ListModel; import org.zkoss.zul.Listbox; import org.zkoss.zul.Listgroup; import org.zkoss.zul.Listitem; import org.zkoss.zul.impl.GroupsListModel; public class SriListViewModel { private Process selectedProcess; private SGroupModel<Process> processList; private List<String> headerList; private boolean collapse; private void init(){ headerList = new ArrayList<String>(); headerList.add("Process Id"); headerList.add("Process Name"); processList = new SGroupModel<Process>(); processList.addItem("group1", new Process("p1","1")); processList.addItem("group1", new Process("p2","2")); processList.addItem("group1", new Process("p3","3")); processList.addItem("group2", new Process("p4","4")); processList.addItem("group2", new Process("p5","5")); } @AfterCompose public void afterCompose() { init(); } @Command public void showResult(@ContextParam(ContextType.VIEW) final Component comp, @BindingParam("listbox") final Listbox listbox) { System.out.println("showAttemptResult"); BindUtils.postNotifyChange(null, null, SriListViewModel.this, "*"); } /** * Collapse all groups * @param view */ @Command public void collapseAll(@ContextParam(ContextType.VIEW) Component view) { expandCollapseAll(view, false); } /** * Expand all groups * @param view */ @Command public void expandAll(@ContextParam(ContextType.VIEW) Component view) { expandCollapseAll(view, true); } /** * Common logic for Expand All / Collapse All buttons * @param toExpand */ private void expandCollapseAll(Component view, boolean toExpand){ Listbox listBox = (Listbox) view.getFellowIfAny("processList"); List<Listitem> items = listBox.getItems(); for(Listitem item:items) { if (item instanceof Listgroup) { listGroupExpandCollapse((Listgroup) item, toExpand); // ((Listgroup) item).setOpen(toExpand); } } notifyCollapseButton(!toExpand); } /** * To Keep Expand All / Collapse all button in sync with the View * @param toCollapse */ private void notifyCollapseButton(boolean toCollapse){ collapse = toCollapse; BindUtils.postNotifyChange(null, null, SriListViewModel.this, "collapse"); } /** * Invoked when + or - button of group list is clicked in the View */ @Command public void toggleGroupOpen() { notifyCollapseButton(processList.isAllGroupsCollapsed()); } /** * Invoked on clicking over the group name * @param view * @param listGroup */ @Command public void groupCloseAndOpen(@ContextParam(ContextType.VIEW) Component view, @BindingParam("listGroup") final Listgroup listGroup) { boolean open = !listGroup.isOpen(); listGroupExpandCollapse(listGroup, open); toggleGroupOpen(); } /** * List group expand Collapse logic is handled according to the CsdcGroupModel * @param listGroup * @param open */ private void listGroupExpandCollapse(Listgroup listGroup, boolean open){ listGroup.setOpen(open); final ListModel model = listGroup.getListbox().getModel(); if (model!= null && model instanceof GroupsListModel) { int index = processList.getGroupIndex(listGroup.getLabel()); GroupsModel gmodel = ((GroupsListModel) model).getGroupsModel(); if(gmodel instanceof SGroupModel) { SGroupModel sModel = (SGroupModel) gmodel; if (open) { sModel.addOpenGroup(index); } else { sModel.removeOpenGroup(index); } } } } public Process getSelectedProcess() { return selectedProcess; } public void setSelectedProcess(Process selectedProcess) { this.selectedProcess = selectedProcess; } public SGroupModel<Process> getProcessList() { return processList; } public void setProcessList(SGroupModel<Process> processList) { this.processList = processList; } public List<String> getHeaderList() { return headerList; } public void setHeaderList(List<String> headerList) { this.headerList = headerList; } } Process.javajavapublic class Process{ public String processName; public String processId; Process(String processName,String processId ){ this.processId = processId; this.processName = processName; } public String getProcessName() { return processName; } public void setProcessName(String processName) { this.processName = processName; } public String getProcessId() { return processId; } public void setProcessId(String processId) { this.processId = processId; } }SGroupModel.javajava import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.HashMap; import org.zkoss.zul.AbstractGroupsModel; import org.zkoss.zul.event.GroupsDataListener; import org.zkoss.zul.event.GroupsDataEvent; public class SGroupModel<T> extends AbstractGroupsModel<T, Object, Object, T> { private static final long serialVersionUID = 1L; private Map<String, List<T>> multiValueMap; private List<String> groups; private String footerString; private Map<Integer, Double> footerValueMap; private boolean footerFormatString; /** * Field to store group close status */ private Map<String,Boolean> openStatus; public SGroupModel() { this.multiValueMap = new HashMap<String, List<T>>(); this.groups = new ArrayList<>(); this.openStatus = new HashMap<>(); } public int getGroupIndex(String groupLabel) { String groupName = groupLabel.substring(0, groupLabel.lastIndexOf("(")).trim(); return groups.indexOf(groupName); } /** * Returns the child value of the specified group at the specified index. */ public T getChild(int groupIndex, int index) { String groupName = groups.get(groupIndex); return ((List<T>) multiValueMap.get(groupName)).get(index); } public int getChildCount(int groupIndex) { String groupName = groups.get(groupIndex); if (multiValueMap.get(groupName) != null) { return multiValueMap.get(groupName).size(); } return 0; } public boolean isAllGroupsCollapsed(){ return openStatus.values().stream().allMatch(value -> value == false); } /** * Returns the group value at the specified index. */ public Object getGroup(int groupIndex) { if (groupIndex < groups.size()) { return String.format("%s (%d)", groups.get(groupIndex), getChildCount(groupIndex)); } else { return ""; } } /** * Returns the group name at the specified index. */ public String getGroupName(int groupIndex) { return groups.get(groupIndex); } /** * Returns the number of groups. */ public int getGroupCount() { return groups.size(); } public String getGroupfoot(int groupIndex) { if (footerValueMap != null && footerFormatString) { double footerValue = footerValueMap.get(groupIndex); long footerValueInt = (long) footerValue; return String.format(footerString, footerValueInt); } else { return null; } } public boolean hasGroupfoot(int groupIndex) { if (footerValueMap != null) { return true; } else { return false; } } public Map<Integer, Double> getFooterValueMap() { return footerValueMap; } public void setFooterValueMap(Map<Integer, Double> footerValueMap) { this.footerValueMap = footerValueMap; } public String getFooterString() { return footerString; } public void setFooterString(String footerString) { this.footerString = footerString; } public void addItem(String groupName, T data) { if (!groups.contains(groupName)) { groups.add(groupName); openStatus.put(groupName, true); } if(multiValueMap.containsKey(groupName)) { multiValueMap.get(groupName).add(data); }else { List<T> groupList = new ArrayList<T>(); groupList.add(data); multiValueMap.put(groupName, groupList); } } public void removeItem(String groupName, T data) { if(multiValueMap.containsKey(groupName)) { multiValueMap.get(groupName).remove(data); } if (multiValueMap.get(groupName) == null) { removeGroup(groupName); } } public void removeGroup(String groupName) { if (groups.contains(groupName)) { groups.remove(groupName); openStatus.remove(groupName); } multiValueMap.remove(groupName); } /** * Opens the group at the specified index. */ @Override public boolean addOpenGroup(int groupIndex) { return setOpenGroup0(groupIndex, true); } /** * Whether the group is open at the specified index. * * @param groupIndex * @return */ @Override public boolean isGroupOpened(int groupIndex) { return openStatus.get(getGroupName(groupIndex)); } /** * Closes the group at the specified index. * * @param groupIndex * @return */ @Override public boolean removeOpenGroup(int groupIndex) { return setOpenGroup0(groupIndex, false); } private boolean setOpenGroup0(int groupIndex, boolean open) { boolean prevStatus = openStatus.get(getGroupName(groupIndex)); if (prevStatus != open) { openStatus.put(getGroupName(groupIndex), open); fireEvent(GroupsDataEvent.GROUPS_OPENED, groupIndex, -1, -1); return true; } return false; } /** * Returns whether the current selection mode is multiple. */ @Override public boolean isMultiple() { return true; } public Collection<T> getAllChild(int groupIndex) { String groupName = groups.get(groupIndex); return multiValueMap.get(groupName); } public T[] getAllChild(String groupName) { return (T[]) multiValueMap.get(groupName).toArray(); } public List<T> getAllChildCollection(String groupName) { return (List<T>) multiValueMap.get(groupName); } public List<T> getAllChildCollection(int groupIndex) { String groupName = groups.get(groupIndex); return (List<T>) multiValueMap.get(groupName); } public boolean isFooterFormatString() { return footerFormatString; } public void setFooterFormatString(boolean formatString) { this.footerFormatString = formatString; } public Map<String, List<T>> getMultiValueMap() { return multiValueMap; } public void setMultiValueMap(Map<String, List<T>> multiValueMap) { this.multiValueMap = multiValueMap; } }