0

How pass parameters between zul??

asked 2011-06-06 18:18:09 +0800

zippy gravatar image zippy
504 1 2

Hi, i tried to pass parameters between zul`s .In the main controller i have a modal window
main->modal->main

private Map<String, String> arg;
Window dialog = (Window) Executions.createComponents( "mainzul.zul",null , this.arg);

In the modal window i tried to set parameters into the attributes of the main window and the map args.

this.dialog.getParent().setAttribute("param", "a");

In the modal window i have doaftercompose with

super.doAfterCompose(comp);


Need help!!

Thanks :)

delete flag offensive retag edit

9 Replies

Sort by ยป oldest newest

answered 2011-06-06 19:42:42 +0800

Fujitsu gravatar image Fujitsu
117 2

We created our own Window component which extends the ZK's Window:

public calls MyWindow extends Window

And within this class we have a member called inputParameters, which is a hashmap:

private Map<String, Object>                       inputParameters = new HashMap<String, Object>();

And of course we defined MyWindow in the lang-addon.xml, so we can use it in the zul files:

  <component>
    <component-name>mywindow</component-name>
    <extends>window</extends>
    <component-class>com.project.components.MyWindow</component-class>
    <property>
      <property-name>border</property-name>
      <property-value>none</property-value>
    </property>
    <property>
      <property-name>width</property-name>
      <property-value>100%</property-value>
    </property>
  </component>

And to use in the Zuls:

  <fwwindow id="${arg.windowId}"
      inputParameters="${arg.inputParameters}"
      screenName="Maintain Trip"
      apply="com.project.screens.trip.maintain.TripMaintainController"
      width="100%" height="100%" >

All our controllers extend our MyController class:

public class TripMaintainController extends MyController<TripMaintainBeans>

Then in MyController:

  public void doAfterCompose( Component comp ) throws Exception
  {
    ....
      // populate the bean group with any input parameters
      Map<String, Object> inputParams = window.getInputParameters();
      if (inputParams != null && inputParams.size() > 0)
      {
        beanGroup.populateProperties(inputParams);
      }

      binder = new MyDataBinder(window);
      bindBeans();
      binder.loadAll();
  }

populateProperties uses reflection and annotations to populate the beans for that screen.

Hopefully this gives you some ideas on how to do it.

link publish delete flag offensive edit

answered 2011-06-07 07:26:05 +0800

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

Implicit Objects - arg

If you have a GFC applied to the component and call super.doAfterCompose(comp);, the variable args is available.

link publish delete flag offensive edit

answered 2011-06-07 10:52:34 +0800

zippy gravatar image zippy
504 1 2

updated 2011-06-07 11:08:36 +0800

Hi, thanks :)
I can pass parameters into zul in one way mainZul->modalZul
but i need to pass in the other way modalZul -> mainZul

I tried in the modalZul to add parameters in the parent

this.dialog.getParent().setAttribute("name", object);

But in the mainZul i have
Window dialog = (Window) Executions.createComponents( "modalZul.zul",this.winMap ,null);
		
		try {
			dialog.doModal();

but dialog.getAttribute is null (i think so , is a order of instructions)

----
Update

This works xd, the problem is the order of instructions mmmm ....

winMap.getAttribute("name")
have the object

link publish delete flag offensive edit

answered 2011-06-07 10:59:59 +0800

mikelara gravatar image mikelara
144
www.mextisa.com.mx

Hi

why not to use org.zkoss.zk.ui.Sessions object?, that way the variable is used/modified in both windows?...just an idea.

Mike

link publish delete flag offensive edit

answered 2011-06-07 11:12:32 +0800

zippy gravatar image zippy
504 1 2

updated 2011-06-07 15:26:23 +0800

hi, saving the parameter in the attributes of the parent work, but i search for method or event listener type onChange attribute.

Thanks !!
I solved my problem with
Save the parameter in the parent

this.dialog.getParent().setAttribute("name", object);

In the parent, the eventlistener get the attribute.

dialog.addEventListener("onClose",new EventListener() {
				public void onEvent(Event event) {
					logger.info("THE PARAMETER"+winMap.getAttribute("name"));
				}
			});

Booo not solved :S
In the modal window i have a button , i need when the user clicked the window close, but nothing happens, only close when the user clicked the X

link publish delete flag offensive edit

answered 2011-06-07 15:43:18 +0800

zippy gravatar image zippy
504 1 2

updated 2011-06-07 15:43:46 +0800

Hi, i have this code


dialog.doModal();
logger.info("The value"+winMap.getAttribute("name"));

In dialog i set the value.
In the documentation says:

However, it does not suspend the execution. Like the overlapped windows, the execution continues to the next statement once the mode is changed. For example, f1() is called only after win1 is closed, while g() is called immediately after win2 becomes highlighted.

win1.doModal(); //the execution is suspended until win1 is closed

f1();

win2.doHighlighted(); //the execution won't be suspended
g1()

but the execution continue....

link publish delete flag offensive edit

answered 2011-06-07 16:03:40 +0800

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

look in your zk.xml

	<!-- ========================================================== -->
	<!--            Enable event thread for modal windows           -->
	<!-- ========================================================== -->
	<system-config>
		<disable-event-thread>false</disable-event-thread>
	</system-config>

link publish delete flag offensive edit

answered 2011-06-07 17:07:39 +0800

zippy gravatar image zippy
504 1 2

:O

my zk.xml dont have nothing :P

only

<device-config>
<device-type>ajax</device-type>
<timeout-uri></timeout-uri><!-- An empty URL can cause the browser to reload the same URL -->
</device-config>

I will try , thanks

link publish delete flag offensive edit

answered 2011-06-15 15:04:29 +0800

mejiaej gravatar image mejiaej
3

updated 2011-06-17 09:12:54 +0800

Hi zippy,

Did you solved your problem? because i need to do something similar, i have a main window and a modal window and i'm trying to get the selected value from the modal window y put the value into a parent attribute, but i have a problem i close de modal window with

	public void onClick$btnOk(){
		if(selectedClient==null){
			alert("No client selected");
		}else{
			 searchClientWin.getParent().setAttribute("selectedClient", selectedClient);
			 searchClientWin.onClose();
		}
	}

but in the parent

	searchClientModal= (Window)Executions.createComponents("demoProduct.zul", searchRow, null);
		searchClientModal.addEventListener("onClose",new EventListener() {
			public void onEvent(Event event) {
				Client c = (Client) searchRow.getAttribute("selectedClient");
				System.out.println( c.getCompanyShort() );
			}
		});
	

i debug mi code and when the modal window is closed nothing happens, never enter in the onClose envent i don't know why.

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
2 followers

RSS

Stats

Asked: 2011-06-06 18:18:09 +0800

Seen: 2,506 times

Last updated: Jun 15 '11

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