Thursday, 24 October 2013



UCM Connection From Java





ADF Bindings

ADF Bindings


ADF : Samples

Worked/Knowledge on:

ü  VO Tuning

  ADF Multi language support.


  Using Data source.

  Dynamic Tab shell template.

  Dynamic Task flow.

  ADF Custom skin.

  ADF Declarative component.

  Developing Menu, Tree and Tab elements.

  Entity objects, View objects and View links.

  Unbounded and Bounded TaskFlows

  Task flow level exception handling.

  Validation (Entity level with Domain and Attribute level and JSF)

  Security Implementation

  Java script loading using adf-js-partition

  Cascaded LOV.

  Using DBSeq and Groovy expressions.

  Using Router and Return components in TF level.

  Extending PagePhaseListner.

  Contextual event.
  Concepts – Create, CreateInsert, CreatewithParams, NextSet, PreviousSet, executeWithParam, setCurrentRowWithKey and setCurrentRowWithKeyValue.

  Autosuggest and carousal components.

  Report generation using XML Publisher.

  Import/Export Excel data.

  Upload/Retrieve Image using servlet.

  Cache Implementation.

  Knowledge on ADF Life cycle.

  Knowledge on ADF with Webservice (JAX-WS 2.0).

  Knowledge on ADF with spring and Hibernate integration.

ü  Knowledge on Oracle BPM, BPEL, SOA and OSB.
 

ADF : ViewObject, Session, FacesMessage, Datasource, addScript

ADF : ViewObject, Session, FacesMessage, Datasource, addScript


import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCDataControl;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.binding.BindingContainer;
import oracle.binding.OperationBinding;
import oracle.jbo.ApplicationModule;
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.naming.InitialContext;
#######################Get Session###############################
    HttpServletRequest request =
                (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
            HttpSession httpSession = request.getSession(true);
######################Get BindingContainer################################
    public BindingContainer getBindings() {
            return BindingContext.getCurrent().getCurrentBindingsEntry();
        }
########################Get ViewObject From Iterator##############################

public void executeVOQuery(){
DCBindingContainer bc = (DCBindingContainer)this.getBindings();
DCIteratorBinding dcIbbLink = bc.findIteratorBinding("Header_InputEOUPVO1Iterator");
//to get viewobject
ViewObject header_InputEOUPVO = dcIbbLink.getViewObject();
//to get all rows
Row[] headerRows = dcIbbLink.getAllRowsInRange();
header_InputEOUPVO.setWhereClause("REFERENCE_ID = "+referenceIdEntered_Int);
header_InputEOUPVO.setWhereClause("AND SIZING_CODE in (select distinct body_material from xxcz_dmc_pa_usm_conn where model_name = '"+modelSelected+"')");
header_InputEOUPVO.executeQuery();
}
########################Get ViewObject From ApplicationModule##############################
public void getVOFromAM(){
BindingContext bctx = BindingContext.getCurrent();
        DCDataControl dc = bctx.findDataControl("AppModuleDataControl");
        ApplicationModule service = (ApplicationModule)dc.getDataProvider();
        System.out.println("service : "+service);
        ApplicationModule am = service.findApplicationModule("AppModule");
        System.out.println("am : "+am);
        ViewObject modelResultVO = am.findViewObject("Model_Result_ROVO2");
}
########################get All Rows from ViewObject##############################
public void getAllRowRangeFromVO(){
DCBindingContainer bc = (DCBindingContainer)this.getBindings();
Row ProcessFluidType[] = bc.findIteratorBinding("ProcessFluidTypeROVO1Iterator").getAllRowsInRange();
                  System.out.println("  *************************************  : "+ProcessFluidType);
                  if(ProcessFluidType != null){
                        for(int i=0; i< ProcessFluidType.length; i++){
                          System.out.println(" row  "+ProcessFluidType.length);
                            Row rowMatch = ProcessFluidType[i];
                            System.out.println(" rowMatch ProcessFluidType************  : "+rowMatch);
                          if(rowMatch != null){
                            System.out.println(" rowMatch.getAttribute(\"PfluidtypeCode\") : "+rowMatch.getAttribute("PfluidtypeCode")+ "and final_ProcessFluidType : "+final_ProcessFluidType);
                            if(rowMatch.getAttribute("PfluidtypeCode").toString().equalsIgnoreCase(final_ProcessFluidType)){
                                System.out.println(" *********** : "+i);
                                bc.findIteratorBinding("ProcessFluidTypeROVO1Iterator").setCurrentRowIndexInRange(i);
                                if(i==0) {
                                        getEnterName().setDisabled(true);
                                        getSoc1().setDisabled(false);
                                    }
                                break;
                            }
                          }
                           
                        }
                  }
}
########################Execute operationBinding##############################
public String executeCommitForProcess_InputVO(){
        System.out.println("Inside executeCommitForProcess_InputVO ........//////////////////////////////////////////////////////...............................");
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("Commit1");
                    System.out.println("Going to execute Commit1111111111111, For Process Input VOOOOOOOOOOOOOOOOOOOOOO. ");
                    Object result = operationBinding.execute();
                    System.out.println("Executed Commit1111111111111 For Process Input VOOOOO : ");
                    if (!operationBinding.getErrors().isEmpty()) {
                        System.out.println("Binding Error");
                        return null;
                    }
                   
        System.out.println("Inside executeCommitForProcess_InputVO ........///////////////////////////.............");
        return null;
    }
########################ADF Error Message##############################
public void setErrorMessageForParticularComponent()
{
FacesContext fc = FacesContext.getCurrentInstance();
UIComponent uIComponent;
            uIComponent = spGravity;
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,   
              "Invalid Specific Gravity",
              "Please provide Specific Gravity, Example: 10.2");       
            fc.addMessage(uIComponent.getClientId(fc), message);  
            ((RichInputText)uIComponent).setValid(false);
}
########################resolveExpression##############################
public static Object resolveExpression(String expression) {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            javax.faces.application.Application app =
                facesContext.getApplication();
            ExpressionFactory elFactory = app.getExpressionFactory();
            ELContext elContext = facesContext.getELContext();
            ValueExpression valueExp =
                elFactory.createValueExpression(elContext, expression,
                                                Object.class);
            return valueExp.getValue(elContext);
        }
