Showing posts with label ADF. Show all posts
Showing posts with label ADF. Show all posts

Sunday, January 5, 2014

Running ADF in High availability

Some of the things you should consider when developing ADF application running in HA environment is changes to pageFlowScope or ViewScope during a request. Making ADF aware of the changes you made to a ViewScope or pageFlowScope params is essential to replicate the changes across cluster.


To accomplish this:
1- Set the adf-scope-ha-support parameter inside adf-config.xml config file to true, this will make sure that changes will automatically replicated within a cluster.
 < adf-controller-config xmlns="http://xmlns.oracle.com/adf/controller/config">
 < adf-scope-ha-support>true</adf-scope-ha-support> </adf-controller-config>

2-  marking the scope is Dirty by adding additional code after scope changes:
    ControllerContext ctx = ControllerContext.getInstance();
    ctx.markScopeDirty(AdfFacesContext.getCurrentInstance().getViewScope());

note if you are making a change by reference without putting (replacing) param value in the Map you must call markScopeDirty.

Example:

Map<String, Object> viewScope = AdfFacesContext.getCurrentInstance().getViewScope();
MyObject obj = (MyObject)viewScope.get("myObjectName");
Obj.setFoo("newValue");

Putting value again in the map will replicate the change across cluster without calling markScopeDirty method.
viewScope.put("myObjectName");

http://docs.oracle.com/cd/E12839_01/core.1111/e10106/adf.htm

Friday, December 14, 2012

Using Bean in Expression language with parameter to check user Authorization

There were many questions in how to build a customized bean and use it in expression language to return user authorization based on specific parameter passed through expression language. In here I will describe the steps in how to build your own bean, accessing its methods and passing parameter to it.

This first step is develop the method that you want to receive your parameter and return the success or failure logic, the authorization roles in my scenario are stored in ViewObject based on dynamic SQL statements that loads the roles from different tables depending on some HR and Assignment statues:


public class AuthorizationBean {
 
    private ApplicationModule appModule=ADFFacesHelper.getAppplicationModule("AppModuleDataControl");

    public AuthorizationBean() {
        super();
    }

    
    public boolean getUserInRole(String RoleCode){
        boolean havePriv=false;
        ViewObject userRoles=appModule.findViewObject("UserRolesVO1");
        RowSet rowSet=userRoles.getRowSet();
        Row row=rowSet.first();
        while(row!=null){         
            String roleCode=row.getAttribute("RoleCode").toString();            
            if(roleCode.equals(RoleCode)){
                havePriv=true;
            }
            row=rowSet.next();
        }
        return havePriv;
    }
 }

The next step is define a bean that will act as an interface between the Authorization bean and expression language, it will receive the parameter from expression language and pass it to a method developed earlier, the class should implements HashMap interface and implements get(Object) method:

import java.util.HashMap;

public class CallAuthorizationBean extends HashMap {
    public CallAuthorizationBean() {
        super();
    }

    public String get(Object key) {
        AuthorizationBean authorization=new AuthorizationBean();
         return ""+authorization.getUserInRole((String)key);
    }
}

Finally, you can call the customized method using expression language like this:
#{Authorization['20180100']=='false'}

Wednesday, January 11, 2012

Arabic Hijra Calender - UM AL-Qura


I almost done developing Hejira Calender using ADF as declarative component. The calender is based on Um AL-Qura, and can be used inside pages, fragments, popups and tables. The calender relies on database and uses pure ADF without any JavaScript injection.




Monday, December 12, 2011

I did technical review on this book - Oracle ADF Enterprise Application Development—Made Simple

  • Develop an ADF application quickly using database tables together with common ADF user interface components and data visualization components.
  • Estimate the effort required to build an ADF enterprise application.
  • Organize the development team, choose support tools, and write development guidelines to ensure a uniform development approach.
  • Set up the necessary infrastructure and configure a development workstation.
  • Develop necessary templates and framework classes to allow productive and flexible development.
  • Build a complete application using all the enterprise support tools.
  • Test your ADF enterprise application at the component, integration, and system levels.
  • Use skinning to change the look of the application to correspond to the enterprise's visual identity.
  • Customize the application to meet the needs and expectations of different users.
  • Secure the enterprise application and assign roles for specific functionality.
