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>

ADF ( Auto Suggest Behavior )

ADF ( Auto Suggest Behavior )



One of my project client needs auto suggest behavior. Just few line of code .


















Jspx Page Code :

  <af:inputText    value="#{pageFlowScope.callP6WebserviceMBean.selectedProjectList}" 
                            label="DeptName  " 
                            id="soc1">
  
<af:autoSuggestBehavior   suggestedItems="#{pageFlowScope.callP6WebserviceMBean.getSubProjectLists}"/> 
 </af:inputText>








Java Code :


 public List getSubProjectLists(String value) {
           
            value=value.toLowerCase();
            List<SelectItem> selectItems = new ArrayList<SelectItem>();
            Iterator itr = projectIdNameList.iterator();
               
               while(itr.hasNext()) {
                  
                     String projectname = (String)itr.next();
                     String pn=projectname;
                     projectname=projectname.toLowerCase();
                   
                         if(projectname.contains(value)){
                                      selectItems.add(new SelectItem(pn,pn)); 
                                      isProjectToRiskLable=false;
                          }
                }
             return selectItems;
    }


Note : ProjectIdNameList you have to know in advance.

Steps to delete data from MDS ( soa-inrfa ) 11g

In my previous blog I explained how to add content in MDS repository . Removing content is very simple compared with adding.I don't have any idea about how to remove data in MDS ( GUI mode ).


WSLT ( weblogic scripting tool )


$ oracle/Middleware/oracle_common/common/bin

$ wlst.sh

Make a connection to weblogic server .

wls:/offline> connect('weblogic','********','t3://localhost:7001')



already MDS Contains fault-policies.xml

/apps/com/xsd/fault-policies.xml


wls:/offline> deleteMetadata(application='soa-infra',server='AdminServer',docs='/apps/com/xsd/fault-policies.xml')

application -- > soa-infra
server        -->  Adminsever is not mandatory . eg : soa_sever1  ( Managed servers )
docs         -->   /apps    by default , then file location.





wls:/offline> deleteMetadata(application='soa-infra',server='AdminServer',docs='/apps/**')

** will delete all the files, so be careful while using this command

Done ............

Oracle Metadata Services (MDS) repository Oracle SOA-MDS / BPM-MDS 11g


MDS  - Matadata Service.

Why MDS ?

 From Development to Production moving complete code to server from Jdveloper and maintain complete code base version .

Two types of MDS :
     
  1. File system MDS :
                             

 Advantage :  File system MDS are useful in terms of maintain complete xsd,wsdl,xml,etc  in same system .so when ever developers want to change any elements in xsd,wsdl,xml,etc are very frequently.

If I use file system MDS during development time  , then how weblogic server will understand  the local file system reference during run time ???

simple create jar ,then  convert into soa-bundle and deploy to the server. so in adf-config.xml file system MDS URL are not hard coded . I would suggest to use file system MDS.

Dis-advantage :   Multiple developers not able to use during development .


 2. Database MDS :

Advantage :  During development time multiple developers can share the same wsdl,xml,xsd  from Database MDS.


Dis-advantage :  MDS URL hard code in adf-config.xml ,when we generate configuration plan. those MDS URL are not  a part of any reference or as a service.


Example :  Business Analysist  create BPM template and those templates are saved in MDS repository . Developer job to check out the complete template  code and develop the process .

I listed few usage of MDS .



Step to create File system MDS Connection :


 create folder name apps in below location  :

              Jdeveloper11.6\jdeveloper\integration\seed

apps --> place xsd, wsdl, xml , etc ..

Resource Palette - > IDE Connection - > SOA - MDS 



now  make reference to  file system MDS in adf-config.xml . 

ApplicationResource - > Descriptors - > ADF  META-INF - > adf-config.xml 

 <?xml version="1.0" encoding="windows-1252" ?>
<adf-config xmlns="http://xmlns.oracle.com/adf/config"
            xmlns:config="http://xmlns.oracle.com/bc4j/configuration"
            xmlns:adf="http://xmlns.oracle.com/adf/config/properties"
            xmlns:sec="http://xmlns.oracle.com/adf/security/config">
  <adf-adfm-config xmlns="http://xmlns.oracle.com/adfm/config">
    <defaults useBindVarsForViewCriteriaLiterals="true"/>
    <startup>
      <amconfig-overrides>
        <config:Database jbo.locking.mode="optimistic"/>
      </amconfig-overrides>
    </startup>
  </adf-adfm-config>
  <adf:adf-properties-child xmlns="http://xmlns.oracle.com/adf/config/properties">
    <adf-property name="adfAppUID" value="BPELAsResApplication.Krishna"/>
  </adf:adf-properties-child>
  <sec:adf-security-child xmlns="http://xmlns.oracle.com/adf/security/config">
    <CredentialStoreContext credentialStoreClass="oracle.adf.share.security.providers.jps.CSFCredentialStore"
                            credentialStoreLocation="../../src/META-INF/jps-config.xml"/>
  </sec:adf-security-child>
  <adf-mds-config xmlns="http://xmlns.oracle.com/adf/mds/config">
    <mds-config xmlns="http://xmlns.oracle.com/mds/config">
      <persistence-config>
        <metadata-namespaces>
          <namespace metadata-store-usage="mstore-usage_1" path="/soa/shared"/>
          <namespace metadata-store-usage="mstore-usage_2" path="/apps"/>
          </metadata-namespaces>
        <metadata-store-usages>
          <metadata-store-usage id="mstore-usage_1">
            <metadata-store class-name="oracle.mds.persistence.stores.file.FileMetadataStore">
              <property value="${oracle.home}/integration"
                        name="metadata-path"/>
              <property value="seed" name="partition-name"/>
            </metadata-store>
          </metadata-store-usage>
          <metadata-store-usage id="mstore-usage_2">
            <metadata-store class-name="oracle.mds.persistence.stores.file.FileMetadataStore">
              <property value="${oracle.home}/integration"
                        name="metadata-path"/>
              <property value="seed" name="partition-name"/>
            </metadata-store>
          </metadata-store-usage>
         </metadata-store-usages>
      </persistence-config>
    </mds-config>
  </adf-mds-config>
