Please disable your adblock and script blockers to view this page

Search this blog

Showing posts with label 12.1.3.0.0. Show all posts
Showing posts with label 12.1.3.0.0. Show all posts

Saturday 11 June 2016

ADF Basics: Use transient attribute to show description of selected value in case of input and combo Lov


In ADF often We apply LOV on a ID attribute to show it's Description to user, This works good in case of choice list (selectOneChoice) but if we use Input Text with List of Values (<af:inputListOfValues>) or Combo Box with List of Values (<af:inputComboboxListOfValues>) then after selection ID appears on page instead of  Description like this


So to avoid this we apply LOV on a transient attribute that shows Description and sets ID value DB attribute, See how to implement this

Tuesday 7 June 2016

Open af:inputListOfValues popup by calling JavaScript programmatically


af:inputListOfValues provides option to open Lov values in a popup and allow user to search, We can open this popup by clicking on magnifying glass icon


Recently I have seen a thread on OTN forum where user wants to open lov popup on a button click after checking some conditions and also found a post by Frank Nimphius Where he used javascript to open Lov popup on double click of mouse.
So guess what I have done ? ;)
Just called that javascript fucntion programmatically on button click

Friday 20 May 2016

Navigate to another page on value change event of ADF input component

Recently I have seen a thread on OTN forum in that user want to navigate from one page to another on valueChangeListener of input component.

First Method-
This is a simple piece of code to perform navigation to specific page , Use it in ValueChangeListener directly

 FacesContext facesContext = FacesContext.getCurrentInstance();
 facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, null, "controlFlowName");

Second Method-
ValueChangeListener fires when value of input component changes but it is not meant for navigation, For navigation we use buttons and links with Action property
But for this requirement we have to be a bit tricky, We can queue button Action on value change listener of inputText to navigate to another page
Now first value change listener will be executed and then it'll queue button action to execute and as final outcome user will be able to navigate

Thursday 19 May 2016

Traverse POJO based ADF treeTable, Get Child nodes of selected parent


Previosuly I have posted about populating af:treeTable programmatically and getting selected records from POJO based treeTable

This post is next in that series and here I am extending same sample application that show a tree of Seasons and it's characters
First we will see How to traverse a POJO based treeTable (Iterate through all nodes of treeTable)

Basic idea is to get treeTable Collection Model and iterate over it to get all nodes value, To get CollectionModel created treeTable component binding in managed bean

Monday 16 May 2016

How to queue SelectionEvent programmatically, Call af:table Selection Listener programmatically

Hello All
Hope you all are doing good :) 
Previously I have posted about defining custom selection listener for af:table and perform desired operation on selection event of table row

Selection Listener is fired when server receives a selection event from client means whenever user selects a row in table (Selection Event) then server process that event and execute selection listener defined in managed bean

And this post is about creating selection event programmatically without user interaction with table.
In ADF we can queue ActionEvent , ValueChangeEvent and in same manner we can create and queue SelectionEvent programmatically

Friday 13 May 2016

Get Selected records (Child/Parent) from POJO based ADF treeTable

Hello All
Previously I have posted about creating af:treeTable programmatically using POJO and this the next post in series

In this post I am talking about a very common requirement while using POJO based treeTable
How can we get selected records (child/parent) from POJO based treeTable ?

For this post I am extending same sample application, Till now we have seen that how can we create POJO based treeTable
Now we'll see that how to get it's selected records


Saturday 30 April 2016

Create ADF Choice List and apply selectItems to it programmatically

I hope we all know how to create selectOneChoice using Model layer and previously I have posted about populating selectOneChoice programmatically from bean using ArrayList

Programmatically populate values in a af:selectOneChoice component in ADF

But this post is slight different - It is about creating selectOneChoice component and applying selectItems to it programmatically
There is nothing complicated in this , Just a piece of code is required
Here I have used an ArrayList to set SelectItems and created component binding for af:form to add selectOneChoice as it's child 

Thursday 21 April 2016

ADF Basics: Get display and base value of POJO based SelectOneChoice


Previously I have posted about populating selectOneChoice programmatically using POJO

and this post is about getting selected value of POJO base selectOneChoice (both display value and base value)

Saturday 27 February 2016

ADF Skinning: Increase width, Change color of a tab in af:panelTabbed

We can change appearance of ADF Application by applying CSS and changing style properties of ADF Faces Component
Here i am writing a simple CSS to increase tab width of af:panelTabbed component

