Tuesday, July 22, 2014

Select Many Choice use in ADF

Hi All, if we want to select multiple values from the list box then we will make use of inbuilt component "af:selectmanychoicebox" in ADF. follow these steps to use this component.

Step1: Create view object for example I have created "DepartmentsVO"

Step2: make an attribute as lov from "DepartmentsVO"

Step3:  create one jspx page and add List binding in page definition as shown below




Step 4: from component pallete select "Select Many Choice component" and it will ask for bindings add bindings like below and click on ok




Step 5: Run the page you will get the output like this


Friday, July 18, 2014

Adding Validation to the Criteria in ADF

Hello Guys if you want to add validation to the input text fields of the Criteria please follow the steps.

Step1: Create a view Criteria as shown below

Step2:

Drop this named criteria from data controls to a page as Query Panel





Step3:

Drop the View Object as form on the same page

Step4: add Partial Target of the form to Criteria




Step5: Select af:Query Component in Structure window and change the query listner property from Property Inspector as shown below(Default query Listner value is: #{bindings.EmployeesEOViewCriteriaQuery.processQuery} ) save this value which needs to be used in bean class




Step6:

write the following code in the bean class:

package com.test.beans;

import com.mobile.model.TestAMImpl;

import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.MethodExpression;

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

import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCDataControl;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.adf.view.rich.event.QueryEvent;

import oracle.binding.BindingContainer;

import oracle.jbo.ApplicationModule;
import oracle.jbo.server.ViewObjectImpl;

public class FormValidate1 {
    public FormValidate1() {
    }

    public void customQueryListner(QueryEvent queryEvent) {     // Add event code here...
       
       String fname = null;
        String lname = null;
        BindingContext ctx = BindingContext.getCurrent();
        BindingContainer cont = ctx.getCurrentBindingsEntry();
        DCIteratorBinding dci = (DCIteratorBinding) cont.get("EmployeesEOView1Iterator");
        ApplicationModule am  = dci.getDataControl().getApplicationModule();
        //ApplicationModule am  = dci.getDataControl().
//        cont.ge
       //  ApplicationModule am  = dci.geta
        DCDataControl dc = ctx.findDataControl("TestAMDataControl");
        TestAMImpl ta =(TestAMImpl) dc.getApplicationModule();
       
        ViewObjectImpl voi = (ViewObjectImpl)dci.getViewObject();
        fname = (String)voi.getNamedWhereClauseParam("bFirstName");
        lname = (String)voi.getNamedWhereClauseParam("bLastName");
        if(fname.length() >4) {
        FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("Name should not be lessthan 4 charecters"));
        }
        else if(am.getTransaction().isDirty()) {
            FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("Please Save the changes or Undo Them"));
        }
       
        else{
           
         String el = "#{bindings.EmployeesEOViewCriteriaQuery.processQuery}";
            invokeEL(el, new Class[]{QueryEvent.class}, new Object[]{queryEvent});
           // invokeEL(el, null,  new Object[]{queryEvent});
        }
       
       
    }
   
   
    public static Object invokeEL(String el,Class[] paramtypes, Object[] params) {
        FacesContext cont = FacesContext.getCurrentInstance();
        ELContext elcont =  cont.getELContext();
        ExpressionFactory ef = cont.getApplication().getExpressionFactory();
        MethodExpression exp = ef.createMethodExpression(elcont, el, Object.class, paramtypes);
        return exp.invoke(elcont, params);
    }
}

Step7:
Run the application and give charecters for firstname more than 4 you will get error message.









Hide Query By Example of PanelCollection on page load

Hi All, If there is a table with filterable is true. If you want to display QueryByExample then surround this table with panelCollection....