########################Datasource Connection##############################
public Connection getConnectionFromDatasource() {
        System.out.println("---------------------------------> Inside getConnectionFromDatasource");
     ResourceBundle rb=ResourceBundle.getBundle("PropertyFile");
     String  datasource_name = rb.getString("DATASOURCE_NAME");
        Connection connection = null;
        try{
           
        Context ic = new InitialContext();
        javax.sql.DataSource dataSource =           (javax.sql.DataSource) ic.lookup(datasource_name);         
        connection = dataSource.getConnection();
          
 
        }
        catch(Exception e){
           
            //e.printStackTrace();
            System.out.println("Exception : "+e.getMessage());
        }
        System.out.println("---------------------------------> completed getConnectionFromDatasource");
        return connection;
    }
########################CloseWindow Javascript in bean##############################
public String closeWindow() {

          FacesContext facesContext = FacesContext.getCurrentInstance();

          org.apache.myfaces.trinidad.render.ExtendedRenderKitService service =
              org.apache.myfaces.trinidad.util.Service.getRenderKitService(facesContext,
                                                                           ExtendedRenderKitService.class);

          //service.addScript(facesContext,
          //                  "window.close();window.opener.location.href = window.opener.location.href;");
          service.addScript(facesContext,
                            "window.close();");

        return null;
      }
########################show popup Javascript in bean##############################
public String displaySavedSucessfullMessagePopup(HashMap refInfo_HM) {
        System.out.println("Inside displayFluidListPopup ...................................................");
        FacesContext context = FacesContext.getCurrentInstance();
        StringBuilder script = new StringBuilder();
        script.append("var popup = AdfPage.PAGE.findComponent('p4'); ");
        script.append("if (!popup.isPopupVisible()) { ").append("popup.show();}");
        ExtendedRenderKitService erks =
            Service.getService(context.getRenderKit(),
                               ExtendedRenderKitService.class);
        erks.addScript(context, script.toString());
       
        System.out.println("Completed displayFluidListPopup ...................................................");
        return null;
    }

ADF : TreeTable: Read selected Node from ADF TreeTable.

TreeTable: Read selected Node from ADF TreeTable.


I have 2 level of tree structure as shown below
   ObjectMainVO
        |_ ObjectFakeVO
                

My requirement is :
  User can select any row from the above heirarchy
  In my bean class i have to find, what VO user has selected and do some operation.