I hope you all know how to create a skin for ADF Application , If don't know then look at this post
ADF Basics: Using CSS to change appearance of application (Skins and Styles in ADF Faces) 

Wednesday 24 February 2016

Drag Drop in same table to reorder rows, Update Attribute value to make it persistent

This post is based on Frank's article on reordering table rows using drag drop functionality of ADF Faces, post uses iterator indexing to change order of rows and it works pretty good

Recently i came across a question on OTN forum asking about making this ordering persistent on base of some attribute value so for that we have to maintain a serial no attribute for each row and when user performs Drag n Drop , serial no. will be swapped and updated ordering of rows will be shown to user and it is persistent as updated attribute's value is saved in database

Monday 15 February 2016

Show live progress of a long running task using af:progressIndicator in Oracle ADF

This post is about using af:progressIndicator to show live status of a particular task
af:progressIndicator state is tracked and maintained by it's value property that supports org.apache.myfaces.trinidad.model.BoundedRangeModel
This class has two methods

public abstract long getMaximum() { }
returns Maximum value for Model

public abstract long getValue() { }
returns value for Model (current state)

Now to see live progress on page we have to refresh progressIndicator component periodically and this can be achieved using af:poll component , poll component delivers poll events to server periodically and we can ppr (refresh) progress indicator after a particular interval

Wednesday 3 February 2016

ADF UI: Using dvt:sunburst to show hierarchical data in ADF

<dvt:sunburst> is one of fancy components to show multi level hierarchical data in form of circular rings in ADF application

It supports drilling up to n-level , consist of dvt:sunburstNode as it's child tag to show level wise detail . Sunburst supports multiple type of animations that makes a better UI
See What docs says -

Sunbursts are used to display hierarchical data across two dimensions, represented by the size and color of the sunburst nodes. The sunburst displays multiple levels of its hierarchy at once, with each ring corresponding to a level of the hierarchy

Thursday 21 January 2016

Add and delete values in POJO based selectOneListbox/selectOneChoice in ADF

Previously i have posted about populating selectOneChoice programmatically using POJO
Programmatically populate values in a af:selectOneChoice component in ADF

In same way we can populate values in selectOneListBox as both ADF Faces components are used for single selection and share same structure

Thursday 14 January 2016

Consuming a SOAP Web Service quickly using Web Service Data Control (WSDL) in ADF

Creating and Consuming Web Servie is an important part development cycle . In earlier posts i have described about creating SOAP/REST Web Service
Create REST Web Service with Application Module declaratively in ADF 12.2.1
Create SOAP Web Service with Application Module quickly in ADF 12.2.1