</adf-config>

as I mentioned earlier  during development time apps folder reference in local system , but when the same deployed in weblogic server. Reference inside adf-config.xml automatically resolve during runtime.


Step to create SOA_Bundle ( MDS weblogic server ) and Database MDS :

yet to define .......

Add custom jars/functions(Java) in Oracle BPM 11g Jdev / SOA Infrastructure




       Add custom jars/functions(Java) in Environment:

A)     Need to build java file and make it as jar.


B)     In Jdeveloper (Local), needs to add jar as follows;
a.      Open Tools  --> Preferences
b.      Select SOA from left side
c.       Click Add button to add jar file.
d.      Restart JDeveloper.
e.      Check by opening any XSL Transformation and click on drop down which appears left, top.

f.        Choose User-Defined from that drop down.
g.      User Defined Functions and Templates will be available.
h.      Click on User-Defined Functions and see your method which available in customized jar.


C)     Need to mention location of the jar in the BpelClasspath

a.      First we need to copy the jar file in the following location 

/opt/Oracle/Middleware/Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1

b.      Then, In Oracle BPM 11G EM(Enterprise Manager), find SOA Infrastructure Menu
c.       Select  SOA Administration àBPEL Properties
d.      Click on BpelcClasspath tab
e.      In the Value field, specify the classpath where placed jars.
f.        Click Apply and Run.
g.      Restart Server.


Thanks to Nambi .

SOA / BPM 11g Fault Handling Framework ( fault-policies.xml , fault-bindings.xml )

SOA / BPM 11g Fault Handling Framework ( fault-policies.xml , fault-bindings.xml  )


Fault Handling Framework :

" Happy Path " always a big term in BPM World . More than a " Happy Path " , Exception Handling  is important in terms of Real time business.

SOA Fault Handling Framework :

Exception Handling in terms of BPM :

1. Boundary Event --> Each activity level .
2. Event Sub-Process --> Process Level .

Exception Handling in terms of BPEL :

1. Catch.
2.Catch All.
3. Rethrow.


How to archive Exception Handling in Application level  ?????????????

SCA is very important in terms of SOA Application ( Composite.xml )

Composite.xml :

Add following piece of code inside composite.xml


 <property name="oracle.composite.faultPolicyFile">fault-policies.xml</property>
 <property name="oracle.composite.faultBindingFile">fault-bindings.xml</property>


Fault Handlining :

1. Fault-bindings.xml


<?xml version="1.0" encoding="UTF-8" ?>
<faultPolicyBindings version="2.0.1" xmlns="http://schemas.oracle.com/bpel/faultpolicy"
xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance">
<composite faultPolicy="KrishnaFaults"/>
</faultPolicyBindings>


2. Fault-policies.xml

<?xml version="1.0" encoding="UTF-8" ?>
<faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy">
  <faultPolicy version="2.0.1" id="KrishnaFaults"
               xmlns:env="http://schemas.xmlsoap.org/ soap/envelope/"
               xmlns:xs="http://www.w3.org/2001/XMLSchema"
               xmlns="http://schemas.oracle.com/bpel/faultpolicy"
               xmlns:xsi="http://www.w3.org/2001/ XMLSchema-instance">
   

 <Conditions>
          <faultName xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
                 name="bpelx:remoteFault">
        <condition>
          <action ref="ora-retry"/>
        </condition>
      </faultName>
    </Conditions>


    <Actions>
      <Action id="my-java-handler">
        <javaAction className="soatraining.faulthandling. MyFaultHandler"
                    defaultAction="ora-terminate" propertySet="myProps">
          <returnValue value="OK" ref="ora-rethrow-fault"/>
        </javaAction>
      </Action>

      <!-- Retry -->
      <Action id="ora-retry">
        <retry>
          <retryCount>4</retryCount>
          <retryInterval>2</retryInterval>
          <exponentialBackoff/>
        </retry>
      </Action>

      <!-- Rethrow action -->
      <Action id="ora-rethrow-fault">
        <rethrowFault/>
      </Action>
      <!-- Human Intervention -->
      <Action id="ora-human-intervention">
        <humanIntervention/>
      </Action>
      <!-- Terminate -->
      <Action id="ora-terminate">
        <abort/>
      </Action>
    </Actions>
    <Properties>
      <propertySet name="myProps">
        <property name="logFileName">myfaulthandler.log</property>
        <property name="logFileDir">c:\temp</property>
      </propertySet>
    </Properties>
  </faultPolicy>
</faultPolicies>




Conditions and Action are very important in Fault-policies.xml.