0

Retrieving map from createComponents()

asked 2010-07-08 09:42:59 +0800

SHERKHAN gravatar image SHERKHAN
231 3

Hi all,

I would like retrieving the map in my composer created by createComponents().

For exemple :

Composer1:

public void onClick$button() {
   Map<String, Object> map = new HashMap<String, Object>();
   map.put("test", myObj);
   Executions.createComponents("test.zul", null, map);
}

Composer2(Composer of the test.zul): (What I did to retrieve the map)

public class Composer2 extends GenericForwardComposer {
   
  public void onCreate$myWindow(Event event)
    Object obj = getArgsMap(event).get("test");
}

public Map<String, Object> getArgsMap(Event event) {
    CreateEvent createEvent = (CreateEvent) ((ForwardEvent) event).getOrigin();
    return createEvent.getArg();
}

The problem is : I didn't use window id (for what I want I mustn't ) so onCreate$... is not called...

Thanks for your help,

Regards,

SHERKHAN

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2010-07-08 10:05:58 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

have you tried a simple onCreate method:

 public void onCreate(Event event)
{
    ....
}

I *think* that's fired, but can't remember for sure...

link publish delete flag offensive edit

answered 2010-07-08 10:38:57 +0800

SHERKHAN gravatar image SHERKHAN
231 3

Hi clark,

Thanks for your help, Dominic on IRC zk give me another solution,

public class Composer2 extends GenericForwardComposer {
   
    @Override
    public void doAfterCompose(Component comp) throws Exception {
        super.doAfterCompose(comp);

        Employee employee = (Employee) arg.get("employee");
        init(employee);
    }
}

But I test your example and it WORKS too! I don't know which is the best way...

Thanks for your help,

best regards,

SHERKHAN

link publish delete flag offensive edit

answered 2010-07-08 11:20:31 +0800

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

The best way who works in both cases is to catch the 'args' in the doAfterCompose(). While i have done a little Project without the spring framework for showing a bug i realize that i need a parameter out from the args before the onCreate() is called. So i have refactored my current project for catching the args in the doAfterCompose() method.


	@Override
	public void doAfterCompose(Component window) throws Exception {
		super.doAfterCompose(window);

		/**
		 * Set an 'alias' for this composer name in the zul file for access.<br>
		 * Set the parameter 'recurse' to 'false' to avoid problems with
		 * managing more than one zul-file in one page. Otherwise it would be
		 * overridden and can ends in curious error messages.
		 */
		if (self != null)
			self.setAttribute("controller", this, false);

		// Get the selectedItem from the Mainmodule.
		if (arg.containsKey("mainCustomerController")) {
			this.setCustomerMainCtrl((CustomerMainCtrl) arg.get("mainCustomerController"));
			// SET THIS CONTROLLER TO THE MainController
			this.getCustomerMainCtrl().setCustomerAddressCtrl(this);
			// get the selected obj
			this.setCustomer(getCustomerMainCtrl().getSelectedCustomer());
		} else {
			this.setCustomer(null);
		}
	
}

best
Stephan

link publish delete flag offensive edit

answered 2010-07-09 03:08:46 +0800

SHERKHAN gravatar image SHERKHAN
231 3

Hi Stephan,

Thanks for your explanation, I will use doAfterCompose...

Best regards,

SHERKHAN

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-07-08 09:42:59 +0800

Seen: 269 times

Last updated: Jul 09 '10

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