-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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
have you tried a simple onCreate method:
public void onCreate(Event event) { .... }
I *think* that's fired, but can't remember for sure...
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
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
Asked: 2010-07-08 09:42:59 +0800
Seen: 269 times
Last updated: Jul 09 '10