-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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");
super.doAfterCompose(comp);
Need help!!
Thanks :)
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.
If you have a GFC applied to the component and call super.doAfterCompose(comp);, the variable args is available.
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);
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")
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
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
Hi, i have this code
dialog.doModal(); logger.info("The value"+winMap.getAttribute("name"));
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....
look in your zk.xml
<!-- ========================================================== --> <!-- Enable event thread for modal windows --> <!-- ========================================================== --> <system-config> <disable-event-thread>false</disable-event-thread> </system-config>
: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
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.
Asked: 2011-06-06 18:18:09 +0800
Seen: 2,506 times
Last updated: Jun 15 '11