ADF table: case-insensitive sorting

I have an <af:table> that uses a SortableModel as it's data source. I have sorting enabled on the table, but it's sorted according to case sensitivity.
My data source has mixed case, and I'd like to be able to sort regardless of case. Is there anyway to change the behavior so it does a case-insensitive sort instead?
Thanks

In case anyone else is looking for this, I went ahead and wrote an extension of CollectionModel that performs a case insensitive sort on String objects. I'm posting it here in the hopes it will help others in the same jam I was. It would really have been helpful if Oracle had made the source code to SortableModel available. I hope I did things properly with the rowKey stuff since there are no examples to work from.
Anyway, here it is:
package com.fhm.mwb.ui.model;
import oracle.adf.view.faces.model.CollectionModel;
import oracle.adf.view.faces.model.SortCriterion;
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.comparators.ComparableComparator;
import org.apache.commons.collections.comparators.ComparatorChain;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import javax.faces.FacesException;
import javax.faces.model.DataModelEvent;
import javax.faces.model.DataModelListener;
* This class provides a sortable data model that uses case insensitive sort order when processing
* String objects.  All other objects in the data must implement Comparable and are sorted using
* Comparable.compare().
public class CaseInsensitiveSortableModel extends CollectionModel {
    private static BasicComparator _comparator = new BasicComparator();
     * Default constructor.
    public CaseInsensitiveSortableModel() {
     * Construct on top of a list of data.
     * @param list List of data to wrap in the model
    public CaseInsensitiveSortableModel(List list) {
        setWrappedData(list);
     * Set the sort criteria for this model
     * @param criteria List of SortCriterion objects
    public void setSortCriteria(List criteria) {
        _sortCriteria = criteria;
        if((criteria != null) && (criteria.size() > 0)) {
            // Sort our model data using this new criteria
            ComparatorChain chain = new ComparatorChain();
            for(int i = 0; i < criteria.size(); i++) {
                SortCriterion crit = (SortCriterion) criteria.get(i);
                chain.addComparator(new BeanComparator(crit.getProperty(), _comparator),
                    !crit.isAscending());
            List list = (List) getWrappedData();
            Collections.sort(list, chain);
            setWrappedData(list);
        } else {
            // Clear out our sort order
            _sortCriteria = new ArrayList();
     * Get the current sort criteria.
     * @return List of sort criteria
    public List getSortCriteria() {
        return _sortCriteria;
     * Determine if a given column is sortable.
     * @param column Name of the column to test
     * @return boolean true if the column is sortable
    public boolean isSortable(String column) {
        return true;    // Everything is sortable for now
     * Sets up a value at a particular rowKey to be the current value. The current value
     * is returned by calling {@link #getRowData}.
     * @param rowKey the rowKey of the value to make current. Use null to clear the current value.
    public void setRowKey(String rowKey) {
        if(rowKey == null) {
            setRowIndex(-1);
        } else {
            setRowIndex(Integer.valueOf(rowKey).intValue());
     * Gets the rowKey of the current value. The current value is returned by
     * calling {@link #getRowData}.
     * @return the rowKey of the current value, or null if there is no current value
    public String getRowKey() {
        return isRowAvailable() ? String.valueOf(_rowIndex) : null;
     * Set the list data we are wrapping
     * @throws ClassCastException if data is
     *  non-null and is not a List
    public void setWrappedData(Object data) {
        _wrappedList = (List) data;
        if(_wrappedList == null) {
            setRowIndex(-1);
     * Return the object representing the data wrapped by this model, if any.
    public Object getWrappedData() {
        return _wrappedList;
     * Return true if there is wrappedData
     * available, and the current value of rowIndex is greater
     * than or equal to zero, and less than the size of the list.  Otherwise,
     * return false.
     * @exception FacesException if an error occurs getting the row availability
    public boolean isRowAvailable() {
        return ((_rowIndex < 0) || (_rowIndex > getRowCount())) ? false : true;
     * If there is wrappedData available, return the
     * length of the list.  If no wrappedData is available,
     * return -1.
     * @exception FacesException if an error occurs getting the row count
    public int getRowCount() {
        return (_wrappedList == null) ? (-1) : _wrappedList.size();
     * If row data is available, return the list element at the index
     * specified by rowIndex.  If no wrapped data is available,
     * return null.
     * @exception IllegalArgumentException if now row data is available
     *  at the currently specified row index
    public Object getRowData() {
        if(_wrappedList == null) {
            return null;
        } else if(!isRowAvailable()) {
            throw new IllegalArgumentException("No row data available");
        } else {
            return wrappedList.get(rowIndex);
     * Return the zero-relative index of the currently selected row.  If
     * we are not currently positioned on a row, or no wrappedData
     * is available, return -1.
     * @exception FacesException if an error occurs getting the row index
    public int getRowIndex() {
        return _rowIndex;
     * Set the zero-relative index of the currently selected row, or -1
     * to indicate that we are not positioned on a row.  It is
     * possible to set the row index at a value for which the underlying data
     * collection does not contain any row data.  Therefore, callers may
     * use the isRowAvailable() method to detect whether row data
     * will be available for use by the getRowData() method.
     * If there is no wrappedData available when this method
     * is called, the specified rowIndex is stored (and may be
     * retrieved by a subsequent call to getRowData()), but no
     * event is sent.  Otherwise, if the currently selected row index is
     * changed by this call, a {@link DataModelEvent} will be sent to the
     * rowSelected() method of all registered
     * {@link DataModelListener}s.
     * @param rowIndex The new zero-relative index (must be non-negative)
     * @exception FacesException if an error occurs setting the row index
     * @exception IllegalArgumentException if rowIndex
     *  is less than -1
    public void setRowIndex(int rowIndex) {
        if(rowIndex < -1) {
            throw new IllegalArgumentException("Row index must be >= 0");
        int old = _rowIndex;
        _rowIndex = rowIndex;
        if(_wrappedList == null) {
            return;
        DataModelListener[] listeners = getDataModelListeners();
        if((old != _rowIndex) && (listeners != null)) {
            Object rowData = null;
            if(isRowAvailable()) {
                rowData = getRowData();
            DataModelEvent event = new DataModelEvent(this, _rowIndex, rowData);
            int n = listeners.length;
            for(int j = 0; j < n; j++) {
                if(null != listeners[j]) {
                    listeners[j].rowSelected(event);
    private List _wrappedList = new ArrayList();
    private List _sortCriteria = new ArrayList();
    private int _rowIndex = -1;
     * Internal class to provide a general Comparator that treats Strings in a case
     * insensitive manner.  All other types are assumed to be instances of Comparable
     * and handled as such.
    private static class BasicComparator implements Comparator, Serializable {
        private static final Comparator INSENSITIVE_COMPARATOR = String.CASE_INSENSITIVE_ORDER;
        private static final Comparator NORMAL_COMPARATOR = ComparableComparator.getInstance();
        public BasicComparator() {
        public int compare(Object o1, Object o2) {
            if(o1 instanceof String && o2 instanceof String) {
                return INSENSITIVE_COMPARATOR.compare(o1, o2);
            } else {
                return NORMAL_COMPARATOR.compare(o1, o2);
}

Similar Messages

  • How to make a sortable column in a table to do a case insensitive sort ?

    Hi :
    I am using Jdeveloper Studio Edition Version 11.1.1.1.0 and my table columns are sortable but i want to make sure that it case insensitive sort ,for example if i have following column values :
    abc,def,ABC,ghi
    Sorted results should not be likes this : abc,def,ghi,ABC
    instead of this it should be like this : abc,ABC,def,ghi
    Please let me know more about it.
    Thanks
    AN

    Dear,
    I'm using the same configuration, Could u tell me how did u done the sort in a column in any case.
    Regards,
    RengarajR
    Edited by: Rengaraj Rengasamy on Oct 19, 2009 1:34 AM

  • LC_COLLATE with dotfiles at top, then case-insensitive sorting

    Hello,
    I would like to have the following sort order in file managers or when using the "ls" command:
    1. dotfiles should be on top
    2. other files should follow but case-insensitive
    For (1) LC_COLLATE=C works, but it then sorts the remaining file case-sensitive
    For (2) e.g. LC_COLLATE="en_US.UTF-8" or de_DE.UTF-8 works.
    Is there a locale that fits to my needs? If not, is it possible to edit a locale or create custom rules?
    Thank you!

    Y = Opportunity Revenue
    X = Month
    The report is a 4-month forecast, but not using built-in Forecasting that CRMOD uses; this report uses the Forecast checkbox in an opportunity to determine if the oppty should be on the forecast report, then grabs the overall Oppty Revenue from that same region of the Oppty (not using line/Product level revenue field).
    The report uses a table and above that a chart with 3D cylindrical output where each press model (derived from a field in the Oppty header) is a different color (I'm letting Analysis defaults set the colors for each product).
    My boss wants to sort the colors from smallest model size to largest model size for consistency sake and to make the chart easier to comprehend with a glance.
    Is this even possible? I could see sorting by revenue size, but that's not always the best indicator (as some used larger presses may sell for less than new smaller ones).
    Any ideas?
    Thanks,
    Andy

  • Making ADF Search case insensitive without using Execute with Params??

    I have a ADF search page baed on VO. I'm not Execute with Params form, instead i'm using normal ADF search page. Is it possible to make the search case insensitive?? if yes, how to do that?

    Ok, i'll try to find out the SRDemo application using ADF BC.
    And In Execute with params form,i'm already using UPPER on both the sides of where clause.
    Say my VO query is like
    select <table name>,...
    from fnd_tables t,fnd_applications a
    where a.application_id = t.application_id
    and upper(t.table_name) like upper(:EntityName) || '%'
    Then i created the ADF paramaters form by dragging and dropping the Execute with param from data control pallette.. when i run this page and do the search, it throws the error given in my second update...Any clue why that error is coming?
    Thanks
    Senthil

  • How do I make Merge operation into the target table case insensitive?

    Hi All,
    We have a target table that has a varchar 2 column called nat_key and a map that copies over data from a source table into the target table.
    Based on wheteher the values in the nat_key column matches between the source and the target, an update or an insert has to be done into the target table.
    Let us say target table T has the following row
    nat_key
    EQUIPMENT
    Now, my source table has the same in a different case
    nat_key
    equipment
    I want these rows to be merged .
    In the OWB map, I have given the property of nat_key column in the target table as 'Match while updating' = 'Yes'. Is there a built in feature in OWB, using which I can make this match as case insensitive?
    Basically, I want to make OWB generate my mapping code as
    if UPPER(target. nat_key)=upper(source.nat_key) then update...else insert.
    Note: There is a workaround with 'Alter Session set nls_sort=binary_ci and nls_comp=linguistic', but this involves calling a pre-mapping operator to set these session parameters.
    Could anyone tell me if there is a simpler way?

    Hi,
    use an expression operator to get nat_key in upper case. Then use this value for the MERGE. Then nat_key will only be stored in upper case in your target table.
    If you have historic data in the target table you have to update nat_key to upper case. This has to be done only once and is not necessary if you start with an empty target table.
    Regards,
    Carsten.

  • Case insensitive selects with 'like'

    I use a 10g database (10.2.0.2 same behaviour with 10.2.0.1). What we want is case insensitive selects with 'like' operator in the where clause. NLS_COMP is set to 'LINGUISTIC' and NLS_SORT is set to 'BINARY_CI.
    In a table we have two columns one of type 'varchar2' one of type 'nvarchar2'. The databases national character set is set to UTF8. Case insensitive sorting works with both columns. Select statements with '.... where varchar2col like '%r%' returns also values with upper case 'R' values (that is what I expect).
    The select statements with '.... where nvarchar2col like '%r%' however does not return the row with upper case 'R' values.
    I used SQL*Plus: Release 10.2.0.3.0 and other clients and the behaviour is the same so
    I think it is not client related.
    Is that a known issue or is there any other parameter to set for UTF8 nvarchar columns?
    Any hint is very much appreciated! Here are the nls settings in database, instance and session:
    DPARAMETER      DVALUE IVALUE SVALUE
    NLS_CHARACTERSET WE8ISO8859P1
    NLS_COMP      BINARY LINGUISTIC LINGUISTIC
    NLS_LANGUAGE      AMERICAN AMERICAN AMERICAN
    NLS_NCHAR_CHARACTERSET UTF8
    NLS_RDBMS_VERSION 10.2.0.1.0
    NLS_SORT BINARY BINARY_CI BINARY_CI
    NLS_TERRITORY      AMERICA AMERICA AMERICA

    OK. Found out what the problem is. It is obviously the client.
    While using the instant client and setting the parameters (NLS_SORT=BINARY_CI and NLS_COMP=LINGUISTIC) as environment variables does not work correctly, at least not for nvarchar2 fields. The nls_session_parameters show the correct values, but selects with 'like' operators in the where clause do not return case insensitive. Issuing the 'alter session' commands and again setting the nls parameters solves the problem.
    Using the full client installation also works, in case the parameters are set in the registry on windows systems. With the full client it it not necessary to issue the 'alter session' commands again.
    So obviously the problem is instant client and nvarchar2 field related. That's too bad....

  • Insensitive Sort in DataGrid

    Hi All,
    Is there a property that can be set to provide for a
    case-insensitive sort? or do I need to create a custom sort compare
    function?
    Thanks,
    Tom

    I imagine the datagrid is resetting when you reassign its dataProvider.
    If you use a single instance of XMLListCollection as the dataProvider
    for the grid and assign your XML data to the XMLListCollection's
    'source' property, your data will update without the grid resetting.
    Here's a very simple example:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
       xmlns:mx="http://www.adobe.com/2006/mxml"
       layout="vertical"
       creationComplete="setDataProvider()">
       <mx:Script>
          <![CDATA[
             import mx.collections.XMLListCollection;
             [Bindable]
             private var xmlOriginal : XML =
                <root>
                   <item name="Alpha" letter="Z"/>
                   <item name="Beta" letter="P"/>
                   <item name="Gamma" letter="X"/>
                   <item name="Delta" letter="P"/>
                </root>
             private var xmlUpdated : XML =
                <root>
                   <item name="Alpha" letter="F"/>
                   <item name="Beta" letter="U"/>
                   <item name="Gamma" letter="A"/>
                   <item name="Delta" letter="P"/>
                   <item name="Epsilon" letter="F"/>
                </root>  
             private function setDataProvider() : void
                dataGrid.dataProvider = new XMLListCollection( xmlOriginal..item );
          ]]>
       </mx:Script>
       <mx:DataGrid
          id="dataGrid"/>
       <mx:Button
          label="Simulate Update"
          click="XMLListCollection( dataGrid.dataProvider ).source = xmlUpdated..item"/>
    </mx:Application>

  • Sorting Column - Case Insensitive but Lower should be first

    Hi all,
    Lets assume we have am EMployee table :
    create table Emp (Empname varchar2(20));
    It has following records :
    Insert into EMP (EMPNAME) values ('A');
    Insert into EMP (EMPNAME) values ('a');
    Insert into EMP (EMPNAME) values ('b');
    Insert into EMP (EMPNAME) values ('c');
    Insert into EMP (EMPNAME) values ('D');
    Insert into EMP (EMPNAME) values ('e');
    Insert into EMP (EMPNAME) values ('E');
    Insert into EMP (EMPNAME) values ('F');
    i.e
    Empname
    A
    a
    b
    c
    D
    e
    E
    F
    I need output as below : ( Sort by Ascending, case insensitive meaning I don't want all Capital first and then Lower letters. The results should be in alphabetical order it shouldn't matter whether its capital or small. More important is that small letter should come first then the Capital letter). Is this possible?.
    Empname
    a
    A
    b
    c
    D
    e
    E
    F
    Select * from emp order by Lower(empname) Asc;
    Doesn't do the job, because 'A' comes before 'a'.
    Regards,
    Bhaskar

    select empname from emp order by upper(empname),ascii(empname) desc;
    EMPNAME
    a
    A
    b
    c
    D
    e
    E
    F
    Cheers,
    Manik.

  • ADF table sorting

    Hi all!
    How can I sort ADF table by column using select one choise LOV (i.e sort by Name insetad of ID)?

    Hi user,
    check this out.
    Java ADF Webcenter UCM SOA Weblogic: Custom ADF Table Filter with Drop Down , Validation and case insensitive

  • Sorting of a column (adf table component) doesn't work in frame

    Hi,
    I just developed a little application with just one query. The results are shown in an adf table component with the possibility of column sorting.
    The application works just fine if i open it with its actual URL, but when I put it in a classic html frameset I'm not able to sort columns anymore.
    The frameset is quite simple. Something like this
    <frameset rows="90%,10%">
    <frame src="header.htm"/>
    <frame src=application URL />
    </frameset>
    I tried to change the targetFrame attribute of the form component but nothing.
    Any idea?
    By the way, I Work with JDeveloper 10.1.3.2.0.4066 and its adf faces components

    Hi,
    I recall an issue in 10.1.3.2 with inner frames that had the wrong JavaScript reference to the DOM. So I assume this to be the same in your case. So you can give it a try with JDeveloper 10.1.3.3 and see if this fixes the problem
    Frank

  • Unable to capture the adf table column sort icons using open script tool

    Hi All,
    I am new to OATS and I am trying to create script for testing ADF application using open script tool. I face issues in recording two events.
    1. I am unable to record the event of clicking adf table column sort icons that exist on the column header. I tried to use the capture tool, but that couldn't help me.
    2. The second issue is I am unable to capture the panel header text. The component can be identified but I was not able to identify the supporting attribute for the header text.

    Hi keerthi,
    1. I have pasted the code for the first issue
    web
                             .button(
                                       122,
                                       "/web:window[@index='0' or @title='Manage Network Targets - Oracle Communications Order and Service Management - Order and Service Management']/web:document[@index='0' or @name='1824fhkchs_6']/web:form[@id='pt1:_UISform1' or @name='pt1:_UISform1' or @index='0']/web:button[@id='pt1:MA:0:n1:1:pt1:qryId1::search' or @value='Search' or @index='3']")
                             .click();
                        adf
                        .table(
                                  "/web:window[@index='0' or @title='Manage Network Targets - Oracle Communications Order and Service Management - Order and Service Management']/web:document[@index='0' or @name='1c9nk1ryzv_6']/web:ADFTable[@absoluteLocator='pt1:MA:n1:pt1:pnlcltn:resId1']")
                        .columnSort("Ascending", "Name" );
         }

  • Issue with ADF table range paging and sorting

    Hello,
    We have a requirement to support pagination in ADF tables. For this, we have made use of Range paging access mode in the view object level. The paging works perfectly fine with this. But we have another requirement of letting the user do a sort on the table (Yes!! The paginated table). The sort should be applied on all rows in the db and the control should return to the first row.
    Applying sort as it is provided by the fwk, sorts the records in the obtained range only. So we have over ridden the Sort listener in Managed bean for this and are able to acheive the sorting of all rows through a AM method call. We are seeing a problem after this. If the sort action is applied to the key attribute then the previous and next range navigation works fine. If the same action is applied to non-key field, then some times (yea!! This is not consistent) the next set is not fetched.
    Here is the code snippet that is called on Next navigation:
    Map<String,Object> pfScope = AdfFacesContext.getCurrentInstance().getPageFlowScope();
    Object objPageNumber = pfScope.get("pageNumber");
    int pageNumber = 0;
    if(null != objPageNumber)
    pageNumber = new Integer(objPageNumber.toString()).intValue();
    BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
    JUCtrlRangeBinding view = (JUCtrlRangeBinding)bindings.getControlBinding("GeDmRequestVO");
    int iRange = getTable().getAutoHeightRows();
    int currentPage = view.getIteratorBinding().getNavigatableRowIterator().getRangeStart()/(iRange + 1);
    System.out.println("Before " + view.getIteratorBinding().getNavigatableRowIterator().getRangeStart());
    System.out.println("Current : " + currentPage);
    System.out.println("Page Number : " + pageNumber);
    System.out.println("Range : " + iRange);
    System.out.println("Value : " + iRange*(currentPage + pageNumber));
    view.getIteratorBinding().getNavigatableRowIterator().scrollRange(iRange*pageNumber);
    System.out.println("After " + view.getIteratorBinding().getNavigatableRowIterator().getRangeStart());
    Although, the new values are not refreshed in the table, the SOPs for before and after print the proper range sizes. And as I mentioned above, the above code works perfectly fine if there is no sort applied or when key attribute is sorted.
    Would appreciate your help on this regard with navigation after non-key attribute sort.
    Thanks,
    Chitra.

    Hi Chitra,
    Can you specify some links to implement RangePaging.....We need to implement pagination.If possible can you share the code or specify the steps how you achieved it.
    Thanks

  • Change Default Sort Logic Of ADF Table?

    Hello All,
    In my application is an ADF table with lots of rows. The default sort logic for one of the columns is from 'Oldest to Newest'. The user has to click on the sort again to get 'Newest to Olderst'. This takes away a lot of time.
    How can I change the default sort logic to 'Newest to Oldest' ?
    Thanks,

    Is this jdeveloper 11.1.1.2?
    What is the problem with the normal scenario - just add 'order by' the view object clause?
    The table offers ascending and descending ordering.

  • How to set default sorting order in ADF Table

    Hi,
    I want to set the default sorting order as ascending in adf table. Please help me regarding how can we do it.
    Using JDev 11.1.1.5.0

    Hi Frank,
    Thanks for the quick reply.
    I have done binding of table with list of pojos.
    The Class for which Data control is created is as:-
    public class DemoDC {
        private List<TableEntity> tableList =
            new ArrayList<TableEntity>();
        public List<TableEntity> getTableList() {
            return tableList;
        public void setTableList(List<TableEntity> tableList) {
            this.tableList = tableList;
    where TableEntity is a pojo which has all the columns as its attributes.
    Now when i do the above steps , after clicking on pencil icon and seecting the iterator name in the iterator tab (DemoDC-> tableList) , and selcting the 'sort criteria' tab when i select a column and try to set the sort order  I get error as ' Iterator can not be created for the selected node ' .

  • ADF Table sorting on Select One choice column display value

    Hi Team,
    We are using an ADF with EJB application.
    I have an ADF table, which has a select one choice in it. (The Select one Choice list elements are populated from a java bean).
    Presetnly, when we perform the sorting on this SOC column, the table is getting sorted based on SOC value not on the Label.
    How to sort this column based on the SOC Lable filed.
    Please help us.
    Thank you,
    Keshav Ch

    Hi Frank,
    I took a transient column in the Entity and populated this column with the LOV label value.
    In the ADF added this coulmn to the table and set it is rendered false.
    Set the sortable property of the lov column to the new trasient column.
    Now the sort will work with the label filed (Transient Column)
    Thank you,
    Keshav ch

Maybe you are looking for

  • Unable to sync All Day events with a Nokia 61i phone in Mac OS X 10..4.10

    When I sync events that are created in iCal with a Nokia 61i some events is OK other not. What can I do to get everything right?

  • Meggaging server security problem

    Hi All, We have messaging server 7.3 and convergence 1_U3. Client site we are using Iexplorer 7.X and Mozilla 3.X . Now we are facing problem is, If we shut down the system with out logging messaging server console. Next login is not asking user name

  • How can we cretae the DBC file?

    Hi all, I am attempting to run the test_fwktutorial.jsp within the toolbox.jws/Tutorial.jpr project in Jdeveloper . We have to provide the Oracle application DB connection in the project properties ( we have to provide this as a DBC file) . How can w

  • Signature problem again

    I finally learned to set the program right and could get random selection BUT once I set it up it works once and then refuses to remember what it was supposed to be doing. When I go to the first column on the Signatures page I find a picture of a pen

  • WLC 5508 upgradation from 7.4.100.0 to 7.4.110.0

    Hi All, We have upgraded the wlc from 7.4.100.0 to 7.4.110.0. where we found after reboot the configuration has failed to load with the below errors. Cryptographic library self-test....passed! XML config selected XML root tag XML_mapping_variables no