###################In JSPX page ################################################
1. remove ..makeCurrent from treeTable and call TreeSelectionListner (since we are executing makeCurrent from bean class)
---------------------------------------------------------------------------------
<af:treeTable value="#{bindings.ObjectMain2.treeModel}" var="node"
                      selectionListener="#{backingBeanScope.backing_ObjectMain_ObjectFake_MapView.TreeSelectionListener}"
                      rowSelection="single"
                      binding="#{backingBeanScope.backing_ObjectMain_ObjectFake_MapView.tt1}"
                      id="tt1">
          <f:facet name="nodeStamp">
            <af:column id="c1">
              <af:outputText value="#{node}" id="ot2"/>
            </af:column>
          </f:facet>
          <f:facet name="pathStamp">
            <af:group binding="#{backingBeanScope.backing_ObjectMain_ObjectFake_MapView.g1}"
                      id="g1">
              <af:outputText value="#{node}"
                             binding="#{backingBeanScope.backing_ObjectMain_ObjectFake_MapView.ot1}"
                             id="ot1"/>
            </af:group>
          </f:facet>
        </af:treeTable>

##############################In Bean Class ##################################
1. Execute the makeCurrent for parentVO manually
2. get the selected key (make sure that parent and child VO has unique key)
3. Check selected node is what type of VO in if else condition
------------------------------------------------------------------------------------

import java.util.Iterator;

import java.util.List;

import javax.el.ELContext;

import javax.el.ExpressionFactory;

import javax.el.MethodExpression;

import javax.faces.application.Application;
import javax.faces.context.FacesContext;

import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCDataControl;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.adf.view.rich.component.rich.data.RichTreeTable;
import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.adf.view.rich.context.AdfFacesContext;

import oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding;

import oracle.binding.BindingContainer;

import oracle.jbo.ApplicationModule;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;
import oracle.jbo.uicli.binding.JUCtrlHierBinding;

import oracle.jbo.uicli.binding.JUCtrlHierNodeBinding;

