-
FEATURED COMPONENTS
First time here? Check out the FAQ!
After doing some tests I would have to ask a question to the community:
what is the advantage of a programming in "Forward" mode Vs programming "standard"?
By standard I mean: the screen. zul + programming with some controls inside the file. java so no need to "forward" events.
Sorry for the question but I really do not know what is best.
Luca
Please describe standard?
1.) zscript inside the zul file
<button onClick="xy.submit();"/>
+ hot deployment, no restart is required, ideal for prototyping
- needs more memory (=slower) and cpu because it's interpreted by beanshell
- not part of eclipse/netbeans refactoring
- beanshell make some troubles in clusterenvironment (this are userreports, i do not use zscript for productive products)
2. - 5.) Are faster then zscript (1.). There is no performance advantage between this variants.
2.) Swing way (Add events listeners with anonym classes)
I see no advantage for this style. It's the most code and you have some limits inside a anonym class.
+ usefull if you port a swing/swt application to web/zk
+/- you could add eventlisteners to dynamic created UI-Elements (smarter: the ZK Utilclasses)
- most code, needs a onw class
3.) autowired by (name)convention (ForwardComposer or Utilclass)
This is my prefered variant.
<button id="ok"..>
public void onClick$ok(ForwardEvent event)...
+ less code
- don't work for dynamic nested zul's
4.) forward
<button forward="onClick=onSave">
+/- less code the swing-style, but more code than autowired
+ can forward accept a path as target, i.e. onClick=/win.onSave
+ you can foward different events to the some eventhandler (i.e. onClick by Button or onOK from the inputfield to the onSave)
5.) extend UI-Component
<window use="class" onOK="onSave"..>
- no good choise if you working with zul-files, you don't have a java class for each component
+ usefull if you want create own standard UI's i.e. a special textbox for your customernumber ..
My best practice:
I use zscript (Variant 1) only for prototyping or maintanaince-zuls.
I use autowired (Variant 3) whenever it possible.
I use the forward-attribute (variant 4) if autowired not possible i.e.
for dynamic added zul's, extra UI-Events for the same controller-event (i.e. onClick by autowired, onOK by forward)
I only extend UI-Components for creating a new standard UI-Component, i.e. a special bandbox, textbox.
/Robert
Hi Robert,
thanks for your reply. I'm looking for the best way to use zk. Your reply helps me a lot.
Luca
Asked: 2010-12-16 16:38:01 +0800
Seen: 439 times
Last updated: Dec 20 '10