Skip to main content

Custom Dialogs

The custom dialog is not a widget but more of a dialog to do a particular business operation.

What it can crete from workspace assistant

Using the workspace assistance developer can create custom dialog for the plugins created by the developer.

Methods exposed as part of the dialog

The custom dialog exposed below three method for building and handling various action of the dialog.

  • buildDialog(..) : This method is responsible for building the Dialog.
  • validDialog(.) : validdialog is used to either chain to different dialog or to perform a business action and return the success.
  • cancelDialog(.) : this method is called when user perform invalid action.
How to return Success message

There are 2 types of interactions that can be provided for the success message.

  1. Alert : if the developer wants to show an alert message popup post operation.
       XmlNode result = super.validDialog(context);
XmlNode msg = new XmlNodeImpl("message");
msg.setValue("Processed Successfully");
msg.setAttribute("type", "alert");
msg.setAttribute("title", "Success");
result.appendXmlNode(msg);

*Sample Output :

   "page-content": {
"success": {
"message": {
"type": "alert",
"order": 1,
"content": "Processed Successfully"
}
}
}
  1. Toast : if the developer wants to show a toast message on top of the screen.
       XmlNode result = super.validDialog(context);
XmlNode msg = new XmlNodeImpl("message");
msg.setValue("Processed Successfully");
msg.setAttribute("type", "toast");
msg.setAttribute("title", "Success");
result.appendXmlNode(msg);

*Sample Output :

   "page-content": {
"success": {
"message": {
"type": "toast",
"order": 1,
"content": "Processed Successfully"
}
}
}

Where

  • message is child node of success, and it is mandatory which is having their content as Value.
  • type is also a mandatory key which allow either alert/toast as value.
  • title is an optional parameter for the type='alert' which will be displayed as the title for the alert popup.
Overriding the default post action behavior

There are basically 3 types of post action that can be performed on the selected objects after the completion of the dialog service operation. Those operation can be set as an attribute to the result before the returning in the case of validDialog(.) and cancelDialog(.)

  1. Locate content and refresh state upon action : This will locate the object and update the state of the object selected. For example, if you are performing some operation which will move the selected object from one location to another. Then this attribute will help the user to identify where it is located as well as refreshing the state of the current container. Attribute used for this is locateAndRefresh
  2. Refresh state : This will refresh the state of the object selected post dialog operation. For example, if you have performed a lifecycle operation or a property update as part of the validDialog(.) then if you want to have the updated menus as well as values in the selected item in the widget we would need to set this value as part fo the result. Attribute used for this is refreshCheckoutState
  3. Refresh widget : This will reload the widget post the operation. Attribute used for this is refreshWidget

Sample Code

       XmlNode result = super.validDialog(context); 
result.setAttribute("locateAndRefresh", "true");
result.setAttribute("refreshCheckoutState", "true");
result.setAttribute("refreshWidget","true");
return result;
info
  1. Supported values are "true"/"false".
  2. Default value if not set is false.