Search This Blog

Custom Error Handling ADF Screen using Java Code ( Oracle BPM 11g ) Taskflow


Custom Error Handling ADF Screen using Java Code ( Oracle BPM 11g ) Taskflow



   Most of the time try and catch block used in java code to handle error, but in terms of customer view Exception page has to be show in-order to avoid panic. Use below method and call any were from Catch block.


     import oracle.adf.controller.ControllerContext;

    ControllerContext controllerCtx = null;
    

   public  void setRedirectPageMethod(String custmMessage ,String StackTraceMessage) {
  
    FacesContext fcntx = FacesContext.getCurrentInstance();
    ExternalContext ectx = fcntx.getExternalContext();
    String viewId = "/faces/CustomErrorPage_Form.jspx";
    controllerCtx = ControllerContext.getInstance();
    String activityURL = controllerCtx.getGlobalViewActivityURL(viewId);
    try{
      ectx.redirect(activityURL);
         
    }
    catch(Exception e) {

    }
}




Your comments and suggestion are always welcome :-)

Custom java code to access Oracle BPM 11g Button actions ( Submit , Cancel. withdraw , suspend , escalate )

Custom java code to access Oracle  BPM 11g Button actions ( Submit , Cancel, withdraw, suspend , escalate )



Use following piece of java code in your application to perform any BPM related pre-defined button actions . Depending upon the type of button, change the button name which highlighted in red Color 


import oracle.adf.model.OperationBinding;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.binding.BindingContainer;

 

public void exitBPMWorkflow(){
    
             String returnMessage = null;
             try {
                 
              DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
                 OperationBinding operationBinding = (OperationBinding)bindings.getOperationBinding("SUBMIT");
                 Map paramsMap = operationBinding.getParamsMap();


                 paramsMap.put("DC_OPERATION_BINDING", "bindings.SUBMIT");
                 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) {
             }
    }

  

        

Code to access DCBindingContainer & DCIteratorBinding ( ADF and BPM 11g )


 Code to access DCBindingContainer & DCIteratorBinding  ( ADF and BPM 11g )


              some point of time need to get username who logged or some BPM pre-defined elements have to access . Below piece of code useful to access.Applicable for both ADF- BPM and separate ADF Project with data control approach also . 




Java Code :

import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.binding.BindingContainer;



DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry() ;
DCIteratorBinding iteratorBindingTask =dcBindings.findIteratorBinding("taskIterator");
              
 String  userName =(String)iteratorBindingTask.getCurrentRow().getAttribute("creator");

     





ADF ( POP Up code ) through Java code and Jspx ( oracle BPM 11g )


ADF POP UP Code ( Java )


 ADF Java Code :

import javax.faces.component.UIComponent;
import oracle.adf.view.rich.component.rich.RichPopup;

 public class DemoPopup
         {
            private RichPopup popUp;
           
           public void createPopup(ActionEvent actionEvent)
            {
        
                UIComponent source = (UIComponent)actionEvent.getSource();
                RichPopup.PopupHints hints = new RichPopup.PopupHints();
                hints.add(RichPopup.PopupHints.HintTypes.HINT_ALIGN_ID,source)
               .add(RichPopup.PopupHints.HintTypes.HINT_LAUNCH_ID,source)
               .add(RichPopup.PopupHints.HintTypes.HINT_ALIGN,
               RichPopup.PopupHints.AlignTypes.ALIGN_AFTER_START);
               popUp.show(hints);

          }
        
        public void hidePopup(ActionEvent event) {
                 popUp.hide();
            }
   

     public void cancelPopupActionListener(ActionEvent event)  {
           popUp.cancel();  

          }

    public void setPopUp(RichPopup popUp) {
        this.popUp = popUp;
    }

    public RichPopup getPopUp() {
        return popUp;
    }
}



ADF POP UP ( JSPX Code )



   <af:popup contentDelivery="lazyUncached" id="Userpopup" binding="#{pageFlowScope.callP6WebserviceMBean.popUpProject}">`
              
  <af:panelWindow id="pw2" modal="true" title="Please select Project" resize="on"
                                  closeIconVisible="false">
                 
              
  <af:commandButton text="Submit" 

                                   id="cb1" 
                                   partialSubmit="true"                                    
                                   actionListener="#{pageFlowScope.callP6WebserviceMBean.hidePopupActionListener}"/>
                 

  <af:commandButton text="Cancel" 
                                   id="cb2" 
                                  partialSubmit="true"
                                  actionListener="#{pageFlowScope.callP6WebserviceMBean.cancelPopupActionListener}" 

                                   immediate="true"/></af:panelWindow>
</af:popup>