Please disable your adblock and script blockers to view this page

Search this blog

Wednesday 18 September 2013

Using af:switcher in ADF Faces to dynamically render page components

Hello all,,
Sometimes we need to display page components on a condition basis , this can be achieved in adf using af:switcher component
Normally switcher component is a collection of multiple facets and on a given condition it decides that which facet should be rendered.

How to use af:switcher- see the steps

  • Create a Fusion web application and create business components using Departments and Employees table (HR Schema)
  •  Now create a page in view Controller and drop a switcher component from component palette
  • Switcher is pure server side component so it doesn't have any client representation, so next move is to add facets in af:switcher, to add facets in switcher,
    just right click--insert inside af:switcher-- facet



  • As in this tutorial i am going to show 2 tables(Departments U& Employees) so added 2 facets in af:switcher

  • Now time to drop tables in corresponding facets, Employees Table in Emp, Departments Table in Dept
  •  Now i have created a static List that has values D for Departments and E for Employees, when user selects D the Departments table will be shown and for E Employees table will be shown

  • to do this select af:switcher and go to FacetName property and open expression builder to write conditional expression
  •  Now run this page and select values in list to see- how switcher works

  Download Sample App Cheers :-)

Tuesday 17 September 2013

Bug in ADF 11g R2- Transient and Bind Valiable of Timestamp type

This is a bug in ADF 11g R2, and sometimes so much annoying for developer.

Bug Is-

  • Suppose you have created business components for Employees table of HR Schema, there is HireDate in Employees table , see it in EntityObject-

  • Now go to source and see, it is of type oracle.jbo.domain.Timestamp (default java representation of Timestamp database data type )

  • Now go to Employees ViewObject and create a transient variable for DOB(Date Of Birth)  and select it as Timestamp
  •  Now after this if developer tries to get or set value of this transient variable, it shows a exception (java.sql.Timestamp can not be cast to oracle.jbo.domain.Timestamp)



  •  To solve this error go to Employees ViewObject and select transient attribute and go to source, se it is of type java.sql.Timestamp

  • Change it to oracle.jbo.domain.Timestamp  and then run it
  • So this is a bug when developer creates new Transient or Query bind variables of Timestamp type, ADF automatically assign it java.sql.Timestamp
Always check it when using Jdveloper 11gR2

Cheers... happy debugging

Friday 13 September 2013

Using af:inputNumberSlider and af:inputRangeSlider for good UI in Oracle ADF

Hello All,
This tutorial is about slider component
Slider is cool and interesting component in ADF to select a single number or to select a range
there is two types of slider available in ADF Faces

1. af:inputNumberSlider (to select single value)
2. af:inputRangeSlider (to select range)

Follow steps to learn how to use slider in ADF
  • Go to Component Palette and search slider and drop it  into page
  • look in property inspector of slider , there are many properties to customise this component, you can change min-max values,orientation etc

  •  See Horizontal and Vertical slider-

  • Now to get its value in bean , bind both slider to managed bean, using binding property



  •     private RichInputNumberSlider numberSliderBind;
        private RichInputRangeSlider rangeSliderBind;
    
    
        public void setNumberSliderBind(RichInputNumberSlider numberSliderBind) {
            this.numberSliderBind = numberSliderBind;
        }
    
        public RichInputNumberSlider getNumberSliderBind() {
            return numberSliderBind;
        }
    
        public void setRangeSliderBind(RichInputRangeSlider rangeSliderBind) {
            this.rangeSliderBind = rangeSliderBind;
        }
    
        public RichInputRangeSlider getRangeSliderBind() {
            return rangeSliderBind;
        }
    

  • now to get value of inputNumberSlider simply use binding.getValue()

  •  Number numberVal = (Number)numberSliderBind.getValue();
    

  • To get Range of inputRangeSlider use this

  •         NumberRange sliderVal = (NumberRange)getRangeSliderBind().getValue();
            Number minVal=sliderVal.getMinimum();
            Number maxVal=sliderVal.getMaximum();
    

  • Now Run your page and see how is it-
You can use slider for custom search, fixed range interval etc