It's all about the answers!

Ask a question

How to prevent jazz.ui.SwapListDialog from closing after OK button is pressed?


Serghei Zagorinyak (482913) | asked Aug 10 '12, 4:30 a.m.
edited Aug 20 '12, 4:00 a.m.

Hi! I'm developing a plugin for RTC WebUI and there is a SwapListDialog in it. After the user presses OK button a service is triggered that processes the data. But the dialog closes. I'd like it to remain open and update the data in it. How can I do that?

  And another less important question is how to prevent  SwapListDialog from being modal and moveable? I tried to set properties "modal:false", "moveable:false" as it extends Dialog, but no use. 

One answer



permanent link
Mike Pawlowski (6861) | answered Aug 23 '12, 5:41 p.m.
JAZZ DEVELOPER
edited Aug 23 '12, 5:47 p.m.
Hi Serghei,

>> I'd like it to remain open and update the data in it. How can I do that?


Unfortunately, there is no built-in mechanism or API implemented to modify this behaviour in the Swap List Dialog common component.

/net.jazz.web.ui/resources/SwapListDialog.js

However, to achieve the same effect you can create a new Dojo widget that extends the Swap List Dialog and overrides it's internal behaviour. Disclaimer: This behaviour is not supported.
More specifically, in your subclass widget you need to override this internal method as follows:

_handleEventOKButtonClicked: function(event) {
   dojo.stopEvent(event);
   // this._doIt = true;
   // this.hide();
   if (this.onOK) {
      this.onOK(this);
   }
   return true;
},

The "hide" method is responsible for closing the dialog.
The "onOK" method is the callback you supplied to the Swap List Widget.

You will need to determine how to close the Swap List Dialog without using the "OK" button (e.g. Is the "Cancel" button acceptable in your scenario?). Otherwise, you will have to rely on either the "Cancel" button or the top right dialog "X" "Close" button. The following code is invoked in the latter scenario:
_handleEventDialogClosed: function() {
if (this._doIt && 
this.onOK) {
this.onOK(this);
} else if (this.onCancel) {
this.onCancel(this);
}
return true;
},
>> how to prevent  SwapListDialog from being modal and moveable?


The Swap List Dialog actually doesn't extend the Dialog common component in the Dojo sense. The name is sort of a misnomer. Rather, the Swap List Dialog widget contains an instance of the Dialog widget (e.g. this._dialog). As a result, you need to override the following method in your new Dojo widget that extends the Swap List Dialog as follows:

show: function() {
this._doIt = false;
this._dialog = new Dialog({
contentNode: this.domNode,
primaryTitle: this.dialogTitleText ? this.dialogTitleText : this.messages.msgSelectParameters,
width: this.width,
height: this.height,
onClose: dojo.hitch(this, this._handleEventDialogClosed),
modal: false, 
moveable: false
});
},
Alternatively, for both of these issues you can create your own custom widget that includes the Swap List widget (without the Dialog) and create and manage the Dialog container yourself to get the desired effect. The benefit to this approach is that you do not need to override anything and you have full control over the behaviour.
See: /net.jazz.web.ui/resources/internal/SwapList.js

HTH

Mike

Comments
Serghei Zagorinyak commented Aug 24 '12, 7:41 a.m.

Thank you for your answer, Mike. I'll give it a try.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.