-
FEATURED COMPONENTS
First time here? Check out the FAQ!
So if I have a Composer1.java for a window component in one.zul and a Composer2.java for another window in two.zul.
two.zul is <include>d in one.zul.
Is there some kind of way for Composer1.java to communicate with Composer2.java? That way, I can avoid having to make multiple getFellow commands. Or would I have the two windows use one composer even though they may have different contents? I hope someone can shed some light on this.
The way that Matze2 show is the best that i know and it's a clear JAVA way.
It's interesting to know why so many guys begin with 'include' instead of Exectutions.createComp...
composer1.java
public class Composer1 extends GenericForwardComposer { protected Textbox txtb_Name; // autowired component // attached Controllers private Composer2 composer2; . . . public void doClickOpenWindow2(){ // Store THIS controller in a MAP and overhanded it to the new opened controller HashMap<String, Object> map = new HashMap<String, Object>(); map.put("ModuleMainController", this); Executions.createComponents("/pages/composer2win.zul", parent, map ) } . . . // +++++++++++++++++++++++++++++++++++++++++++++++++ // // ++++++++++++++++ Setter/Getter ++++++++++++++++++ // // +++++++++++++++++++++++++++++++++++++++++++++++++ // public Composer2 getComposer2() { return composer2; } public void setComposer2(Composer2 composer2) { this.composer2 = composer2; }
.
composer2.java
public class Composer2 extends GenericForwardComposer { // attached Controllers private Composer1 composer1; . . . public void afterCompose(){ . . . // Read BACK the parent Controller for having access to it. if (arg.containsKey("ModuleMainController")) { setComposer1((Composer1) arg.get("ModuleMainController")); // Set THIS controller BACK TO THE MainController getComposer1().setComposer2(this); . . . } } /** * Change NOW the value of a textbox that is declared in an other window/controller. * Works DIRECTLY ! * Equal if this composer is opended as a modal window. * (A zk modal window is only a fantastic magical visual illusion. Because it's in the same DOM) */ public void modifyTextbox(){ getComposer1().textb_Name.setValue("new Value set from Composer2"); } . . . // +++++++++++++++++++++++++++++++++++++++++++++++++ // // ++++++++++++++++ Setter/Getter ++++++++++++++++++ // // +++++++++++++++++++++++++++++++++++++++++++++++++ // public Composer1 getComposer1() { return composer1; } public void setComposer1(Composer1 composer1) { this.composer1 = composer1; }
best
Stephan
:-)
Yeah,
so i came from the desktop app world, i mean the simulation of modal wins in zk or even javaScript is absolut fantastic and a 'real feeling' .
best
Stephan
Asked: 2010-11-02 13:46:19 +0800
Seen: 1,876 times
Last updated: Nov 10 '10