Sunday, 16 March 2014

Book Review: Oracle ADF Enterprise Application Development - Made Simple: Second Edition

Hi All, recently i got privilege to review the book from Packt Publications. I suggest every Senior  ADF Developer/ Project lead to go through this book. It give you complete Enterprise Application Development in ADF from the scratch.
Each and every point explained very clearly like development, building the application etc.



After going through this book, you can successfully plan project, develop, Test, and deploy using Oracle ADF.

Overview
  • Utilize best practices for real-life enterprise application development
  • Plan and estimate your very own ADF project
  • Successfully organize your code and your team for maximum efficiency
You can Purchase the book from the below sites

Sunday, 16 February 2014

Passing Parameters to Taskflow

Hi friends today i am going to post about the passing parameters to Task flow. I have seen most of the developers facing problem in passing parameter to TF.
I have created Business components on Employees table. I have added where clause to the query as shown below and bind variable.


Create custom method in AmImpl.java class which is used to filter the employees based on DepartmentId



Now create one BoundedTF (employeeTF) and add the custom method (default activity) and view activity to show the list of employees as table.



Go to overview tab --> parameters --> set the parameter as shown below



Now go to adfc-config.xml file and drag and drop view activity and employeeTF.
Double click on view activity and generate the main.jspx page and drag & drop InputText and button as shown below to pass department ID.



Select the EmployeesTF go to property inspector and pass the value to DeptID #{pageFlowScope.deptID}



Now create bindings for input text and action listener method for button of main.jspx page and set the class to backingBeanScope. Use the below code to set the value in pageFlowScope.

    public void executeDeparment(ActionEvent actionEvent) {
        // Add event code here...
        AdfFacesContext.getCurrentInstance().getPageFlowScope().put("deptID", deptid.getValue().toString());
    }

Now run the page




Thanks :) Happy Learning




Friday, 20 December 2013

Generate the DB sequence number without loosing

Generally we use sequence number in EntityImpl class create() method using the following code

       SequenceImpl seq=new SequenceImpl("EMPLOYEES_SEQ",getDBTransaction());
        setEmployeeId(seq.getSequenceNumber());

or we will set expression in default attribute of Entity Object xml file. If we follow this approach we will loose the sequence numbers. To avoid this use the following approach

Step 1: Go to entity object xml file  --> select the EmployeeID -- > go to defalu value and set -999 or -9999. Because the sequence number never reach the negetive value.


Step 2: Generate the java class for EO and override the doDML() method

    protected void doDML(int operation, TransactionEvent e) {
     
        if(operation==this.DML_INSERT){
            SequenceImpl seq=new SequenceImpl("EMPLOYEES_SEQ",getDBTransaction());
            this.setEmployeeId(seq.getSequenceNumber().intValue());
        }
        super.doDML(operation, e);
    }
   
Step 3: Run the application

Wednesday, 18 December 2013

Populate dynamic Panel Accordion in ADF page

In this post i will show you how to create dynamic panel accordion. Sometimes you may get requirement to populate the accordion dynamically based on user login or some criteria.

Step1: Create the Business components on Department Table.



Step2: Create on jspx page --> go to data bindings and create Tree Bindings as shown below


Step3:  Add the data source DepartmentView1 and add the rule. Select the department name as shown below.




Step4: Drag and drop panel accordion on jspx page. Select the af:showDetailItem in structure window and surround with af:ForEach




Step5: Set the attributes in forEach tag as shown below.



Step6:  Change the Text attribute value to #{dept.DepartmentName} in af:showdetailsItem



Step7: Run the jspx page 




Tuesday, 17 December 2013

Hiding unwanted operators in Advance mode of ADF Query Search

Sometimes you may get a requirement to hide the unwanted operators in advance mode of adf query search.
 I have created view criteria on employess table with FirstName. Now the requirment is i want to hide the BETWEEN and NOTBETWEEN operators for FirstName Field in advance search mode.
By using the below code you can hide the operators.

         <CompOper 
           Name="Name" 
           Oper="BETWEEN" 
           ToDo="-1" 
           MinCardinality="0" 
           MaxCardinality="0"/> 

Here is my view criteria code.

     <ViewCriteriaRow
      Name="EmployeesViewCriteria_row_0"
      UpperColumns="1">
      <ViewCriteriaItem
        Name="FirstName"
        ViewAttribute="FirstName"
        Operator="="
        Conjunction="AND"
        Value=":bFname"
        IsBindVarValue="true"
        Required="Optional">
         <CompOper 
           Name="Name" 
           Oper="BETWEEN" 
           ToDo="-1" 
           MinCardinality="0" 
           MaxCardinality="0"/> 
         <CompOper 
           Name="Name" 
           Oper="NOTBETWEEN" 
           ToDo="-1" 
           MinCardinality="0" 
           MaxCardinality="0"/>          

          
        </ViewCriteriaItem>
      <ViewCriteriaItem
        Name="LastName"
        ViewAttribute="LastName"
        Operator="="
        Conjunction="AND"
        Value=":bLname"
        IsBindVarValue="true"
        Required="Optional">
      
        </ViewCriteriaItem>
    </ViewCriteriaRow>


Thursday, 3 October 2013

Update attribute value in View Object Programmatically

In this post i willl explain you how to update the attribute value of a Row.

The following code will find the EmployeeId 100 in Employee View object and update the FirstName.

        Number empid=100;
       // create the key object
        Key key = new Key(new Object[] { empid });
        Employees1ViewImpl vo = (Employees1ViewImpl)this.getEmployees1View1();
        //find the row using key reference in View Object.
        Row k=vo.getRow(key);
        //using this method we can set the new value to FirstName  
        k.setAttribute("FirstName", "stev");
        this.getDBTransaction().commit();
       System.out.println("the name is");

Programmatically Insert New Row in DB using View Object reference

We have seen declarative approach to insert new row in database.

In this post i will explain you how to insert new row Programmatically.

1. Create the AppModuleImpl class and also create the java class for respective ViewObject. In this example i am working on EmployeeView. So i have generated EmploueeViewImpl java class.

2. Create the user defined method in AppModuleImple calss as shown below.

    public void createNewRow(){

//get he EmployeeViewImpl class instance
        EmployeesViewImpl vo=this.getEmployeesView1();

       // Create new row to insert data
        Row r=vo.createRow();
       
//Set the values to respective attributes.
            r.setAttribute("EmployeeId", 509);
            r.setAttribute("FirstName", "test");
            r.setAttribute("LastName", "test");
           
            r.setAttribute("Email", "test12@gmail.com");
            r.setAttribute("PhoneNumber", "800000444");
            r.setAttribute("HireDate", new Timestamp(System.currentTimeMillis()));
            r.setAttribute("JobId", "IT_PROG");
            r.setAttribute("Salary", 5000);
            r.setAttribute("CommissionPct", "");
            r.setAttribute("ManagerId", "");
            r.setAttribute("DepartmentId", 340);
//insert row in the view object
            vo.insertRow(r);
//commit the transaction
            this.getDBTransaction().commit();
       
        }