Now this post is about consuming a SOAP Web Service. A very simple way to consume Web Service is to create Web Service Data Control (WSDL) for external Web Service URL
Here i am using a Country-Currency Web Service (http://www.webservicex.net/country.asmx) to create WSDL

Tuesday 5 January 2016

Get selected slice of dvt:pieChart using custom selection listener in ADF

First of all wishing a very Happy New Year to all of you, New Year is like a blank page , fill it with happiness and good memories


This post is about a simple requirement - How to get selected slice value of dvt:pieChart ?
So for this we have to create a custom selection Listener in managed bean that will be called whenever user selects any slice of pieChart
If you see documentation of pieChart it tells about two properties -

Tuesday 15 December 2015

Checkbox ValueChangeListener problem in af:table - ADF 12.1.3


Recently i faced a problem while working on one of my application, it has an editable table having one check box column and a valueChangeListener is defined on that check box.

Problem is that whenever user selects any row of table , valueChangeListener of check box is called every time for all editable rows, this is weird because VCL should execute only when user selects or deselects check box

Thursday 10 September 2015

Jdeveloper installation folder size increasing beyond limit , Reason was hprof (Heap Profiling) files

Recently i faced a problem, i was lacking space on my C drive so  checked all directories and found that the size of Jdeveloper 12.1.3 installation folder Oracle-->Middleware  was approx 30 GB . This is not expected as Jdev. takes approx 1.5 to 2 GB space only


Then i found some java_pidXXXX.hprof file that was taking lot of space in this folder

Friday 17 July 2015

Apply sorting to POJO based af:table programmatically , Using custom sort listener in ADF

Again a post about POJO based table , previously i have posted about-

1.Populating and adding records in POJO based table
Populate af:table programmatically from managead bean using POJO
2. Gettting selected rows from POJO based table
Get selected row (single/multiple) from POJO based table in ADF

This post is about applying sorting to POJO based table , when we drop a viewObject as af:table on page then framework provides sorting and filtering features declaratively, but when populating table from managed bean using List(POJO) then it is not there so we have to do it manually

To understand this post completely , go through previous posts and check attached application there
I have used a PersonBean java bean class to contain columns of table or you can say there is a List of PersonBean type that populates data in af:table. (This is the basic information about application)




Now what to do , see step by step implementation-
  • Select table on page editor and create a sortListener in managed bean to handle sortEvent


  • Now what we have do in sort listener ?
    1.Get active sort criteria using sortEvent
    2.Remove that sort criteria
    3.Sort List Data Structure that is used to populate af:table
    4.Apply sort criteria again on af:table

    See code written in managed bean-

  •     //List to store sort criteria
        private List<SortCriterion> sortedTableList = new ArrayList<SortCriterion>();
    
        public void setSortedTableList(List<SortCriterion> sortedTableList) {
            this.sortedTableList = sortedTableList;
        }
    
        public List<SortCriterion> getSortedTableList() {
            return sortedTableList;
        }
    
        /**Custom Sort Listener for POJO based af:table
         * @param sortEvent
         */
        public void tableSortListener(SortEvent sortEvent) {
            //Get active sortCriteria on table
            List<SortCriterion> activeSortCriteria = sortEvent.getSortCriteria();
            SortCriterion sc = activeSortCriteria.get(0);
            // Remove active criteria from table
            this.removeSortCriteria(sc);
            //Sort List that populates table using Comparator interface
            applySortAsPerColumn(sc.getProperty());
    
            // Add the current criteria to the list
            this.sortedTableList.add(0, sc);
            // Apply sort criteria to table
            RichTable richTable = (RichTable) sortEvent.getComponent();
            richTable.setSortCriteria(sortedTableList);
    
        }
    
        /**Removes sort criteria*/
        private boolean removeSortCriteria(SortCriterion sortCriterion) {
            //Checks that if any sortCirteria is present in list , if yes then remove it
            if (sortedTableList != null && sortedTableList.size() > 0) {
                for (SortCriterion sc : sortedTableList) {
                    if (sc.getProperty().equals(sc.getProperty())) {
                        sortedTableList.remove(sc);
                        return true;
                    }
                }
            }
            return false;
        }
    

    Now logic to apply programmatic sort starts from here , we have to sort List using Java Comparator interface
    To Read more - How to sort ArrayList using Comparator?     Comparator interface

        private void applySortAsPerColumn(String criteria) {
            //Get List that populates table
            List<PersonBean> list = getPersonList();
            //Check which column's sorting is triggered from UI
            //and then sort list on basis of that attribute
            //Sorting of collection makes use of Comparator interface, Read about it
            if ("name".equalsIgnoreCase(criteria)) {
                Collections.sort(list, new ProgTableBean.PersName());
            } else if ("mobNo".equalsIgnoreCase(criteria)) {
                Collections.sort(list, new ProgTableBean.MobNo());
            } else if ("salary".equalsIgnoreCase(criteria)) {
                Collections.sort(list, new ProgTableBean.Salary());
            }
        }
        // Comparator for all attributes to sort List according to different attributes
    
        public static class PersName implements Comparator<PersonBean> {
            private int flag = 1;
    
            @Override
            public int compare(PersonBean o1, PersonBean o2) {
                return flag * o1.getName().compareTo(o2.getName());
            }
        }
    
    
        public static class MobNo implements Comparator<PersonBean> {
            private int flag = 1;
    
            @Override
            public int compare(PersonBean o1, PersonBean o2) {
                System.out.println("In 2**");
                return flag * o1.getMobNo().compareTo(o2.getMobNo());
    
            }
        }
    
    
        public static class Salary implements Comparator<PersonBean> {
            private int flag = 1;
    
            @Override
            public int compare(PersonBean o1, PersonBean o2) {
                return flag * o1.getSalary().compareTo(o2.getSalary());
            }
        }
    


  • Now on page ,select table and set sortable true for each column and set sortProperty same as column name
    Check af:table source after setting all properties

  • <af:table var="row" rowBandingInterval="1" id="t1" value="#{viewScope.ProgTableBean.personList}"
                              partialTriggers="::b1" rowSelection="multiple" binding="#{viewScope.ProgTableBean.tableBind}"
                              selectionListener="#{viewScope.ProgTableBean.tableSelection}"
                              sortListener="#{viewScope.ProgTableBean.tableSortListener}">
                        <af:column sortable="true" headerText="Name" id="c1" width="150" sortProperty="name">
                            <af:outputText value="#{row.name}" id="ot1"/>
                        </af:column>
                        <af:column sortable="true" headerText="Mobile Number" id="c2" sortProperty="mobNo">
                            <af:outputText value="#{row.mobNo}" id="ot2"/>
                        </af:column>
                        <af:column sortable="true" headerText="Salary" id="c3" align="right" sortProperty="salary">
                            <af:outputText value="#{row.salary}" id="ot3"/>
                        </af:column>
                    </af:table>
    

  • All done :) , Run and check application


