0

triggering events?

asked 2010-08-17 09:28:56 +0800

nevyn gravatar image nevyn
159 2

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.

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2010-08-17 10:41:10 +0800

robertpic71 gravatar image robertpic71
1275 1

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

link publish delete flag offensive edit

answered 2010-08-18 03:30:46 +0800

nevyn gravatar image nevyn
159 2

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.

link publish delete flag offensive edit

answered 2010-08-18 06:17:45 +0800

robertpic71 gravatar image robertpic71
1275 1

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

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-08-17 09:28:56 +0800

Seen: 233 times

Last updated: Aug 18 '10

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