0

How to pass parameters to new component using executions.createcomponents

asked 2010-09-07 00:53:36 +0800

enricoge gravatar image enricoge
27 1 1

I tried to create a new component passing a map but the when i get the arg map it is empty.

delete flag offensive retag edit

19 Replies

Sort by ยป oldest newest

answered 2010-09-07 02:06:02 +0800

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

Please show us the code.

link publish delete flag offensive edit

answered 2010-09-07 02:25:13 +0800

enricoge gravatar image enricoge
27 1 1

updated 2010-09-07 02:27:09 +0800

I have to send to the new modal dialog a parameter ( the username of the logged in user)


Code of the main controller :

public void onClick$bNewTestList(Event event)
throws SuspendNotAllowedException, InterruptedException, ClassNotFoundException, SQLException, NamingException {
HashMap map = new HashMap<String, String>();
String username = ((Label)page.getFellow("lUsername")).getValue();
map.put("username", username);


final Window dialog = (Window) Executions.createComponents( "WindowNewTestList.zul",null , map);
dialog.doModal();

...........................


The controller code of the new component :


....................

public void onClick$bSaveTL (Event event) throws NamingException, SQLException {
String username = (String)execution.getArg().get("username"); <<<----- here the arg map is empty !!!

TestList testList = new TestList();
testList.setTL_CREATOR(username);
testList.setTL_NAME(tTestListName.getValue());
testList.setTL_DESCRIPTION(tTestListDescription.getValue());
TestListDAO testListDAO= new TestListDAO();
testListDAO.addTestList(testList);
self.detach();
}

.....................

link publish delete flag offensive edit

answered 2010-09-07 02:47:24 +0800

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

updated 2010-09-07 02:47:48 +0800

catch it in the afterCompose method of the modal window

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

		if (arg.containsKey("username ")) {
			String s =  (String) arg.get("username"));
                        .  .  .

link publish delete flag offensive edit

answered 2010-09-07 03:13:50 +0800

enricoge gravatar image enricoge
27 1 1

OK. It works.

Thank you

link publish delete flag offensive edit

answered 2011-03-25 19:31:27 +0800

obrand69 gravatar image obrand69
21

Terry,

Pardon my ignorance, where do you get the args from in the doAfterCompose?
When I call from one of my composer:

Window win = (Window) Executions.createComponents("/adduser.zul", userManagementWindow,
null);

win.setMaximizable(true);
try {
win.doModal();
} catch (SuspendNotAllowedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

And passing some arguments to this new zul page. How would I retrieve the arguments in the doAfterCompose of the new page?

Thanks in advance

Olivier

link publish delete flag offensive edit

answered 2011-03-25 23:15:27 +0800

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

If you call super.doAfterCompose( comp ) from your doAfterCompose(...) in a GenericForwardComposer, the args variable is autowired for you. So, it will have all the values passed as the 3rd argument to Executions.createComponents(...).

link publish delete flag offensive edit

answered 2011-03-26 06:49:26 +0800

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

like Cary said you can see the code in the GenericAutowireComposer from which the GenericForwardComposer inherits.

abstract public class GenericAutowireComposer extends GenericComposer
implements ComponentCloneListener, ComponentActivationListener {
	private static final long serialVersionUID = 20091006115726L;
	private static final String COMPOSER_CLONE = "COMPOSER_CLONE";

       . . .

	protected transient Map arg;
	/** Implicit Object; the param argument passed from the http request.
	 * @since 3.6.1
	 */

       . . .

.
It's the same as you do it manually like this

public class MyDialogCtrl extends GenericAutowireComposer implements Serializable {
       . . .

	public void onCreate$myDialogWindow(Event event) throws Exception {

		CreateEvent ce = (CreateEvent) ((ForwardEvent) event).getOrigin();
		Map<Object, Object> arg =   ce.getArg();
               . . .

link publish delete flag offensive edit

answered 2012-05-09 09:01:46 +0800

saius gravatar image saius
45

please, i have the same problem. i want to retrieve from a lististem template of "Product" an object "Product" and give it to a modal window to update it but i don't understand the mechanism. please, give an entire code to help me

link publish delete flag offensive edit

answered 2012-05-09 09:09:10 +0800

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

look here

link publish delete flag offensive edit

answered 2012-05-09 15:18:04 +0800

saius gravatar image saius
45

Please,i've already apply a bind composer and a view model to my first zul page.so I write code java in my first zul page to call modal window.but in the composer of my modal window,how I retrieve map "arg" .in the method after compose of the link you gave me,where does come from "arg". How to instantiate it to retrieve map.

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-09-07 00:53:36 +0800

Seen: 4,856 times

Last updated: Dec 27 '12

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