Friday, October 4, 2013

ADF 11G : How to Customize Default ADF BC Error Messages?

ADF 11G : How to Customize Default ADF BC Error Messages?










Class under Model:
package model;

import java.util.ListResourceBundle;

public class NeelmaniCustomModelMessageBundle extends ListResourceBundle {
    private static final Object[][] emp_email_UK =    new String[][] { { "EMP_EMAIL_UK", "This Email is already Taken by other Employees!"} };


    protected Object[][] getContents() {
        return emp_email_UK;
    }
}




Class under ViewController:
package view;

import java.sql.SQLIntegrityConstraintViolationException;

import oracle.adf.model.binding.DCErrorHandlerImpl;

import oracle.jbo.DMLConstraintException;

public class NeelmaniErrorHandler extends DCErrorHandlerImpl {
    public NeelmaniErrorHandler() {
    super(false);
    }
    public NeelmaniErrorHandler(boolean b) {
    super(b);
    }

    @Override
    protected boolean skipException(Exception exception) {
        if (exception instanceof DMLConstraintException) {
        return false;
        } else if (exception instanceof
        SQLIntegrityConstraintViolationException) {
        return true;
        }
      
    
        return super.skipException(exception);
    }
}








How to Allow af:inputText for Spell Checking ?

How to Allow af:inputText for Spell Checking ?







Tuesday, October 1, 2013

How to select the rows in af:table with checkBox?


How to select the row in af:table with checkBox?








    public String findSelectedRows() {
        ViewObject vo = null;
        ApplicationModule am = null;
        am = getAMInstance("AppModule");
        vo = am.findViewObject("EmployeesView1");
        Row[] selRowArr = vo.getFilteredRows("Selected", Boolean.TRUE); //Selected is the Transient(boolean) attribute under the VO
        System.out.println(selRowArr.length+ "Row Selected");

        return null;
    }
 
    public static ApplicationModuleImpl getAMInstance(String AM) {
           
                FacesContext fc = FacesContext.getCurrentInstance();
                Application app = fc.getApplication();
                ExpressionFactory elFactory = app.getExpressionFactory();
                ELContext elContext = fc.getELContext();
                ValueExpression valueExp =
                    elFactory.createValueExpression(elContext, "#{data."+AM+"DataControl.dataProvider}",
                                                    Object.class);

                return (ApplicationModuleImpl)valueExp.getValue(elContext);
         
        }

How to get the Handle of any UI component without binding?

How to get the Handle of any UI component without binding?


    public String callAction() {

        UIComponent component = findComponentInRoot("it1"); //it1 is the Id of the UI
        System.out.println(component.getId());
        component.setRendered(false);
        return null;
    }

    public static UIComponent findComponentInRoot(String id) {
        UIComponent component = null;

        FacesContext facesContext = FacesContext.getCurrentInstance();
        if (facesContext != null) {
          UIComponent root = facesContext.getViewRoot();
          component = findComponent(root, id);
        }

        return component;
    }
    public static UIComponent findComponent(UIComponent base, String id) {
        if (id.equals(base.getId()))
          return base;
     
        UIComponent kid = null;
        UIComponent result = null;
        Iterator kids = base.getFacetsAndChildren();
        while (kids.hasNext() && (result == null)) {
          kid = (UIComponent) kids.next();
          if (id.equals(kid.getId())) {
            result = kid;
            break;
          }
          result = findComponent(kid, id);
          if (result != null) {
            break;
          }
        }
        return result;
    }

ADF 11G : How to Customize af:query ?

ADF 11G : How to Customize af:query ?