arg - java.util.Map(Refer to ZK:The User Guide)
The arg argument passed to the createComponents method in the
org.zkoss.zk.ui.Executions class. It might be null, depending on how
createComponents is called.
It is the same as self.desktop.execution.arg.
params.put("name", "John");
Executions.createComponents("/my.zul", null, params);
Then, in my.zul,
...
Notice that arg is available only when creating the components for the included page, say
my.zul. On the other hand, all events, including onCreate, are processed later. Thus, if you
want to access arg in the onCreate's listener, use the getArg method of the
org.zkoss.zk.ui.event.CreateEvent class.
Testing code is the below:
In the a.zul composer.
final Map<String, Object> map = new HashMap<String, Object>(0); map.put("userid",detailsUser.getUserName() ); Window changepasswordWin = null; changepasswordWin = (Window) Executions.createComponents( "/admin/change_password.zul", null, map);
In teh b.zul composer.(change_password.zul)
Map<String, Object> args = null; public void onCreate$changePasswordWin(Event e) throws Exception { System.out.println("--ChangePassword changePasswordWin--"); CreateEvent ce = (CreateEvent) ((ForwardEvent) e).getOrigin(); this.args = ce.getArg(); System.out.println("pass userid:" + this.args.get("userid")); //do something //.... System.out.println("--/ChangePassword changePasswordWin--"); }
沒有留言:
張貼留言
留個話吧:)