Sample ADF Application -Download
Cheers :) Happy Learning

Thursday 16 July 2015

Get selected row (single/multiple) from POJO based table in ADF


Previously i have posted about populating af:table from managed bean using POJO and adding records in it, Check this-
Populate af:table programmatically from managead bean using POJO 
In this post i am extending previous post application
This post is about getting selected row from POJO based table , It is a common requirement while using af:table based on POJO

Get single row using custom selection listener-


SelectionListener  handles selection event of table , whenever user selects a row in table ,selection listener is fired
Set table RowSelection property to single (to select one row at a time) or multiple (to select multiple row ) and create a custom selection listener in managed bean that will handle table's selection event




See selection listener code in managed bean we can get selected row  using this -



import oracle.adf.view.rich.component.rich.data.RichTable;
import org.apache.myfaces.trinidad.event.SelectionEvent;

 /**Method to get selected row(single)
     * @param selectionEvent
     */
    public void tableSelection(SelectionEvent selectionEvent) {
        //Get table from selectionEvent
        RichTable richTable = (RichTable) selectionEvent.getSource();
        //Cast to the List that populates table
        PersonBean row = (PersonBean) richTable.getSelectedRowData();
        //Get the attributes (column) from list
        System.out.println(row.getName());
    }

Now check this -

 Output on console :)

Get single/multiple selected row on a button click (ActionEvent)-


Set table RowSelection to multiple and select multiple row using Ctrl key of your keyboard
and check this code to get multiple selected row using RowKeySet, We can get all row using getSelectedRowKeys method


import org.apache.myfaces.trinidad.model.RowKeySet;
import java.util.Iterator;    



/**Method to get all selected record in af:table
     * @param actionEvent
     */
    public void getSelectedRecord(ActionEvent actionEvent) {
        //getTableBind is binding of table on page.
        RowKeySet selectedEmps = getTableBind().getSelectedRowKeys();
        //Create iterator from RowKeySet
        Iterator selectedEmpIter = selectedEmps.iterator();

        while (selectedEmpIter.hasNext()) {
            String i = selectedEmpIter.next().toString();
            //personList is the list used to populate table and name is a column of table
            //So here filter list using index and get values then
            PersonBean rowIter = personList.get(Integer.parseInt(i));
            System.out.println(rowIter.getName());
        }
       
    }

Now run and check again -

 Output on console :)

Sample ADF Application- Download
Cheers :) Happy Learning

Wednesday 17 June 2015

Insert and show whitespace in ADF Faces Components (panelBox, showDetailItem etc)

This post is about a small trick
How to show whitespace in ADF Faces component properly ?
Recently i found a question on OTN about this
 How can I and spaces in the text property of a showDetailItem?
so thought to document it here for future reference

There is one more post about showing whitespace , check it
Showing white-spaces properly in ADF table column- 11g & 12c

Sometimes we need to insert some whitespace in between of some text as panelBox name, tab name in showDetailItem etc
In this case space appears in page editor but it doesn't appear on page and you can not put spacer at these points because there is only one component



Suppose you have a panelBox and requirement is to show Oracle    ADF as it's header text . In this case providing space in propertyInspector doesn't work , HTML entity for space &nbsp; also doesn't work because of no DOCTYPE declaration

See here i added normal spaces in property of panelBox


 But is doesn't work :(

Now what to do ?
After lots of hit and tries finally i found that it work with equivalent entity number for &nbsp;
and this magic number is  - &#160;
So tried this -


 <af:panelBox text="Oracle&#160;&#160;&#160;&#160;&#160;&#160;&#160;ADF" id="pb1">
                    <f:facet name="toolbar"/>
                </af:panelBox>

and output is

This is the small trick , sometimes you may need this :)
Cheers, Happy Learning :)