0

ZK Best Practice on medium/big WebApps

asked 2010-04-22 15:06:33 +0800

LuigiX gravatar image LuigiX
12

updated 2010-04-22 15:07:01 +0800

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!

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2010-04-23 04:45:12 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2010-04-23 04:46:26 +0800

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

link publish delete flag offensive edit

answered 2010-04-26 01:58:07 +0800

xmedeko gravatar image xmedeko
1031 1 16
http://xmedeko.blogspot.c...

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(...) :-)

link publish delete flag offensive edit

answered 2010-04-26 03:27:48 +0800

LuigiX gravatar image LuigiX
12

oh thanks, I like them both.
For now I'm just passing the composer to the other by paramsMap, very clean and testable.
I didn't even consider the other option. I'll give it a try.

link publish delete flag offensive edit

answered 2010-08-02 04:04:01 +0800

rizkyk gravatar image rizkyk
6

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

link publish delete flag offensive edit

answered 2010-08-02 07:17:27 +0800

xmedeko gravatar image xmedeko
1031 1 16
http://xmedeko.blogspot.c...

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

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-04-22 15:06:33 +0800

Seen: 752 times

Last updated: Aug 02 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More