Tuesday, 28 January 2014

ADF: Getting the current row clicked.

If your application has table and if user is clicking some of the action component(Button, Link) in the table, How will you get the user clicked row in the back-end code.

See one of the easiest solution below.


DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        DCIteratorBinding iteratorBinding = (DCIteratorBinding)bindings.get("sampleVO1Iterator");
        //_logger.info("iteratorBinding===="+iteratorBinding);
       

        if (iteratorBinding != null) {
            sampleVORowImpl currentRow = (sampleVORowImpl)iteratorBinding.getCurrentRow(); // this is the user clicked row.

In the attached source code, there is page1.JSF page, run it and click on the manager id(id click here) and check in the console. In the console whichever manager id you have clicked it will be printed.

Download the source code below.
Download

ADF : How to get the value of the Input Parameter Definitions through the code.

String scopeVariableValue = (String)this.getElExpression("#{pageFlowScope.variable}"); // pageFlowScope.variable is a Input Parameter Definitions variable

    public Object getElExpression(String el) { 
      
        FacesContext objFacesContext = FacesContext.getCurrentInstance();
        ELContext objELContext = objFacesContext.getELContext();
        ExpressionFactory objExpressionFactory = objFacesContext.getApplication().getExpressionFactory();
        ValueExpression objValueExpression =
            objExpressionFactory.createValueExpression(objELContext, el, Object.class);

        return objValueExpression.getValue(objELContext);
    }



Tuesday, 21 January 2014

Life Cycle of ADF

Different phases of ADF Life Cycle

1)Restore View:  Whenever Url lands in the browser, the view name in the URL is compared in the databindings.cpx file and from the cpx file, view path is available. If there is no state(Invoking the url first time) on the server side, response will be rendered. If there is any state on server side, view will follow the further life cycle steps.

2)Apply Request Values:  These are the user input values, these values will be applied to the ADF components.

3)Process Validations: If there are any validations provided to the ADF components, those validations will be evaluated. If any validation fails, error response will be rendered.

4)Update Model Values:  The values provided by the user enters in to the model layer.

5)Validate Model Values: If there are any model layer validations (entity level validations) they will get evaluated. If any validation fails, error response will be rendered.

6)Invoke Application: If any action(button click) gets execute, navigation to the different view will take place and response will be rendered. If there is no action this phase will be skipped.

7)Render Response:  The new component values will be rendered and the state gets stored on the server