Modal Dialog

13 views
Skip to first unread message

mon3y

unread,
Jul 27, 2007, 3:58:26 AM7/27/07
to GWT Tk
Hi

I have 2 classes. Both classes are basically 2 ModalDialogBoxes with
several widgets inside of them.

For the purpose of this question lets call the classes , Class"A" and
"Class B". The ModalDialog from class "B" pops up when i click a
button on "Class A"(ModalDialog) button.(No problems there, :) )

I have this in "Class B"

myDialog1.addPopupListener(new PopupListener(){

public void onPopupClosed(PopupPanel sender, boolean autoClosed)
{
myDialog1.hide();
}

});

when that event fires i want to refresh a widget in "Class A", so i
have a method like this in "Class A"
public void refreshWidget(){
mainTable.remove(departmentDD);//remove the widget
getDepartments();//RPC Call
mainTable.setWidget(10, 3, departmentDD);//add the widget back
to the table with the new lsit
}

How can i call that method, in "Class A" when the ModalDialog of
"Class B" closes?

Thanks

Mat Gessel

unread,
Jul 27, 2007, 1:57:01 PM7/27/07
to gwt...@googlegroups.com
Hi,

One of the primary goals of software design is to reduce dependencies
so that classes can be reused independently of each other. What this
means in your scenario is you don't want the dialogs to refer to each
other. DialogA depends on DialogB, because A shows (and possibly
constructs) B. Therefore, you don't want B to know about A. Here is a
possible solution:

Declare DialogB's PopupListener, the RPC call, and the AsyncCallback
in DialogA. The execution sequence could look something like this:

dialogA.button.click()
dialogA.clickListener.onClick()
new DialogB()
dialogB.addPopupListener(new dialogA.popupListener())
dialogB.show()
...
dialogA.popupListener().onPopupClosed()
dialogB.hide()
dialogA.mainTable.remove(departmentDD)
rpcService.getData(new dialogA.asyncCallback())
...
dialogA.asyncCallback.onSuccess(result)
dialogA.mainTable.add(DepartmentDD((DataClass) result))

--
Mat Gessel
http://www.asquare.net/gwttk/

Reply all
Reply to author
Forward
0 new messages