-
FEATURED COMPONENTS
First time here? Check out the FAQ!
hi there,
I'm developing an application (using just the basics of ZK 5.x) which is going to get bigger soon.
I'm very happy with it, and now I'm trying to figure out how to make components to talk to each other.
I'll try to make it very simple.
Imagine having this as "main window"
<window>
<borderlayout>
<north> menus </north>
<center> complex panels based on menus entries </center>
<south> panel with a listbox </south>
<borderlayout>
</window>
Here the "easy" problem:
I want to call "south-panel-composer" methods from the composers which are in the center (or whereever else).
Think about south-panel-composer as a "global" object I want to access to.
I could use static methods inside south-panel-composer, but I kind of don't like it.
Static methods are pretty much "dirty code" when it comes to test units.
Same thing about "A Global Singleton Class" which contains "pointers" to real objects
(assigned into their "doAfterCompose").
During last two hours I've been reading how to make custom components, but it sounds
a bit too complicated to me right now (well not as complicated as star trek's enterprise,
but my lazy side wants to avoid that for now :))
Any suggestions?
Thanks a lot!
One of my most loved ZK methods is the Executions.createComponents("/myZulFile.zul", parent, paramMap).
in this paramMap you can store all what you need. So you can additionally overhanded your south-panel-composer in this map when you create a new content in the center area.
In this newly created content you can read back and cast the south-panel-composer from the overhanded paramMap and have full access to it.
best
Stephan
Hi,
the other possibility is that one composer stores itself in it's own (top component id is windowEdit) namespace:
comp.setVariable("controller", this, true);
and the other calls it like
((MyController) this.windowEdit.getVariable("controller", true)).myMethod();
Or use "attribute" instead of "variable", since "variables" are deprecated in ZK 5.
BTW. I prefer <include src="" mode="defer" /> instead of Executions.createComponents(...) :-)
Interesting thread :-)
from both mode ->
1) <include src=""/>
and
2) Executions.createComponents(..)
Which
1> faster for loading amount of time, especially on big web-app.
2> Can we cached <include/> which is tag to call *.zul or Executions.createComponents(..) to load minimum of time the *.zul page(s) ??
Anybody who's been measure, please answer..
rgrds,
rk
Hi rizkyk,
I do not know the answers, but ZULs are cached by default. AFAIK the slowdown of loading ZULs is probably not so big, I think a bigger speedup may be reached by:
- avoid using zscript (even construction like onClick="checkbox.visible = false" is a zscript), especially mixing zsript and GenericAutowireComposer
- use native componets when you do not need ZK interactivity (e.g. just display some information)
- and other stuff from http://docs.zkoss.org/wiki/Performance_tip
Asked: 2010-04-22 15:06:33 +0800
Seen: 752 times
Last updated: Aug 02 '10