-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am new to ZK. I'd like to explore the idea of using Zk to build UI completely in java, taking advantage of type checking and IDE features. Does anyone do this?
I have some success in creating simple button, label etc. I try to create a table (Listbox). It seems trivial in zul, but I can't get it properly composed in java. In particular, the table has 3 column headers. Only the first column header is shown. The other column headers are missing.
Listbox listbox = new Listbox(); SimpleListModel listModel = new SimpleListModel(data); listbox.setModel(listModel); listhead = new Listhead(); listhead.setParent(listbox); Listheader listheader = new Listheader("ID"); listheader.setParent(listhead); listhead.appendChild(listheader); listheader = new Listheader("First Name"); listheader.setParent(listhead); listhead.appendChild(listheader); listheader = new Listheader("Last Name"); listheader.setParent(listhead); listhead.appendChild(listheader); listbox.appendChild(listhead); this.appendChild(listbox);
Can someone shed some light on this?
You are mixing 2 different ways to get a java-built listbox.
Variant 1.) Using a model and an listitemrender.
Variant 2.) Fill the listbox with javacode - appendChild(Listitem) where Listitem contents the Listcell's
When you remove the model, your listheader should be ok. But you have to fill the listbox with
GUI-Elements (Listitem/Listcell).
With model you need to code a ListitemRenderer.html.
No big thing.
void render(Listitem item, java.lang.Object data) // Renders the data to the specified list item. YourBean yourBean = (YourBean) data; item.appendChild(new Listcell(data.getFirstName()); item.appendChild(new Listcell(data.getLastName()); ...
>> ... completely in java, taking advantage of type checking and IDE features. Does anyone do this?
I know that some people here use java-only.
But (in my opinion) there are a lot of things, that makes the (programmers) life easier with zul:
+ databinding (@,$) including an automatic ListItemrender
+ structured GUI-Code ( indentation, nesting)
+ WYSIWYG with ZK Studio
+ autowired components and events
+ less lines (each set of an attribute is one line in javacode)
+ hot deployment for zul-files (no serverrestart for gui-changes/zscript)
+ VariableResolver (can set directly i.e. the attribute model)
i.e. fill a combobox directly from a spring resource
<combobox id="fromcountry"> <comboitem label="${each.description}" value="${each}" forEach="${countryManager}" /> </combobox>
However, some arguments for java only:
+ better refactoring (checks also the gui-layer)
+ better type checking
++ type checking for new methods/attributes from extended GUI-Components
+ better for very dynamic views
+ easier swing/swt migration
/Robert
Asked: 2008-11-26 21:10:32 +0800
Seen: 731 times
Last updated: Nov 27 '08