import org.apache.myfaces.trinidad.event.SelectionEvent;
import org.apache.myfaces.trinidad.model.CollectionModel;
import org.apache.myfaces.trinidad.model.RowKeySet;
import org.apache.myfaces.trinidad.model.TreeModel;


    public void TreeSelectionListener(SelectionEvent selectionEvent) {
            System.out.println("Inside onTreeSelectInstanceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee...//////////////////////////////////////////////////////////////");
           
            //original selection listener set by ADF //#{bindings.allDepartments.treeModel.makeCurrent}
            String adfSelectionListener = "#{bindings.ObjectMain2.treeModel.makeCurrent}";
              System.out.println("adfSelectionListener : "+adfSelectionListener);
            FacesContext fctx = FacesContext.getCurrentInstance();
              System.out.println("fctx : "+fctx);
            Application application = fctx.getApplication();
            ELContext elCtx = fctx.getELContext();
            ExpressionFactory exprFactory = application.getExpressionFactory();
            System.out.println("Inside onTreeSelect...11");
            MethodExpression me = null;
            me = exprFactory.createMethodExpression(elCtx, adfSelectionListener, Object.class, new Class[]
                  { SelectionEvent.class });
            System.out.println("Inside onTreeSelect...22");
            me.invoke(elCtx, new Object[] { selectionEvent });
            System.out.println("Inside onTreeSelect...33");
           
            RichTreeTable tree = (RichTreeTable)selectionEvent.getSource();
              System.out.println("Inside onTreeSelect...33..111");
            TreeModel model = (TreeModel)tree.getValue();
            System.out.println("Inside onTreeSelect...444 model : "+model);
            RowKeySet rowKeySet = selectionEvent.getAddedSet();
            Iterator rksIterator = rowKeySet.iterator();
            System.out.println("Inside onTreeSelect..555.");
           
               
            while (rksIterator.hasNext()) {
              List key = (List)rksIterator.next();
              System.out.println("Inside onTreeSelect...66 : "+key.get(0));
              JUCtrlHierBinding treeBinding = null;
              CollectionModel collectionModel = (CollectionModel)tree.getValue();
              System.out.println("Inside onTreeSelect...collectionModel : "+collectionModel);
              treeBinding = (JUCtrlHierBinding)collectionModel.getWrappedData();
              JUCtrlHierNodeBinding nodeBinding = null;
              nodeBinding = treeBinding.findNodeByKeyPath(key);
              System.out.println("Inside onTreeSelect...nodeBinding : " + nodeBinding);
              //Row rw = nodeBinding.getRow();      
             
              //String rowType = rw.getStructureDef().getDefName();
            
             //************************************
             FacesCtrlHierBinding bind = (FacesCtrlHierBinding)collectionModel.getWrappedData();
             DCIteratorBinding rowiter = bind.getDCIteratorBinding();
              Row r = rowiter.getCurrentRow();
             
                String nodeStuctureDefname = nodeBinding.getHierTypeBinding().getStructureDefName();
                System.out.println("Selected Node Def Name : "+nodeStuctureDefname);
                String objectMainDef = "model.ObjectMain";
                String objectFakeDef = "model.ObjectFake";
               
                BindingContext bctx = BindingContext.getCurrent();
                DCDataControl dc = bctx.findDataControl("AppModuleDataControl");
                ApplicationModule service = (ApplicationModule)dc.getDataProvider();
                System.out.println("service : "+service);
                ApplicationModule am = service.findApplicationModule("AppModule");
                System.out.println("am : "+am);
                if (nodeStuctureDefname.equalsIgnoreCase(objectMainDef)){
                System.out.println("Insideeeeee OBJECT -> OBJECTFFFFMMMMAAAAIIIIINNNNNNN");
                    ViewObject objectMainVO = am.findViewObject("ObjectMain2");
                    System.out.println("objectMainVO : "+objectMainVO);
                    //Row selectedRow = langVO.getCurrentRow();
                    Row selectedRow = objectMainVO.getRow(nodeBinding.getRowKey());
                    System.out.println("selectedRow : "+selectedRow);
                    System.out.println("selectedRow - map Id1 : "+selectedRow.getAttribute("Id1"));
                    System.out.println("selectedRow - obj : "+selectedRow.getAttribute("Obj"));
                    DCBindingContainer bc = (DCBindingContainer)this.getBindings();
                    ViewObject mapViewVO = bc.findIteratorBinding("MapView1Iterator").getViewObject();
                    mapViewVO.setWhereClause(null);
                    mapViewVO.setWhereClause("ID1 = '"+selectedRow.getAttribute("Id1")+"'");
                    mapViewVO.executeQuery();
                    AdfFacesContext.getCurrentInstance().addPartialTarget(this.tt2);
                  
                }
                else if (nodeStuctureDefname.equalsIgnoreCase(objectFakeDef)){
                //work with departments node data
                System.out.println("Insideeeeee OBJECT -> OBJECTFFFFAAAAAKKKKKKKKKKEEEEEEEEEE");
                    ViewObject objectFackeVO = am.findViewObject("ObjectFake2");
                    System.out.println("objectFackeVO : "+objectFackeVO);
                    //Row selectedRow = langVO.getCurrentRow();
                    Row selectedRow = objectFackeVO.getRow(nodeBinding.getRowKey());
                    System.out.println("selectedRow : "+selectedRow);
                    System.out.println("selectedRow - map Id1 : "+selectedRow.getAttribute("Id1"));
                    System.out.println("selectedRow - obj : "+selectedRow.getAttribute("Obj"));
                    DCBindingContainer bc = (DCBindingContainer)this.getBindings();
                    ViewObject mapViewVO = bc.findIteratorBinding("MapView1Iterator").getViewObject();
                    mapViewVO.setWhereClause(null);
                    mapViewVO.setWhereClause("ID1 = '"+selectedRow.getAttribute("Id1")+"'");
                    mapViewVO.executeQuery();
                    AdfFacesContext.getCurrentInstance().addPartialTarget(this.tt2);
                }
            //          else if (nodeStuctureDefname.equalsIgnoreCase(employeesDef)){
            //          System.out.println("Insideeeeee OBJECT -> OBJECT_DETAIL -> OBJECT_ATTRRRSSSSSSSSSS");
            //          }
                else{
                    //what the heck did the user click on? Ask him ;-) }
                    System.out.println("Insideeeeee Nothingggggggggggggggggggg.........");
                }
               
                //*********************************
               
            }
        }

ADF : ViewCriteria : Persisting Query Criteria Results Across Sessions with Oracle MDS

ViewCriteria : Persisting Query Criteria Results Across Sessions with Oracle MDS

Three setups explained in this:
Setup1: store viewcriteria saved search in MDS
Setup2: store <af:table - column change in MDS
Setup3: override <af:table - column persistant change not to store in MDS for particular column.

Setup1:store viewcriteria saved search in MDS

Note :
From the above link we will be able to store all searched criteria in to MDS and it will be retrived next time when the same user logs in.

Setup2: store <af:table - column change in MDS

Enabling Implicit Personalization Across Session


