Showing posts with label JDeveloper 11g. Show all posts
Showing posts with label JDeveloper 11g. Show all posts

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);
    }
}








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);
         
        }

Monday, September 30, 2013

ADF 11G : Implement Multiple Selection using View Criteria

ADF 11G : Implement Multiple Selection using View Criteria











Friday, September 27, 2013

Display the Selected Row in ADF Table

How to Display the Selected Row in ADF Table?



We can display the current(Selected) record number along with the tolal Number of record on any of the ADF table.



#{bindings.EmployeesView1Iterator.rangeStart+bindings.EmployeesView1Iterator.currentRowIndexInRange+1}/#{bindings.EmployeesView1Iterator.estimatedRowCount}

Thursday, September 26, 2013

ADF 11G : Clearing af:query Programatically

  ADF 11G : Clearing af:query Programatically

  public String customClearAFQuery() {
     
        RichQuery queryComp = qryId1; //qryId1 is the Id of af:query
        QueryModel queryModel = queryComp.getModel();
        QueryDescriptor queryDescriptor = queryComp.getValue();
        queryModel.reset(queryDescriptor);
        queryComp.refresh(FacesContext.getCurrentInstance());
        return null;
    }

ADF 11G : Check if VO is Dirty

ADF 11G : Check if VO is Dirty

Approach 1: Click 

Approach 2: 
    public String save() {
        System.out.println(isDirty()); //Call the method to check if VO is Dirty
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("Commit");
        Object result = operationBinding.execute();
        if (!operationBinding.getErrors().isEmpty()) {
            return null;
        }
        return null;
    }


    public boolean isDirty(){
    boolean dirty=false;
    BindingContext bindingCtx = BindingContext.getCurrent();
    DataControlFrame dataCtrlFrame = bindingCtx.findDataControlFrame(bindingCtx.getCurrentDataControlFrame());
    Collection dataCol = dataCtrlFrame.datacontrols();
    for (DCDataControl dcDaCtrl : dataCol) {
    if (!dcDaCtrl.getName().equals("NeelmaniAMDataControl1") && !dcDaCtrl.getName().equals("NeelmaniAMDataControl2"))
        dirty = (dcDaCtrl.isTransactionDirty()==true) ? true :false;
    }
    return dirty;
    }

ADF Faces : Handling Dialog

 ADF Faces : Handling Dialog









   public void okAction(DialogEvent event){
         
            if (event.getOutcome().equals(DialogEvent.Outcome.yes)){
                           System.out.println("Component Regreshing...");
            }
            else if(event.getOutcome().equals(DialogEvent.Outcome.no)){
                           System.out.println("Canceled");
                }
    }

ADF 11G : Pagination

Pagination for ADF Table has been introduce by Oracle in Jdeveloper 11.1.1.7 Version.

We Need to set the ScrollPolicy attribute to Page.

Changes Needed:

scrollPolicy=”page” autoHeightRow=”0”







Rendered Vs Visible

Rendered Vs Visible


RENDERED: Making a field attribute's property RENDERED as false (Rendered=false) does NOT make the component to be part of JSF Tree.

VISIBLE: Making a field attribute's property VISIBLE as false (Visible =false) make the component to be part of JSF Tree, is sent to the client as part of HTML and is HIDDEN.

Thursday, May 16, 2013

ADF 11G: Set Current Date in af:inputDate

ADF 11G: Set Current Date in af:inputDate









    public String setCurrentDate() {
      
        Date convertedDate = new Date(Date.getCurrentDate());
                  String convertedDateString;
                  java.text.SimpleDateFormat displayDateFormat = new java.text.SimpleDateFormat ("MM/dd/yyyy");
                  convertedDateString = displayDateFormat.format(convertedDate.dateValue());
                 
                  id1.setValue(convertedDateString);
        id1.setRendered(true);
        return null;
    }


Wednesday, May 15, 2013

ADF 11G : Customize the page based on the isDirty Attribute in Business Component

Customize the page based on the isDirty Attribute in Business Component.
Click















Implmentation: Create an Attribute at EO level using Groovy Expression.

(entityState != 1)