-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'm just a touch lost.
I've got a page and when a user clicks a button on that page, a modal windows loads up. One the modal window, there's a text box and two buttons - a cancel and an okay button.
Both buttons close the window but I need the add button to tell the controller for the original page to do something like refresh a list from a database. How would I go about doing this?
Below is some psuedo code to illustrate my point...
BaseWindowController
Button butNewWindow; window wndContainer; void public onClick$butNewWindow(){ try{ Window win=(Window)Executions.createComponents( "/modalWindow.zul", null, shareValues); } catch(Exception e){ }
modalWindow
Button butOK; Button butCancel; Window wndModal; Textbox txtbxValue; public void onClick$butCancel(Event event){ wndModal.detach(); } public void onClick$butOK(Event event){ //do something with txtbxValue - easy //somehow tell BaseWindowController that this window is closing. //Preferably, pass the string value of txtbxValue back to BaseWindowController //and let that controller do all of the work. wndModal.detach(); }
Any help would be greatly appreciated.
Regards,
Nevyn.
There some options:
i.e.
wndModel.detach(); Event reloadEvent = new Event("onReload", (Window) Path.getComponent("//main/win")); // get your main-window Events.sendEvent(reloadEvent);
and in mailwindow/composer:
public void onReload(Event event) { binder.loadAll(); }
Note: You can construct the Event with Name, Component and objectdata - and
retrieve the data later with event.getData()
Another option is to pass the window-component or the composer itself via Parameter (createComponent).
Also an option could be, to register the maincontroller as desktop attribute.
/Robert
Thanks Robert,
Helped heaps. I did have to change my approach a little bit - I used an include so that I could traverse DOM so that I could go backwards through the DOM due to the complexity of the page (did a bit of a count and realised by the point I'm clicking on that button I've got 4 composers up).
Regards,
Nevyn.
Hi Nevyn,
please note: include increase initial load time
I use include for often used components and createComponent for i.e. optional windows or menu.
You could follow the DOM for Components, created with createComponents too.
However, if you initial speed is ok, or the the user stays long in this side - inlcude is ok.
Another option: Eventqueue could also handle this issue.
/Robert
Asked: 2010-08-17 09:28:56 +0800
Seen: 233 times
Last updated: Aug 18 '10