But: If we want to persist (store) the ADF table column changes also in to MDS, we have to add the below code into adf-config.xml file. (For more info refer -> http://blog.us.oracle.com/lift/?97408963)

############################################################################

<adf-faces-config xmlns="http://xmlns.oracle.com/adf/faces/config">
    <persistent-change-manager>
      <persistent-change-manager-class>oracle.adf.view.rich.change.MDSDocumentChangeManager</persistent-change-manager-class>
    </persistent-change-manager>
    <taglib-config>
       <taglib uri="http://xmlns.oracle.com/adf/faces/customizable">
        <tag name="showDetailFrame">
          <attribute name="expansionMode">
            <persist-changes>
              true
            </persist-changes>
          </attribute>
          <attribute name="contentStyle">
            <persist-changes>
              true
            </persist-changes>
          </attribute>
        </tag>
        <tag name="panelCustomizable">
          <persist-operations>
            all
          </persist-operations>
        </tag>
      </taglib>
      <taglib uri="http://xmlns.oracle.com/adf/pageeditor">
        <tag name="layoutCustomizable">
          <persist-operations>
            all
          </persist-operations>
          <attribute name="type">
            <persist-changes>
              true
            </persist-changes>
          </attribute>
        </tag>
      </taglib>
      <taglib uri="http://xmlns.oracle.com/adf/faces/portlet">
        <tag name="portlet">
          <attribute name="expansionMode">
            <persist-changes>
              true
            </persist-changes>
          </attribute>
        </tag>
      </taglib>
      <taglib uri="http://xmlns.oracle.com/adf/faces/rich">
        <tag name="column">
          <attribute name="displayIndex">
            <persist-changes>
              true
            </persist-changes>
          </attribute>
          <attribute name="frozen">
            <persist-changes>
              true
            </persist-changes>
          </attribute>
          <attribute name="noWrap">
            <persist-changes>
              true
            </persist-changes>
          </attribute>
          <attribute name="visible">
            <persist-changes>
              true
            </persist-changes>
          </attribute>
          <attribute name="width">
            <persist-changes>
              true
            </persist-changes>
          </attribute>
        </tag>
      </taglib>
    </taglib-config>

  </adf-faces-config>
#########################################################################


This above setup is applied for all the adf:table -> column -> visible attribute.

Setup3: override <af:table - column persistant change not to store in MDS for particular column.

Some times we may have requirement not to persist particular table-> column, In that case you can go with the below setup.


1. Select af:table -> column component -> go to Property inspector -> expand Advanced tab -> DontPersist select All.
(then all attributes will not be persisted for that particular column, actually this overrides the above adf-config.xml setup only for this particular column)

For More Info : http://fmwdocs.us.oracle.com/doclibs/fmw/E10285_01/web.1111/b31974/ad_persist.htm#CIHDEBFJ




Monday, 21 October 2013

ADF : ViewCriteria: ViewCriteria -> In Advance Mode -> Customization

ViewCriteria: In ViewCriteria -> In Advance Mode -> 

 How to remove drop down choice.


http://myforums.oracle.com/jive3/thread.jspa?messageID=6987958&

http://weblog.singhpora.com/2012/04/how-to-showhide-operators-in-adfquery.html


<ViewCriteriaRow
  Name="vcrow50"
  UpperColumns="1">
   <ViewCriteriaItem
     Name="LastUpdateDate"
     ViewAttribute="LastUpdateDate"
     Operator="="
     Conjunction="AND"
     Required="Optional">
        <CompOper
            Name="LastUpdateDate"
            ToDo="-1"
            Oper="BEFORE"
        </CompOper>

   </ViewCriteriaItem>

Hide some of the fields from "Add Fields" option of View Criteria


http://myforums.oracle.com/jive3/thread.jspa?threadID=1272634&tstart=30





How to Create Custom Operators.

http://docs.oracle.com/cd/E24382_01/web.1112/e16182/web_search_bc.htm#ADFFD2457

http://myforums.oracle.com/jive3/thread.jspa?messageID=7061788&

###############################################################
 <ViewCriteriaRow
      Name="vcrow0"
      UpperColumns="1">
      <ViewCriteriaItem
        Name="Salary"
        ViewAttribute="Salary"
        Operator="="
        Conjunction="AND"
        Value=""
        Required="Optional">
        <CompOper
            Name="Salary"
            ToDo="1"
            OperDescStrCode="greater_salary"
            Oper=">10000"
            MinCardinality="0"
            MaxCardinality="0" >
            <TransientExpression><![CDATA[ return " > 10000"
                ]]></TransientExpression>
        </CompOper>
        </ViewCriteriaItem>
    </ViewCriteriaRow>



##############################################################