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 :

HTML Template with ZK

1guest162.158.178.2102847gt4Apr 23, 2024 2:39:12 AMlink

zk timeout simplified

1guest172.68.125.1581bp3pf0Apr 22, 2024 5:41:22 PMlink

zk timeout simplified

18guest172.68.125.15885cq6Apr 22, 2024 5:41:16 PMlink

Fileupload accept and other options

14guest141.101.98.164v7e6epApr 22, 2024 3:28:05 PMlink

Fileupload accept and other options

13guest172.70.90.2v7e6epApr 22, 2024 3:19:17 PMlink

Fileupload accept and other options

12guest172.69.195.135v7e6epApr 22, 2024 3:18:32 PMlink

Fileupload accept and other options

11guest172.69.195.198v7e6epApr 22, 2024 3:13:27 PMlink

Fileupload accept and other options

10guest172.71.178.4v7e6epApr 22, 2024 3:09:16 PMlink

Fileupload accept and other options

9guest172.71.178.4v7e6epApr 22, 2024 3:08:38 PMlink

Fileupload accept and other options

8guest172.71.178.5v7e6epApr 22, 2024 3:08:13 PMlink

Load model dynamically on demand

108guest172.69.134.511td4lsnMar 25, 2020 4:17:05 AMlink

resources

index.zulzul<zk> <window title="Load model from DB (simulation)" border="normal" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('pkg$.DBViewModel')"> <grid mold="paging" model1="@load(vm.model)"> <columns> <column label="name"/> <column label="name again"/> </columns> <template name="model"> <row> <label value="@load(each)"/> </row> </template> </grid> <button label="Clear Cache" onClick="@command('clearCache')"/> </window> </zk>DBListModel.javajavaimport java.util.HashMap; import java.util.List; import java.util.Map; import org.zkoss.zul.AbstractListModel; public abstract class DBListModel<T> extends AbstractListModel<T> { private static final long serialVersionUID = 1L; private int chunkSize; private Integer totalSize = null; private Map<Integer, List<T>> chunkCache = new HashMap<Integer, List<T>>(); public DBListModel(int chunkSize) { super(); this.chunkSize = chunkSize; } @Override public T getElementAt(int index) { int chunkIndex = index / chunkSize; List<T> chunkElements = chunkCache.get(chunkIndex); if(chunkElements == null) { chunkElements = loadChunkFromDB(chunkIndex * chunkSize, chunkSize); chunkCache.put(chunkIndex, chunkElements); } return chunkElements.get(index % chunkSize); } @Override public int getSize() { if(totalSize == null) { totalSize = loadTotalSize(); } return totalSize; } public void clearCaches() { totalSize = null; chunkCache.clear(); } protected abstract int loadTotalSize(); protected abstract List<T> loadChunkFromDB(int startIndex, int size); } DBViewModel.javajavaimport java.util.ArrayList; import java.util.List; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.NotifyChange; import org.zkoss.zk.ui.util.Clients; public class DBViewModel { pkg$.DBListModel<String> model; @Init public void init() { model = new pkg$.DBListModel<String>(100) { @Override protected int loadTotalSize() { //in the real app you would call a service and load the count from the DB //SQL could be: SELECT COUNT(name) FROM person_table; return 1350; } @Override protected List<String> loadChunkFromDB(int startIndex, int size) { //in the real app you would call a service and load the chunk of data from the DB //SQL could be: SELECT name FROM person_table LIMIT $size OFFSET $startIndex; Clients.showNotification(String.format("loaded %d elements starting from position %d", size, startIndex)); List<String> results = new ArrayList<String>(size); for(int i = startIndex; i < startIndex + size; i++) { results.add("Name #" + i); } return results; } }; } @Command("clearCache") @NotifyChange("model") public void doClearCache() { model.clearCaches(); } public DBListModel<String> getModel() { return model; } }