Wednesday, 30 October 2013

ADF : VO Performance Increase:

VO Performance Increase:




1.    Mark VOs as insert only. This will avoid unnecessary select queries from being issued.
 
2.       2. Set VO in forward only mode which will prevent caching of previous sets of rows.

3.       3. Enable EO batch processing which reduces no of trips to database.

4.      4. Commit records at regular intervals.

5.   Set setListenToEntityEvents to false.




Through JAVA : The Same thing can be set using Java (Programatically)

VO Impl change

---------------------------------------------------------------
  voi.setListenToEntityEvents(false);
                    voi.setMaxFetchSize(0);
                    voi.setAccessMode(RowSet.FORWARD_ONLY);
                    if(voi.getViewDef() != null){
                        voi.getViewDef().setFetchMode(voi.FETCH_AS_NEEDED);
                        voi.getViewDef().setInheritPersonalizationStrValue("merge");
                    }

 EO Impl change

----------------------------------------------------------------
if(voi != null && voi.getViewDef() != null){
                        EntityReference[] er =  voi.getViewDef().getEntityUsages();
                        if(er != null){
                            for(EntityReference e:er){
                                   EntityDefImpl eoDefImpl = e.getEntityDef();
                                    if(eoDefImpl != null)
                                    eoDefImpl.setBatchThreshold(10);
                            }
                        }
                    }

NOTE: If Entity has BLOB/CLOB attributes then eoDefImpl.setBatchThreshold(10); will not work.

It starts giving different error like : RowAllreadyDeleteException .....etc.
MoreInfo: http://waslleysouza.com.br/en/2014/08/enabling-update-batching-in-adf/



Friday, 25 October 2013

ADF : Skin Selection

ADF : Skin Selection









ADF Security Implementation

ADF Security Implementation






It Creates the jazn-data.xml – to create user, roles and grants.

Define User
admin
normal



Define Role
admin – role
normal – role

Give Grants
1.       Page Level Security


1.       Field Level Security
#{securityContext.userInRole['staff']}







ADF : Oracle extended template use

oracle extended template


1.       Download the oracle extended template source code from http://www.oracle.com/technetwork/developer-tools/adf/uishell-093084.html
Use this link http://www.oracle.com/technetwork/developer-tools/adf/394631.zip. In the above site to download zip file.
2.       You will get like this in jdeveloper. Change according to your change.


1.       Take the jar file of this.


1.        Use it in SecondUI project library.







ADF : View Object - Operations

View Object - setCurrentRowWithKey

 https://blogs.oracle.com/shay/entry/selecting_a_row_in_a_table_to


Thursday, 24 October 2013

ADF Expression Use on JSPX

ADF Expression Use on JSPX


####################
My Requirement is i should disable the button if table rowcount is > = 500

Use -> #{bindings.MapView11.estimatedRowCount ge 500}  on Disabled property of button

########################IN JSPX ##########################

 <af:commandButton text="#{bindings.MapView11.estimatedRowCount}"
                          binding="#{backingBeanScope.backing_ObjectMain_ObjectFake_MapView.cb1}"
                          id="cb1" partialTriggers="tt1 tt2 t1"
                          disabled="#{bindings.MapView11.estimatedRowCount ge 500}"/>


ADF Working Flow

ADF Working Flow





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.........");
                }
               
                //*********************************
               
            }
        }