NY_00001_YesNoPlugIn
This is a simple dialog offering "YES" and "NO" buttons in response to a question. The dialog can also be closed using the "Escape" key or the close button in the upper right corner.
The dialog is located in a separate plugin.
Of course, one might question whether such a small dialog justifies creating its own microservice. However, the dialog can be used by many programs in this form. While its handling is slightly more complex than that of a local dialog, it shares the same mechanics as all the other dialogs presented here. This makes its use straightforward and consistently uniform after a short period.
Usage
Creation
The call requires the microservice ID.
private static final IIdMICRO_SERVICE_YES_NO = CIdFactory.fromObject("NY_WebDialogYesNo_00001");
The
The
An ID of an div
element.
private void openDialogYesNo(final byte[]aSessionToken , @NotNull final StringaDivElementId , @NotNull final StringaMessage ) throws CException { final CStringProperties params = new CStringProperties(); params.put("message",aMessage ); mWebDialogApi.showWebDialog(MICRO_SERVICE_YES_NO ,aSessionToken ,aDivElementId , params); }
The dialog can be terminated programmatically by sending a CRecordWebDismissDialog message.
Dialog terminates notification
// constructor: addMessageHandler(CRecordWebNotifyDialogDismissed.ID, this::asyncWebDialogFinished );
private booleanasyncWebDialogFinished (@NotNull final CEnvelope aEnvelope, @NotNull final CRecord aRecord) throws CException { if (aEnvelope.isAnswer()) { return false; } else { final int reason = CRecordWebNotifyDialogDismissed.getReason(aRecord, -1); if (reason == CWebDialogApi.REASON_SUCCESS) { final IId microserviceId = CRecordWebNotifyDialogDismissed.getMicroserviceId(aRecord, null); // Check whether this is our dialog if (MICRO_SERVICE_YES_NO .equals(microserviceId)) { // The returned properties contain the results as well as the properties provided. final CStringProperties results = CRecordWebNotifyDialogDismissed.getResults(aRecord, new CStringProperties()); final String yesOrNo = results.get("result"); if ("yes".equals(yesOrNo)) { // ... } } } else if (reason == CWebDialogApi.REASON_ERROR) { // ... } else if (reason == CWebDialogApi.REASON_CANCELED_BY_USER) { // ... } else if (reason == CWebDialogApi.REASON_CANCELED_BY_OWNER) { // ... } aEnvelope.setResultSuccess(); return true; } }