Book in Details

    Sunday, March 21, 2010

    Inserting Data in hidden detailed table after inserting in Master one

    When working with a friend trying to insert data in a detailed table (without dropping the detailed table in a page view associated with its master table), and getting some of the detailed table column values from the same data inserted in the master table, we came across to use the following code:


    public String insert_master_detail() {

            BindingContainer bindings = getBindings();
            OperationBinding operationBinding = 
                                             bindings.getOperationBinding("Commit");
            Object result = operationBinding.execute();
            //Perform a commit on the master table binding on page view
          
            if (operationBinding.getErrors().isEmpty()) {
            //if transaction succeeded then continue adding data to detail
              table


            String amDeff = "model.AppModule";
            String config = "AppModuleLocal";
            ApplicationModule am =  
                   Configuration.createRootApplicationModule(amDeff, config);
            ViewObject vo = am.findViewObject("DetailTabke1");
            //connect to the detail view using the application module 
          
           BindingContainer bc = 
              BindingContext.getCurrent().getCurrentBindingsEntry();
           //get the current page bindings
          
        
            JUCtrlAttrsBinding Code = 
                                  (JUCtrlAttrsBinding)bc.get("Code");        
            
            JUCtrlAttrsBinding Name = 
                                      (JUCtrlAttrsBinding)bc.get("Name");  
           //get list of data added to the master table that will be add to 
            the detailed table
          
            NameValuePairs pairs = new NameValuePairs();
            pairs.setAttribute("Code",
                           Code.getAttributeValue().toString());
            Number n=new Number(1);
            pairs.setAttribute("No", n);
            pairs.setAttribute("Name",
                          Name.getAttributeValue().toString());
            pairs.setAttribute("Status", "00020");
            pairs.setAttribute("Typee", "051");
            pairs.setAttribute("StartDate", "1430/01/01");
            pairs.setAttribute("EndDate", "1430/01/01");
            
            Row ActivityTaskRow = vo.createAndInitRow(pairs);
            vo.insertRow(ActivityTaskRow);
            //create a Name value attribute and calling createAndInitRow
              with name value attributes for detailed table that will be 
              used to insert row in table
        
            am.getTransaction().commit();
            //commit the transaction and then release the connection


            Configuration.releaseRootApplicationModule(am,true);
            }
            return null;
     }


    This code is added as an action to submit button and should be called after creating a new row in the master table.

    Wednesday, March 17, 2010

    Creating dependent list of values using JDeveloper 11g

    In this post I will discuses how to build a dependent list of value, in which two lists are involved.
    This example is built on scott Emp/Dept tables in which it gets the list of employees working in specific department using single selection list.

    So, after creating the required application using JDeveloper 11g, I created an ADF business components from tables attached to scott schema. When using the wizard it should create EMP and DEPT entities, views and a view link describing the constraints the exists between the dept_id in EMP table and dept_id in DEPT table.

    The model should look somthing like the following figure, the view FKDeptnolink construct the relation between the two tables. Modify the DeptView and set OrderBy clause to order values by Dept_no, this will help to get Dept_no filed that correspond to Dept_name filed from the iterator that will be defined later in next steps.


    then, create a view page in the view controller, this page will contain our list of values.
    From data control drag the DeptView1 component and drop it on the page, select ADF Select One Choice component.


    In the Edit List Binding, the Display Attribute select Department Name, and click ok.


    Tuesday, February 23, 2010

    Installing Weblogic Server 10.3 and extending it to support ADF

    When I started working on ADF application development I thought when I am done from development, I just have to deploy the application to weblogic server, then running the application and it will run with no extra work to do.

    But, it seems there some confusion when installing and deploying ADF applications to weblogic server, so i wanted to stat it in a step wise procedure.

    This is a basic steps carried out through installation of production weblogic server:

    1- Download weblogic server 10.3 and latest version of JDeveloper from oracle website.

    2- Install weblogic into new BEA home, my installation is carried out on windows 2008 R2 server 64-bit. My installation directory is C:\BEA\Middelware.

    3-  Deselect the components that you don't need such as :
    • Web 2.0 http pub-sub server
    • Weblogic Web Server Plugins
    • UDDI and Xquery Support
    • Server Examples
    • Workshop


    Friday, February 5, 2010

    JDeveloper, and Weblogic:Accessing Detailed Views from Master One Using Java

    One of the most addressable issues in Oracle ADF Application Development is how to access your business model components through Java method call. Accessing the parent view that requires a bind variable and attaching it to a page doesn't mean that the details views related to master one at data model level will execute with same bind variable.

    In this post we will address the problem of how to call a master view with bind variable set through Java call ? and at the same time to fetish data from detail views ?

    First of all make sure that your data model is built to reflect master detail relation. A view link between Master and Detail should be created at first and added to Data Model, like simple two key join in a select statement:

    As you note a country-City relation ship exists, in which you must get country to get its cities.
    The country view has a bind variable set at run-time through expression language and called through execute with params method call. This what happened at normal page flow navigation. But, in our case we want to set the bind variable using Java code and then looping thourgh to get the detailed cities.

    Tuesday, February 2, 2010

    JDeveloper, Weblogic and ADF: Security in Oracle ADF and Session invalidate

    In enterprise applications that require user authentication, a user can't navigate back to a cached page. When developing applications using JDeveloper11g ADF, I encountered two problems.

    First, how to kill a user session when clicking logout button, as explained below:
    In ADF, you might use SessionScope to create variables or beans that can be carried out during the life cycle of a user session. Destroying the session bean or setting a session variable to null doesn't mean that the session is killed, to kill a session you have to:

    1- Add a method call to logout button Action can be in the managed or backing bean and name it logout_action();

    2- The code is used to invalidate the user session then redirect the page to your login screen displayed below:

            FacesContext fc = FacesContext.getCurrentInstance();
            ExternalContext ectx = fc.getExternalContext();      
            HttpSession session = (HttpSession)ectx.getSession(false);
            try {
                session.invalidate();          
                ectx.redirect("../loginpage");
                fc.responseComplete();
            } catch (Exception exp) {
                ectx.redirect("../loginpage");
                fc.responseComplete();
            }

    * note if you are using a bounded task flow and your loging screen exists in unbounded task flow located one level up then consider navigating through floders using (..) till login screen location.