Adf - secondary sort

Hi,
We have adf display only table with 3 columns with the default sort on each column.
It works fine independantly.
Is there a way to do a secondary sort on a second column maintaining the first column sort?
Is there a setting in the column properties that I can use to set this?
Thanks

ADF provides only single column sorting, but you can retain the previous sort orders and apply the current sort order as follows:
1) Create a class variable that retains all the previous sort orders in the managed bean registered in pageFlowScope.
private List<SortCriterion> tableSortList = new ArrayList<SortCriterion>();
2) When a sort is performed, if the attribute is already present, remove the old sort criterian for the attribute and add the new one by having custom sort function.
Here is the sample code:
Sample.jspx:
<af:document id="d1">
<af:messages id="m1"/>
<af:form id="f1">
<af:table value="#{bindings.Departments.collectionModel}" var="row"
rows="#{bindings.Departments.rangeSize}"
emptyText="#{bindings.Departments.viewable ? 'No data to display.' : 'Access Denied.'}"
fetchSize="#{bindings.Departments.rangeSize}"
rowBandingInterval="0"
selectedRowKeys="#{bindings.Departments.collectionModel.selectedRow}"
selectionListener="#{bindings.Departments.collectionModel.makeCurrent}"
rowSelection="single" id="t1"
*sortListener="#{pageFlowScope.SampleBean.onSort}">*
<af:column sortProperty="Deptid" sortable="true"
headerText="#{bindings.Departments.hints.Deptid.label}"
id="c1">
<af:outputText value="#{row.Deptid}" id="ot2">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.Departments.hints.Deptid.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="Deptname" sortable="true"
headerText="#{bindings.Departments.hints.Deptname.label}"
id="c2">
<af:outputText value="#{row.Deptname}" id="ot1"/>
</af:column>
</af:table>
</af:form>
</af:document>
*SampleBean.java:*
import java.util.ArrayList;
import java.util.List;
import oracle.adf.view.rich.component.rich.data.RichTable;
import org.apache.myfaces.trinidad.event.SortEvent;
import org.apache.myfaces.trinidad.model.SortCriterion;
public class SampleBean {
public SampleBean() {
*private List<SortCriterion> tableSortList = new ArrayList<SortCriterion>();*
*public void onSort(SortEvent sortEvent) {*
*List currentSortList = sortEvent.getSortCriteria();*
*SortCriterion currentSortCriterion =*
*(SortCriterion)currentSortList.get(0);*
*// Remove the criteria if already present*
*this.removeIfCurrentSortCriteriaAlreadyPresent(currentSortCriterion);*
*// Add the current criteria to the list*
*this.tableSortList.add(currentSortCriterion);*
*// Print current sorting order for debugging purpose*
*this.printCurrentSortingOrder();*
*// Apply the current list of sort criterions to the table*
*RichTable richTable = (RichTable)sortEvent.getComponent();*
*richTable.setSortCriteria(tableSortList);*
private boolean removeIfCurrentSortCriteriaAlreadyPresent(SortCriterion currentSortCriterion) {
if (tableSortList != null && tableSortList.size() > 0) {
for (SortCriterion sortCriterion : tableSortList) {
if (sortCriterion.getProperty().equals(currentSortCriterion.getProperty())) {
tableSortList.remove(sortCriterion);
return true;
return false;
private void printCurrentSortingOrder() {
System.out.println(":: CURRENT SORT APPLIED ::");
if (tableSortList != null && tableSortList.size() > 0) {
for (SortCriterion sortCriterion : tableSortList) {
System.out.println(sortCriterion.getProperty() + "----" +
sortCriterion.isAscending());
Register the bean in pageFlowScope.
The code is self explanatory.
Thanks,
Navaneeth

Similar Messages

  • Bridge Sort Order - Secondary Sort Key

    Noticed an anamoly to sort order when rating images.
    I have sort order set to Ascending by date. Everything starts off fine - all images in the correct order. When I start labeling the images (using numbers 6, 7, 8, 9) the sort order starts changing.
    I have several images with the same exact date/time (e.g., 8/22/08 10:15:13) - my camera shoots 6 frames per second.
    I start labeling "three" images with the same date/time - as I do, the image I label goes to the "end" of the "three" that have the same date/time stamp. So, now an image I just labeled is moved in the order and I end up labeling it again - which based on how bridge works actually undoes the label - label does a toggle.
    Then I hit the next image and rate it - same thing. appears to be sorting on a secondary key when the date/time are the same for multiple images.
    Is there a way to stop the secondary sort key affect. It really screws up the labeling flow.
    Image order:
    Image01
    Image02
    Image03
    Label Image01 as a "6" - order changes to:
    Image02
    Image03
    Image01
    So now image01 is back in the labeling flow...

    To further explain this issue:
    Original file order:
    1
    2
    3
    I look at each file then star File # 1. Instantly, the files rearrange to:
    3
    2
    1
    So I back track and start the sequence over (so that I can see files 2 and 3). So I decide I also like file # 2. The order rearranges again into:
    1
    3
    2 or something like that
    By now, I'm all mixed up as to what order the event actually happened. The more I star, the more the files rearrange. When I go back to see the rearranged files, they rearrange again. It's all very frustrating when I'm trying to edit a wedding and tell the story. It's imperative that I see all different camera files in order.

  • I highlight genre in my iTunes library and it is sorted thus.  The secondary sort is automatically artist.  I want the secondary sort to be album. How do I accomplish this?

    I highlight "genre" in my itunes library and it is sorted thus.  The secondary sort is automatically "artist".  I want the secondary sort to be "album".  How do I accomplish this?

    Can't do it.
    You can use the browser (iTunes menu view > Browser) select a genre then sort by Album.

  • Secondary sort in itunes

    How do I use a secondary sort in itunes so not only does my list show the artist in alphabetical order, the albums show in chronological as well?
    and can I use Album Artist to sort by last name so I don't have to retype the artist's name so that their last name is listed first in the main itunes window?
    thanks!

    Chris CA wrote:
    Or you can simply sort on Album by Year. Click the Album column header to switch between Album > Album by Artist > Album by Year then back to Album
    This will sort albums by artist by year.
    Yes, but while that is indeed true it's of very limited use as it ONLY applies to the list of tracks currently in the main window. Whereas, if you set up your 'Sort Album' tag/field as I suggest, the list of albums in the 'browse' list at the top (or side) for the selected artist will also be sorted chronologically and there is NO other way to achieve that.
    This chronological sort will also carry over onto the iPods and TVs so almost everywhere you use your music, an Artist's Albums will be sorted chronologically, which as I already opined, is the ONLY way they should be sorted. Just remember to NOT add the date in that way to compilations. This ensures they are grouped together at the top of the Album list for that Artist rather than simply muddling up the list. Mind you, if you do also want them chronologically sorted, you can have that too
    I understand that it is a lot of work to convert a large library of music. With over 1000 CDs it has taken me a long time to achieve an acceptable display for them all, but now, it's a simple matter of adjusting the tags on any new CD I import and that takes only seconds for each one, so it's no longer a big deal. Of course, others may not wish to put in that much effort, but at least I can show that there is a way to achieve it, if you really want.

  • How do I change the secondary sorting on iTunes?

    So iTunes has it's basic sorting algorithm, with various options to choose from for the primary sort.
    However there are secondary, tertiary etc sorts which happen on the rest of the information - so for example, if I sort by Artist, my secondary sort will be albums, and then tertiary will be track number.
    What I want to know is, can I change the default secondary sort? So that if I sort by artist, the secondary sort will be song title or something.
    I know that this capability is present, as Album has various options for sorting if you click it multiple times, specifically Album by Artist and Album by Artist/Year.
    If not present, this feature should be added, because added customisation would be fantastic!

    What I want to know is, can I change the default secondary sort?
    Nope.

  • Secondary sort.

    Hi,
    How do I implement secondary sort order in reports. For example, I have an employee report. I have first_name, last_name, emp_type, login_name etc. I want to give users a way so that when they click on the top of the columns, it should act like this: User first clicks on type then last_name and first_name. Then I want to sort by emp_type, last_name, first_name. Is it possible to do this ? I am using APEX 3.0.
    Thanks

    I could be wrong but I don't think you can do this, The only way I can think of is offering the user a sort selection prior to running the report then using the selected variable to feed a PL/SQL query.
    You could look at a checkbox selection perhaps?

  • Secondary Sorting

    How do I do a secondary sort?  For example, if I want to sort my songs by Artist and THEN have them alphabetically sorted by song title by each artist?  This used to happen "automatically" in my previous versions of ITunes, but I can not make it work since the upgrade.

    iTunes doesn't support user defined secondary sorting. There are a couple of fixed options such as Album by Artist/Year, but that is it.
    tt2

  • 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

  • ADF table sorting not working - Possible Bug

    Hi all,
    I'm getting this error when I tried to sort a table.
    <06/11/2012 09h14min53s BRST> <Warning> <EclipseLink> <BEA-2005000> <2012-11-06 09:14:53.839--UnitOfWork(28365105)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Column "clientes.nome" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
    Error Code: 8127
    Call: SELECT COUNT(id) FROM "clientes" ORDER BY nome DESC
    Query: ReportQuery(referenceClass=Clientes sql="SELECT COUNT(id) FROM "clientes" ORDER BY nome DESC")>
    <06/11/2012 09h14min53s BRST> <Warning> <EclipseLink> <BEA-2005000> <2012-11-06 09:14:53.917--UnitOfWork(25154371)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Column "clientes.nome" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
    Error Code: 8127
    Call: SELECT COUNT(id) FROM "clientes" ORDER BY nome DESC
    Query: ReportQuery(referenceClass=Clientes sql="SELECT COUNT(id) FROM "clientes" ORDER BY nome DESC")> I'm using MSSQL server and I tried the same code with MySQL and everything worked.
    I really don't know waht to do, anyone have faced this problem?

    Yes,
    Column "clientes.nome" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.I've create an Aplication using EJB 3.0 and ADF faces. The table on view layer I've created dragging and dropping the list from DataControl.
    When I run the app, the table load fine but it's not sorting the table and on log the server give that error message posted before.
    This error is coming only when I use MSSQL server, on MySQL it's working well.
    Edited by: 969768 on 06/11/2012 04:14
    Edited by: 969768 on 06/11/2012 04:18

  • ADF Table sorting not working for  newly inserted rows

    Hi,
    I am using Oracle Jdeveloper 11.1.1.6.2
    I am trying to sort the table after inserting the mew rows using ADF Table UI sort option, But the newly inserted rows are not getting sorted.
    The code i am using to add a row is:
            ComplianceLibraryAMImpl am = getDataControl();
            EmKeywordVOImpl rep = am.getEmKeywordVO1();
            NameValuePairs nvp = new NameValuePairs();
            nvp.setAttribute("KeywordName", keyword);       
            Row row1 = rep.createAndInitRow(nvp);
            rep.insertRow(row1);After this addition we are doing ppr on the table and then trying to sort using sort icon in table.
    But the newly added rows are not taking part in sort.
    What am i missing?
    Thanks,
    Tripuresh

    This is the expected behavior. Check bug 9109010 - newly added and unsaved rows don't participate in sorting as per design. Try saving the rows and then sorting.
    Regards,
    Aditya

  • 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

  • Problem in ADF Table Sorting Accessor Fields Generated from EJB 3

    Here are the things that I have done:
    1) created EJB entities for Employee and Department based on the HR schema
    2) created an HRFacade session bean
    3) generated DataControl
    4) created a browse page
    5) created an adf read only table with the following fields: employeeId, lastname, and departmentName with row selection, filtering and sorting enaabled.
    when I invoke sorting for the employeeId and lastname fields, the table sorts fine, but...
    when I invoke sorting on the departmentName field (an accessor field), the following error occured:
    WARNING: ADF: Adding the following JSF error message: Definition departmentName of type Attribute is not found in employeesFindAll.
    oracle.jbo.NoDefException: JBO-25058: Definition departmentName of type Attribute is not found in employeesFindAll.
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.findAttributeDef(JUCtrlValueBinding.java:589)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.findAttributeDef(JUCtrlValueBinding.java:559)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlRangeBinding.__setSortCriteria(FacesCtrlRangeBinding.java:247)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding$FacesModel.setSortCriteria(FacesCtrlHierBinding.java:346)
         at org.apache.myfaces.trinidad.component.UIXCollection.setSortCriteria(UIXCollection.java:464)
         at org.apache.myfaces.trinidad.component.UIXTable.setSortCriteria(UIXTable.java:196)
         at org.apache.myfaces.trinidad.component.UIXTable.broadcast(UIXTable.java:260)
         at oracle.adf.view.rich.component.UIXTable.broadcast(UIXTable.java:140)
         at oracle.adf.view.rich.component.rich.data.RichTable.broadcast(RichTable.java:364)
         at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:147)
         at org.apache.myfaces.trinidad.component.UIXTable.broadcast(UIXTable.java:271)
         at oracle.adf.view.rich.component.UIXTable.broadcast(UIXTable.java:140)
         at oracle.adf.view.rich.component.rich.data.RichTable.broadcast(RichTable.java:364)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:787)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:280)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:165)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:54)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.wls.JpsWlsFilter$1.run(JpsWlsFilter.java:96)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.wls.util.JpsWlsUtil.runJaasMode(JpsWlsUtil.java:146)
         at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:140)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:202)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3588)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Is this a bug or a not supported feature?
    We been stack on this... Help!!!

    I have a similar problem but related to the creation of Project Gantt Chart.
    oracle.jbo.NoDefException: JBO-25058: No se ha encontrado la definición XXXView2 del tipo Atributo en YYYView1.
    this is happened when i try to create a Project Gantt Chart whit 2 view objects that have a parent-child relationship where XXXView2 (SUBTASKS) is the child and YYYView1 (TASK) is the parent.
    still not find the solution.
    This is the bug?

  • ADF Table sort issue

    Hi,
    We are using ADF 11g.
    In application we have af:query search block and its result table. When we click on column header with some data present it is sorting the data, which is accepted behaviour.
    But when there is no data in the table, and click on column header, The blind search query is being exceuted and fetching all the data. The issue with this is the table has millions of records and we have 'selectively required' search on the page. So through search block a blind search is not allowed but on click of Sort of column we are not able to handel it, affecting the performance of application.
    What can be done to prevent blind search?
    Thanks,
    Manasa

    There could be so many ways.. One simple solution I see is disable sorting only when Table is empty,
    set the sortable property for columns like : #{bindings.employeeVO1.estimatedRowCount > 0 ? true : false}
    Amit
    Edited by: amseth on Jan 14, 2011 10:31 AM

  • ADF Table Sorting issue

    Hi,
    I have a table that is created from bean data control. When I do sorting on a particular column, the call goes to the bean and it is doing sorting. The sorted data is not getting displayed in the tabel because ADF table is again doing is own sorting and displaying the data. How to display the sorted data comes from the bean and stop table;s in-built sort.
    Thanks,
    $N

    Let me give the actual scnerio,
    1. I need all the columns of the table are sortable, So I made sortable="true" to all the columns.
    2. One of the column is displaying date and time but still the column is string in the table (There is a text box to filter the date not date picker)
    3. When I sort date column ASC/DEC it makes call to the service and the service returns sorted data.
    4. After the data is retrieved from the service, the table is doing its own sorting by taking this column as string(actually)
    5. Finally the table display the data that is sorted by the table itself not the list sorted by the service.
    So the sorting flow happens in this way
    (a) User clicks on Sort in the Table --> (b) Call goes to service to get the sorted data --> (c) Table gets the data from service and does the sort again --> (d)display the data sorted in step(c)
    I want to avoid the step (c) so that the table display the that got in step(b)

  • ADF Faces: sorting in af:table does'n work after migration fr. EA11 to EA13

    I have a JSF JSP with an <af:table> component (EA11). Sorting of columns in this table works fine with this code:
    <af:column>
    <f:facet name="header">
    <af:sortableHeader text="Name" property="Name"/>
    </f:facet>
    <af:outputText value="#{item.Name}"/>
    </af:column>
    Then i migrate to EA13 and changed the code to:
    <af:column sortProperty="Name" sortable="true">
    <f:facet name="header">
    <h:outputText value="Name"/>
    </f:facet>
    <af:outputText value="#{item.Name}"/>
    </af:column>
    => the column headers are rendered as sortable, but sorting of columns does not work!
    The bean property, the value attribute of the table is bound to, extends oracle.adf.view.faces.model.CollectionModel.
    I will give you a hint: documentation to <af:column> and <af:table> always describes how to implement sorting with <af:sortableHeader>.

    I use my own Implementation of CollectionModel. It extends oracle.adf.view.faces.model.CollectionModel.
    The setSortCriteria method is called correctly. Even the sorting is done correctly. I just don't see it in my page. If I click on a column header to sort the column my cursor transforms to an hourglass, and that's it. Then I click on another button which makes the page render again, and suddenly the table is sorted according to the column I clicked before.

Maybe you are looking for