Tuesday, 6 October 2015

ADF : Resolved! Failed to convert internal representation error in ADF

While development some times this error occurs in VO's and EO's in ADF.

Main Cause : The main cause of this error is that the Datatype mismatch of the Columns in Database and  in ViewObject (or Entity Object).

For example : Suppose you have a DEPT_ID String Column in the Database of type String and in EntityObject or ViewOject its type is Integer then this error will occur.

What happens is that when the framework tries to convert the value in the database i.e (String in this case like 'DEPT_01') to the type defined in the ViewObject or EntityObject i.e. Integer, then it fails to type cast 'DEPT_01' to Integer as it contains character that cannot be converted to Integer and this error is thrown.

Solution : Make sure the all the datatype of all the attributes in the ViewObect or EntityObject are in Sync with the database and there is not mismatch.

Monday, 21 September 2015

ADF : Implementing Contains Search in AutoSuggest | Change the default "STARTSWITH" behaviour of AutSuggest to "CONTAINS" in ADF

Hello all,

This post is about changing the default AutoSuggest behaviour in ADF Components.

We had a requirement to implement AutoSuggest search on "CONTAINS" basis. Normally the AutoSuggest component in ADF works on "STARTSWITH" basis but we had a requirement in which we had to implement contains search in ADF.

Whenever AutoSuggest is invoked a method applyViewCriteria(ViewCriteria, boolean) in ViewObjectImpl is called.

So to change the behaviour of AutoSuggest we have to override this method in ViewObjectImpl.

Go to the ViewObjectImpl class of the ViewObject on the basis of whome LOV is made and paste the following code.


    @Override
    public void applyViewCriteria(ViewCriteria viewCriteria, boolean b) {
        super.applyViewCriteria(supressStartsWithClauseForLov(viewCriteria), b);
    }
    
    public ViewCriteria supressStartsWithClauseForLov(ViewCriteria vc){
        if(vc != null && vc.getName().contains("__lov__filterlist__vcr__")){
            ViewCriteriaRow currentRow = (ViewCriteriaRow)vc.getCurrentRow();
            if(currentRow != null){
                List criteriaItems = currentRow.getCriteriaItems();
                for(int i = 0 ; i < criteriaItems.size() ; i++){
                    ViewCriteriaItem object = (ViewCriteriaItem)criteriaItems.get(i);
                    if(object != null){
                        System.out.println("Operator is : "+object.getOperator());
                        if("STARTSWITH".equals(object.getOperator())){
                            object.setOperator("CONTAINS");
                        }
                    }
                }
            }
        }
        return vc;
    }


Now, you are ready to go.

References : http://andrejusb.blogspot.in/2014/11/suppressing-adf-lov-like-operator.html