0

InterComposer Communication?

asked 2010-11-02 13:46:19 +0800

Tessla gravatar image Tessla
330 2

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.

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2010-11-09 19:48:51 +0800

samchuang gravatar image samchuang
4084 4

Hi

you can refer to http://www.zkoss.org/forum/listComment/12750

link publish delete flag offensive edit

answered 2010-11-10 06:59:25 +0800

Matze2 gravatar image Matze2
773 7

You can also use Executions.createComponents() instead of <include>.
Then you can pass any object from Composer1 as argument to Composer2.

link publish delete flag offensive edit

answered 2010-11-10 07:57:05 +0800

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

updated 2010-11-10 08:15:58 +0800

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

link publish delete flag offensive edit

answered 2010-11-10 10:10:55 +0800

twiegand gravatar image twiegand
1807 3

Stephan,

Your definition of the modal window made me smile! Thanks!

Todd

link publish delete flag offensive edit

answered 2010-11-10 15:28:27 +0800

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

updated 2010-11-10 15:28:49 +0800

:-)

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

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-11-02 13:46:19 +0800

Seen: 1,876 times

Last updated: Nov 10 '10

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