Sunday, September 14, 2014

Confirmation Dialog when clicking on REJECT/ CANCEL button in Oracle BPM Human Task and close window

Step1:

Add the below code inside <af:commandToolbarButton>

 <af:showPopupBehavior popupId="p1" triggerType="action"/>

Example Code looks like

<af:commandToolbarButton actionListener="#{invokeActionBean.setOperation}"
                                               text="#{wf:getResourceValue('REJECT', 'bindings.customActions')}"
                                               disabled="#{!bindings.REJECT.enabled}"
                                               action="#{invokeActionBean.invokeOperation}"
                                               partialSubmit="false"
                                               visible="#{wf:isCustomActionAvailable('REJECT', 'bindings.customActions')}"
                                               id="ctb1">
                                       
                                                <af:showPopupBehavior popupId="p1" triggerType="action"/>
                                                    <f:attribute name="DC_OPERATION_BINDING" value="bindings.REJECT"/>
                                   
                      </af:commandToolbarButton>

Step2:

Add the below code after  </af:commandToolbarButton>
<af:popup id="p1">
                        <af:dialog id="d222" title="Confirmation"
                                   dialogListener="#{CancelBean.isCancelled}">
                        <af:outputText   value="Are you sure that you want to cancel this Request?" id="ot211"/>
                        </af:dialog>
                      </af:popup>

Step3:

Add the below code in your cancelandClose() in Bean:
              DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
                 OperationBinding operationBinding = (OperationBinding)bindings.getOperationBinding("REJECT");
                 Map paramsMap = operationBinding.getParamsMap();
                 paramsMap.put("DC_OPERATION_BINDING", "bindings.REJECT");
                 operationBinding.execute();
                 List errorsOnSubmit = operationBinding.getErrors();
                 if (errorsOnSubmit == null || errorsOnSubmit.isEmpty()) {
                     returnMessage = "closeTaskFlow";
                     FacesContext facesContext = FacesContext.getCurrentInstance();
                     ExtendedRenderKitService service = Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);
                     service.addScript(facesContext, "window.opener = self;window.close();");
                 }
             } catch (Exception e) {
              e.printStackTrace();
             }
        return returnMessage;
    }



No comments:

Post a Comment