Af:table sorting

Hi,
How do i display the af:table coln sorting pic . Becos when i set the sortProperty="startDate" sortable="true" by default, the sorting pic did not appear on the table coln. So user may not know that field can be sortable.
thanks

If by "sorting pic" you mean the dark outline that appears on the column heading of columns that are sortable...that also requires the view object attribute to be queriable. You might check that checkbox.

Similar Messages

  • Text Overlapping/Wrapping Issue in BSP(Table Sorter Using JQUERY)

    Hi ,
    I have a requirement to add a new column in existing table which has been built by Table Sorter method in JQUERY.
    I have added the new column but the issue is value for the new column is populated  on next line of the table.
    This could be a simple width issue, but i don't know JAVA much.Attached the image for reference.
    Code i have used is:
    <input type="text" name="t_rbclaim[<%= lv_tabix%>].reason" size="3" maxlenth="3" wrapping = "true"
         onBlur="javascript:this.value=this.value.toUpperCase();" value="<%= w_rbclaim-reason%>">
    Please let me know how to modify the above code in better way.

    Hi Raja,
    Can you please help on this problem. I want to know whether there is any funciton module to convert the univercel character set code (HTML Codepage) page to SAP codepage. We are going to use ECC 6.0 which is unicode system for background R/3. So we can get the correct character format if identify the correct conversion method.
    Please let me know if any information and expect some information on this.
    Regards,
    Saravanan V

  • Af:table sorting when immediate='true' bug

    Where can I find the patch to fix the problem of sorting an af:table when immediate='true'?

    No I don't have a bug number, I've found that this is a bug based on this thread <a href src='BUG:  ADF FACES 10.1.3_04: Table sort broken if immediate="true" but I have no idea what the number is or where to find the patch for it.
    This is a really irritating bug. I want to have sorting on my tables but if I can't put immediate='true' on the table then other components on the page will fire their validation.

  • Custom table model, table sorter, and cell renderer to use hidden columns

    Hello,
    I'm having a hard time figuring out the best way to go about this. I currently have a JTable with an custom table model to make the cells immutable. Furthermore, I have a "hidden" column in the table model so that I can access the items selected from a database by their recid, and then another hidden column that keeps track of the appropriate color for a custom cell renderer.
    Subject -- Sender -- Date hidden rec id color
    Hello Pete Jan 15, 2003 2900 blue
    Basically, when a row is selected, it grabs the record id from the hidden column. This essentially allows me to have a data[][] object independent of the one that is used to display the JTable. Instinctively, this does not seem right, but I don't know how else to do it. I know that the DefaultTableModel uses a Vector even when it's constructed with an array and I've read elsewhere that it's not a good idea to do what I'm trying to do.
    The other complication is that I have a table sorter as well. So, when it sorts the objects in the table, I have it recreate the data array and then set the data array of the ImmutableTableModel when it has rearranged all of the items in the array.
    On top of this, I have a custom cell renderer as well. This checks yet another hidden field and displays the row accordingly. So, not only does the table sort need to inform the table model of a change in the data structure, but also the cell renderer.
    Is there a better way to keep the data in sync between all of these?

    To the OP, having hidden columns is just fine, I do that all the time.. Nothing says you have to display ALL the info you have..
    Now, the column appears to be sorting properly
    whenever a new row is added. However, when I attempt
    to remove the selected row, it now removes a seemingly
    random row and I am left with an unselectable blank
    line in my JTable.I have a class that uses an int[] to index the data.. The table model displays rows in order of the index, not the actual order of the data (in my case a Vector of Object[]'s).. Saves a lotta work when sorting..
    If you're using a similar indexing scheme: If you're deleting a row, you have to delete the data in the vector at the INDEX table.getSelectedRow(), not the actual data contained at
    vector.elementAt(table.getSelectedRow()). This would account for a seemingly 'random' row getting deleted, instead of the row you intend.
    Because the row is unselectable, it sounds like you have a null in your model where you should have a row of data.. When you do
    vector.removeElementAt(int), the Vector class packs itself. An array does not. If you have an array, when you delete the row you must make sure you dont have that gap.. Make a new array of
    (old array length-1), populate it, and give it back to your model.. Using Vectors makes this automatic.
    Also, you must make sure your model knows the data changed:
    model.fireTableDataChanged(); otherwise it has no idea anything happened..
    IDK if that's how you're doing it, but it sounds remarkably similar to what I went thru when I put all this together..

  • Can't add row using table sorter

    I had a jtable with my own mytableModel that implements AbstractTableModel. In mytableModel, I have addRow, removeRow... so I can delete/add row dynamically by calling mytableModel.addRow(..). Everything works fine.
    However, after I added the table sorter and table map (got the code from the tutorial).
    MyTableModel myModel = new MyTableModel();
    TableSorter sorter = new TableSorter(myModel);
    JTable table = new JTable(sorter);
    sorter.addMouseListenerToHeaderInTable(table);
    Now, when i call mytableModel.addRow(..), it doesn't work anymore. It doesn't add a row anymore, why?
    Thank you so much for your help.

    I don't have a addRow method in TableSorter. My addRow method is in myTableModel. So, when I need to addRow, I called myTableModel.addRow, In my addRow method, I have fireTableRowsInserted method. This used to work using integrating with TableSorter.
    Do I need to move all my addRow, addCol....DelRow... to TableSorter? The table data are stored in myTableModel. I guess I really doesn't know how the TableSorter work :(
    Thanks

  • Table Sorter Not working in EP 7.01

    Hi All,
    The table sorter stopped working in ep 7.01.
    Can anyone comment why?
    Are there any notes or patches to be applied?
    Thanks and Regards,
    Nuzhat

    Hi Shanti,
    Thanks for replying.
    I am working on WD for Java.
    Can you please give me your table sorter Java file?
    I think there may be issues in versions.
    Previous server was ep 7.00 and now when code is moved to ep 7.01 sp05 patch 1, the table sort doesnt seems to work. even though I checked all the codes are there in the new system.
    Thanks and Regards,
    Nuzhat

  • Table.Sort only sorting records in preview pane

    I have the following M query:
    let
        OrgIdParameter = Excel.CurrentWorkbook(){[Name="ClientFilter"]}[Content],
        OrgIdValue = OrgIdParameter{0}[Column2],
        Source = Sql.Database("JOHNSQLD53", "EnterpriseAnalytics"),
        dbo_vFactEngrgServiceLocMonthlyAsOfSnapshot = Source{[Schema="dbo",Item="vFactEngrgServiceLocMonthlyAsOfSnapshot"]}[Data],
        #"Filtered Rows" = Table.SelectRows(dbo_vFactEngrgServiceLocMonthlyAsOfSnapshot, each [BeProspectClientOrgId] = OrgIdValue),
        #"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"SnapshotYear", Order.Ascending}})
    in
        #"Sorted Rows"
    however, the sort is working on the records that show in the preview pane (about 36 records), then the data goes back to being unsorted in the rest of the table when loaded in power pivot (224 rows).
    any idea why?

    I believe that Power Pivot does not reliably preserve the input sort of the data; this is a feature of the data model, not of Power Query.

  • EIT SSHR Table sorting

    Hi all,
    I have successfully personalized the EIT SSHR screen to display one of the configured EIT on a custom responsibility using a custom function(so that I can do personalization on function level without affecting other EIT screens).
    Now my challenge is that, when I click on the menu function, it takes me to the people search page, I do a search and select a employee, then it shows me the list of existing EIT records with an option of add, update and delete. Here, I need to show the existing records in a sorted order. I need the latest entry entered to appear in the top. If this is not possible, it would be great if I can have the table sorted as per one of the segment value.
    Is there a way to do this. Can someone help me in doing this and let me know the steps to do the same.
    Cheers
    Arun

    I think Tomahawk is the way to go here.
    Tomahawk allows sorting of data in the data table.
    For action based on row selection, you need to invoke java script function
    using rowOnClick attribute of t:dataTable and then make a hidden command button "click" from
    the java script.
    Regards,
    Joshua

  • CS4 - Still no table sorting

    OK -- We're up to version 6 now with InDesign and Adobe still hasn't incorporated a built-in table row sorting feature? Is it me, or does anyone else think this is absolutely absurd.
    It seems table sorting would be a big issue not just for the technical publishing crowd...but maybe I'm wrong.
    Unless I'm mistaken, from what I can gather there are 3 methods that people are currently using to sort their table row data:
    1) FREE - Manually sort the data in a Word table or Excel, then paste back into ID (which of course loses most formatting and applied styles)
    2) FREE - Use a Script like:
    http://www.kahrel.plus.com/indesign/tablesort.html
    3) EXPENSIVE - Purchase a plugin like:
    http://www.woodwing.com/en/Smart_Styles
    Anybody have any other solutions? We would love to see an inexpensive plugin that does what Smart Styles offers (without all of the other non-sorting features)...or do we have to wait another year for CS5 to find out if this feature finally makes it in.

    The several-year gap in postings on this thread, may indicate that there's not a lot of interest in having the feature built into InDesign. However, if you really need it now, look into the commercial Active Tables plug-in from dtptools.com. There's a free trial. Besides sorting, it can perform many spreadsheet functions within ID tables.
    [/EDIT] I forgot to mention that you can add your formal support for building the feature into ID here: Wishform.[/EDIT]
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices
    moyler0316 wrote:
    This would be an EXTREMELY helpful feature. I have to sort at least one table in nearly every technical publication I create. These are 2-3 pages + long, so I'd much rather click a button than do it by hand or try 1/2 a dozen different work arounds. 
    Message was edited by: peter at knowhowpro

  • EA 19 Table Sorting

    I've downloaded adf faces ea19. In its documentation is descripted
    this feature:
    <<Aspect API
    A new Aspect API (this name will likely be changed in upcoming
    releases) lets component changes
    persist across requests. For example, the sort order of a table or
    expansion of a tree can
    automatically be restored for you when you return to a page. This API
    is currently not active by
    default, but has been turned on in the demo bundle with the
    oracle.adf.view.faces.ASPECT_PERSISTENCE
    context parameter. See the Javadoc and the enclosed demos for more
    information.>>
    I'm very interested to preserve the sort order in my pages with
    tables, so I've add the follow lines in web.xml:
    <context-param>
    <param-name>oracle.adf.view.faces.CHANGE_PERSISTENCE</param-name>
    <param-value>session</param-value>
    </context-param>
    But I think ASPECT_PERSISTENCE doesn't work.
    The table sort order is not preserved, no change respect the
    precedent adf version.
    Anyone with some ideas about this problem?
    Thank you

    I think Tomahawk is the way to go here.
    Tomahawk allows sorting of data in the data table.
    For action based on row selection, you need to invoke java script function
    using rowOnClick attribute of t:dataTable and then make a hidden command button "click" from
    the java script.
    Regards,
    Joshua

  • Table sorting

    Hello All,
    I already implement table sorting in my application.How can i trigger a table sort action on a particular column after I have compeleted some other action?
    Thanks

    Use IWDNode.sortElements(Comparator).
    The Comparator instance passed to this method should cast its arguments to the node element interface and compare them by the attribute displayed in the particular column.
    Say your node is named "Employees" and the attribute is "Name" and has type "String", then it looks like
    Comparator comparator = new Comparator()
      public int compare(Object x1, Object x2)
        IEmployeesElement e1 = (IEmployeesElement ) x1;
        IEmployeesElement e2 = (IEmployeesElement ) x2;
        return e1.getName().compareTo(e2.getName());
    node.sortElements(comparator);
    Armin

  • Table Sorting: How is firstVisibleRow being affected?

    Dears,
    I'm confused at table sorting using Tablesorter.java.
    When sorting, how does Tablesorter affect the firstVisibleRow of the table?
    In the "[Working with tables|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/90ac0015-d1c5-2a10-d788-aed89990811d]" sample SDN provided, when press "sorting asending" or "sort descending", the table's first visible row changes automatically.
    I didn't understand why firstVisibleRow changed to be so. And I don't know how the firstVisibleRow will change to be.
    I checked the code of Tablesorter, and I also tried to debug into it, but didn't find any track.
    Any word is appreciated. Thanks in advance.
    Edited by: gangtee gangtee on May 2, 2008 4:59 PM

    Attached is Tablesorter.java
    package com.sap.tc.webdynpro.tests.utils;
    import java.text.Collator;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.Comparator;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Map;
    import java.util.StringTokenizer;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractDropDownByIndex;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractDropDownByKey;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractInputField;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractTableColumn;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDCaption;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDCheckBox;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDLink;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDProgressIndicator;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDRadioButton;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTable;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableCellEditor;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableColumn;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableColumnGroup;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTextEdit;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTextView;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTableColumnSortDirection;
    import com.sap.tc.webdynpro.progmodel.api.IWDAction;
    import com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent;
    import com.sap.tc.webdynpro.progmodel.api.IWDNode;
    import com.sap.tc.webdynpro.progmodel.api.IWDNodeElement;
    import com.sap.tc.webdynpro.progmodel.api.IWDViewElement;
    import com.sap.tc.webdynpro.services.sal.localization.api.WDResourceHandler;
    * Helper class that makes a Web Dynpro table UI element sortable (column-wise).
    public final class TableSorter {
          * @param table
          * @param sortAction
          * @param comparators
         public TableSorter(IWDTable table, IWDAction sortAction, Map comparators) {
              init(table, sortAction, comparators, null);
         public TableSorter(IWDTable table, IWDAction sortAction, Map comparators, String[] sortableColumns) {
              init(table, sortAction, comparators, sortableColumns);
          * Initialisation stuff
         private void init(IWDTable table, IWDAction sortAction, Map comparators, String[] sortableColumns){
              this.table = table;
              if(sortableColumns == null){
                   sortableCols = null;
              }else{
                   sortableCols = new HashMap();
                   for (int i = 0; i < sortableColumns.length; i++) {
                        sortableCols.put(sortableColumns<i>, sortableColumns<i>);
              // sanity checks
              if (sortAction == null)
                   throw new IllegalArgumentException("Sort action must be given");
              if (table == null)
                   throw new IllegalArgumentException("Table must be given");
              if (table.bindingOfDataSource() == null)
                   throw new IllegalArgumentException(
                        "Data source of table with id '" + table.getId() + "' must be bound");
              // make the columns sortable
              String dataSourcePrefix = table.bindingOfDataSource() + ".";
              setComparatorsForColumns(dataSourcePrefix, table.iterateGroupedColumns(), comparators);
              //set up the table properties
              table.setOnSort(sortAction);
              table.mappingOfOnSort().addSourceMapping(IWDTable.IWDOnSort.COL, "selectedColumn");
              table.mappingOfOnSort().addSourceMapping(IWDTable.IWDOnSort.DIRECTION, "sortDirection");     
          * Try to make the given columns sortable (recusivly, if necessary)
         private void setComparatorsForColumns(String dataSourcePrefix, Iterator columnIterator, Map comparators){
              int index = 0;
              for (Iterator it = columnIterator; it.hasNext(); ++index) { // for every column: try to make it bindable
                   IWDAbstractTableColumn abstractColumn = (IWDAbstractTableColumn) it.next();
                   if(abstractColumn instanceof IWDTableColumn){
                        IWDTableColumn column = (IWDTableColumn)abstractColumn;
                        if(sortableCols == null || sortableCols.containsKey(column.getId())){
                             //try to make this column sortable
                             Comparator comparator = null;
                             if (comparators != null){
                                  comparator = (Comparator)comparators.get(column.getId());
                             NodeElementByAttributeComparator elementComparator = null;     
                             if (comparator instanceof NodeElementByAttributeComparator) {
                                  // the easy one, attribute and ordering are given
                                  elementComparator = (NodeElementByAttributeComparator)comparator;
                             } else { // attribute must be determined
                                  String bindingOfPrimaryProperty = bindingOfPrimaryProperty(column.getTableCellEditor());
                                  if (bindingOfPrimaryProperty == null || !bindingOfPrimaryProperty.startsWith(dataSourcePrefix)){
                                       //no attribute found or outside of data source
                                       column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
                                       continue;
                                  String attributeName = bindingOfPrimaryProperty.substring(dataSourcePrefix.length());
                                  Collection subnodes = new ArrayList();
                                  if (attributeName.indexOf('.') >= 0){
                                       //attribute not immediately below data source
                                       String[] tokens = tokenize (attributeName, ".");
                                       for(int i=0; i<tokens.length-1; i++){
                                            subnodes.add(tokens<i>);
                                       attributeName = tokens[tokens.length-1];
                                  if(subnodes.size() == 0){
                                       elementComparator = new NodeElementByAttributeComparator(attributeName, comparator);
                                  }else{
                                       elementComparator = new NodeElementByAttributeComparator(attributeName, comparator, subnodes);
                             // set up internal data structures
                             comparatorForColumn.put(column, elementComparator);
                             //set sort state
                             column.setSortState(WDTableColumnSortDirection.NONE);
                        }else{
                             //column should not be sortable
                             column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
                   }else if (abstractColumn instanceof IWDTableColumnGroup){
                        //it's just a column group -> try to bind the columns of the column group
                        IWDTableColumnGroup columnGroup = (IWDTableColumnGroup)abstractColumn;
                        setComparatorsForColumns(dataSourcePrefix, columnGroup.iterateColumns(), comparators);
          * Tokenizes the input string according to the given delimiters. The delimiters will be left out.
          * Example: tokenize("Hello_World", "_") results ["Hello", "World"]
         private String[] tokenize (String input, String delim){
              StringTokenizer tokenizer = new StringTokenizer(input, delim);
              String[] tokens = new String[tokenizer.countTokens()];
              int index = 0;
              while(tokenizer.hasMoreTokens()){
                   tokens[index] = tokenizer.nextToken();
                   index++;
              return tokens;
          * This method must be called from the event handler of this table sorter's
          * sort action. It performs the actual sort operation.
         public void sort(IWDCustomEvent wdEvent, IWDNode dataSource) {
              // find the things we need
              String columnId = wdEvent.getString("selectedColumn");
              String direction = wdEvent.getString("sortDirection");
              IWDTableColumn column = (IWDTableColumn) table.getView().getElement(columnId);
              NodeElementByAttributeComparator elementComparator = (NodeElementByAttributeComparator) comparatorForColumn.get(column);
              if (elementComparator == null){
                   //not a sortable column
                   column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
                   return;
              // sorting
              elementComparator.setSortDirection(WDTableColumnSortDirection.valueOf(direction));
              dataSource.sortElements(elementComparator);
          * Returns the binding of the given table cell editor's property that is
          * considered "primary" or <code>null</code> if no such binding exists or no
          * such property can be determined.
         private static final String bindingOfPrimaryProperty(IWDTableCellEditor editor) {
              return editor instanceof IWDViewElement ? bindingOfPrimaryProperty((IWDViewElement) editor) : null;
          * Returns the binding of the given view element's property that is
          * considered "primary" or <code>null</code> if no such binding exists or no
          * such property can be determined.
         private static final String bindingOfPrimaryProperty(IWDViewElement element) {
              if (element instanceof IWDAbstractDropDownByIndex)
                   return ((IWDAbstractDropDownByIndex) element).bindingOfTexts();
              if (element instanceof IWDAbstractDropDownByKey)
                   return ((IWDAbstractDropDownByKey) element).bindingOfSelectedKey();
              if (element instanceof IWDAbstractInputField)
                   return ((IWDAbstractInputField) element).bindingOfValue();
              if (element instanceof IWDCaption)
                   return ((IWDCaption) element).bindingOfText();
              if (element instanceof IWDCheckBox)
                   return ((IWDCheckBox) element).bindingOfChecked();
              if (element instanceof IWDLink)
                   return ((IWDLink) element).bindingOfText();
              if (element instanceof IWDProgressIndicator)
                   return ((IWDProgressIndicator) element).bindingOfPercentValue();
              if (element instanceof IWDRadioButton)
                   return ((IWDRadioButton) element).bindingOfSelectedKey();
              if (element instanceof IWDTextEdit)
                   return ((IWDTextEdit) element).bindingOfValue();
              if (element instanceof IWDTextView)
                   return ((IWDTextView) element).bindingOfText();
              return null;
          * Instance of a comparator according to the ordering imposed by the
          * implementation of <code>Comparable</code>.
         private static final Comparator DEFAULT = new Comparator() {
               * Compares the given objects according to the ordering imposed by the first
               * ones <code>compareTo(Object)</code> function. Furthermore, <code>null</code>
               * is treated to be less than any object.
               * @see java.lang.Comparable#compareTo(java.lang.Object)
               * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
              public int compare(Object o1, Object o2) {
                   if (o1 == null && o2 == null)
                        return 0;
                   if (o1 == null)
                        return -1;
                   if (o2 == null)
                        return +1;
                   if (o1 instanceof Boolean && o2 instanceof Boolean)
                        return o1.toString().compareTo(o2.toString()); // false < true
                   if (o1 instanceof String && o2 instanceof String){
                        //Use a Collator for sorting according to the given Locale
                        Collator collate = Collator.getInstance(WDResourceHandler.getCurrentSessionLocale());
                        return collate.compare(o1, o2);                    
                   return ((Comparable) o1).compareTo((Comparable) o2);
          * Map of table column to comparator (<code>ReversableComparator</code>)
          * used for sorting that column (sortable columns only).
         private Map comparatorForColumn = new HashMap();
          * The table to be sorted.
         private IWDTable table = null;
          * Column-IDs of the columns, which should be sortable
         private Map sortableCols = null;
          * Generic comparator that compares node elements by a given attribute with
          * the help of a given comparator.
         public final class NodeElementByAttributeComparator implements Comparator {
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute according to the natural ordering of that attribute's
               * type (which must implement <code>java.lang.Comparable</code>).
              public NodeElementByAttributeComparator(String attributeName) {
                   this(attributeName, null, false, new ArrayList());
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute with the help of the given comparator. If no comparator
               * is given, the natural ordering of that attribute's type is used.
              public NodeElementByAttributeComparator(String attributeName, Comparator comparator) {
                   this(attributeName, comparator, false, new ArrayList());
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute either as objects (i.e. "in internal format") or as text
               * (i.e. "in external format") as indicated. The ordering is the natural
               * ordering of that attribute's type (which must implement
               * <code>java.lang.Comparable</code>) in case objects are compared or the
               * natural ordering of <code>java.lang.String</code> in case texts are compared.
              public NodeElementByAttributeComparator(String attributeName, boolean compareAsText) {
                   this(attributeName, null, compareAsText, new ArrayList());
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute according to the natural ordering of that attribute's
               * type (which must implement <code>java.lang.Comparable</code>). In addition it is possible
               * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
               * (List of child node names in the correct order)
              public NodeElementByAttributeComparator(String attributeName, Collection subnodes) {
                   this(attributeName, null, false, subnodes);
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute with the help of the given comparator. If no comparator
               * is given, the natural ordering of that attribute's type is used. In addition it is possible
               * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
               * (List of child node names in the correct order)
              public NodeElementByAttributeComparator(String attributeName, Comparator comparator, Collection subnodes) {
                   this(attributeName, comparator, false, subnodes);
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute either as objects (i.e. "in internal format") or as text
               * (i.e. "in external format") as indicated. The ordering is the natural
               * ordering of that attribute's type (which must implement
               * <code>java.lang.Comparable</code>) in case objects are compared or the
               * natural ordering of <code>java.lang.String</code> in case texts are compared. In addition it is possible
               * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
               * (List of child node names in the correct order)
              public NodeElementByAttributeComparator(String attributeName, boolean compareAsText, Collection subnodes) {
                   this(attributeName, null, compareAsText, subnodes);
               * Internal constructor.
              private NodeElementByAttributeComparator(
                   String attributeName,
                   Comparator comparator,
                   boolean compareAsText,
                   Collection subNodes) {
                   if (attributeName == null)
                        throw new IllegalArgumentException("Attribute name must not be null");
                   if (comparator == null)
                        comparator = DEFAULT;
                   this.attributeName = attributeName;
                   this.comparator = comparator;
                   this.compareAsText = compareAsText;
                   this.sortDirection = true;
                   this.subNodes = subNodes;
               * Sets the sort direction of this comparator to the given direction. The comparator sort in ascending order by default.
               * @see com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTableColumnSortDirection
              public void setSortDirection(WDTableColumnSortDirection direction){
                   if(direction.equals(WDTableColumnSortDirection.UP)){
                        sortDirection = true;
                   }else if(direction.equals(WDTableColumnSortDirection.DOWN)){
                        sortDirection = false;
               * Compares the given objects which must be instances of <code>IWDNodeElement</code>
               * according to the values of the attribute given at construction time
               * with the help of the comparator given at construction time.
               * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
               * @see com.sap.tc.webdynpro.progmodel.api.IWDNodeElement
              public int compare(Object o1, Object o2) {
                   IWDNodeElement element1 = (IWDNodeElement) o1;
                   IWDNodeElement element2 = (IWDNodeElement) o2;
                   if(subNodes.size() > 0){
                        element1 = getSubNodeElement(element1, 0);
                        element2 = getSubNodeElement(element2, 0);
                   Object attributeValue1 = null;
                   Object attributeValue2 = null;
                   if(element1 != null){
                        attributeValue1 =
                             compareAsText
                                  ? element1.getAttributeAsText(attributeName)
                                  : element1.getAttributeValue(attributeName);
                   if(element2 != null){
                        attributeValue2 =
                             compareAsText
                                  ? element2.getAttributeAsText(attributeName)
                                  : element2.getAttributeValue(attributeName);
                   if(sortDirection){
                        return comparator.compare(attributeValue1, attributeValue2);
                   }else{
                        return comparator.compare(attributeValue2, attributeValue1);
               * Determines recursivly the child node, which have an attribute with the given name.
               * The path to this child node must be specified in the subnodes property of this comparator.
               * Start this method with index = 0.
              private IWDNodeElement getSubNodeElement(IWDNodeElement currentElement, int index){
                   if(currentElement == null || index >= subNodes.size()){
                        //end of recursion
                        return currentElement;
                   }else{
                        return getSubNodeElement(currentElement.node().getChildNode((String)subNodes.toArray()[index], currentElement.index()).getCurrentElement(), index+1);
                        //return getSubNodeElement(currentElement.node().getChildNode((String)subNodes.toArray()[index], currentElement.index()).getElementAt(0), index+1);
               * Name of the attribute used for comparisons.
              private final String attributeName;
               * Comparator used for comparing the attribute's values.
              private final Comparator comparator;
               * Indicates whether attribute values are compared as text (as opposed to
               * "as objects").
              private final boolean compareAsText;
               * Sort direction (true = ascending order, false = descending order)
              private boolean sortDirection;
               * List of child node names
               * (Description of the path from the given context node to the specified attribute)
              private Collection subNodes;

  • 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?

  • Table sorter

    Hi,
         i have to implement a table sorter in one of my webdypro application. I have done all the steps mentioned in one of the blog and have also imported TableSorter.java class. i am getting sorting icons in column headers. but on clicking icon nothing happens...i think there is some problem with the java class which i have imported. So can anybody provide the code of tablesorter.java class.
    Thanks in advance,
        Reena

    Hi Reena,
    Here is the code.Just change the package name.
    * Created on Sep 6, 2007
    * To change the template for this generated file go to
    * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
    package ibm.com.tradefund.utils;
    * @author Administrator
    * To change the template for this generated type comment go to
    * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
    import java.text.Collator;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.Comparator;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Map;
    import java.util.StringTokenizer;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractDropDownByIndex;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractDropDownByKey;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractInputField;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractTableColumn;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDCaption;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDCheckBox;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDLink;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDProgressIndicator;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDRadioButton;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTable;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableCellEditor;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableColumn;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableColumnGroup;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTextEdit;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTextView;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTableColumnSortDirection;
    import com.sap.tc.webdynpro.progmodel.api.IWDAction;
    import com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent;
    import com.sap.tc.webdynpro.progmodel.api.IWDNode;
    import com.sap.tc.webdynpro.progmodel.api.IWDNodeElement;
    import com.sap.tc.webdynpro.progmodel.api.IWDViewElement;
    import com.sap.tc.webdynpro.services.sal.localization.api.WDResourceHandler;
    * Helper class that makes a Web Dynpro table UI element sortable (column-wise).
    public final class TableSorter {
          * @param table
          * @param sortAction
          * @param comparators
          * Creates a table sorter for the given table using the given sort action.
          * This constructor must be called from <code>wdDoModifyView()</code>, but
          * usually only when that hook is called for the first time. Store the newly
          * created instance in a context attribute with Java native type
          * <code>com.sap.tc.webdynpro.tests.utils.TableSorter</code>.
          * The given sort action's event handler will be bound to the <code>onSort</code>
          * event of the table and must at least call this table sorter's
          * <code>sort(wdEvent)</code> method.
          * Every column of the table is made sortable if possible according to the
          * following rules.
          * If a comparator is given for a column's ID and it is a
          * <code>NodeElementByAttributeComparator</code>, then that comparator defines
          * both the attribute and the ordering used to sort that column.
          * If any other comparator is given and an attribute can be determined from
          * that column's table cell editor, then that attribute is used to sort that
          * column according to the ordering imposed by the given comparator.
          * If no comparator is given but an attribute can be determined from
          * that column's table cell editor, then that attribute is used to sort that
          * column according to the natural ordering of that attribute's type.
          * Else that column is left untouched.
          * Additionally it is possible to define the sortable columns by their
          * TableColumn UI element ids.
          * @see sort()
          * @see NodeElementByAttributeComparator
          * @see com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTable
         public TableSorter(IWDTable table, IWDAction sortAction, Map comparators) {
              init(table, sortAction, comparators, null);
         public TableSorter(IWDTable table, IWDAction sortAction, Map comparators, String[] sortableColumns) {
              init(table, sortAction, comparators, sortableColumns);
          * Initialisation stuff
         private void init(IWDTable table, IWDAction sortAction, Map comparators, String[] sortableColumns){
              this.table = table;
              if(sortableColumns == null){
                   sortableCols = null;
              }else{
                   sortableCols = new HashMap();
                   for (int i = 0; i < sortableColumns.length; i++) {
                        sortableCols.put(sortableColumns<i>, sortableColumns<i>);
              // sanity checks
              if (sortAction == null)
                   throw new IllegalArgumentException("Sort action must be given");
              if (table == null)
                   throw new IllegalArgumentException("Table must be given");
              if (table.bindingOfDataSource() == null)
                   throw new IllegalArgumentException(
                        "Data source of table with id '" + table.getId() + "' must be bound");
              // make the columns sortable
              String dataSourcePrefix = table.bindingOfDataSource() + ".";
              //TODO: remove the following line since this method is not longer available in later releases
              setComparatorsForColumns(dataSourcePrefix, table.iterateColumns(), comparators);
              setComparatorsForColumns(dataSourcePrefix, table.iterateGroupedColumns(), comparators);
              //set up the table properties
              table.setOnSort(sortAction);
              table.mappingOfOnSort().addSourceMapping(IWDTable.IWDOnSort.COL, "selectedColumn");
              table.mappingOfOnSort().addSourceMapping(IWDTable.IWDOnSort.DIRECTION, "sortDirection");     
          * Try to make the given columns sortable (recusivly, if necessary)
         private void setComparatorsForColumns(String dataSourcePrefix, Iterator columnIterator, Map comparators){
              int index = 0;
              for (Iterator it = columnIterator; it.hasNext(); ++index) { // for every column: try to make it bindable
                   IWDAbstractTableColumn abstractColumn = (IWDAbstractTableColumn) it.next();
                   if(abstractColumn instanceof IWDTableColumn){
                        IWDTableColumn column = (IWDTableColumn)abstractColumn;
                        if(sortableCols == null || sortableCols.containsKey(column.getId())){
                             //try to make this column sortable
                             Comparator comparator = null;
                             if (comparators != null){
                                  comparator = (Comparator)comparators.get(column.getId());
                             NodeElementByAttributeComparator elementComparator = null;     
                             if (comparator instanceof NodeElementByAttributeComparator) {
                                  // the easy one, attribute and ordering are given
                                  elementComparator = (NodeElementByAttributeComparator)comparator;
                             } else { // attribute must be determined
                                  String bindingOfPrimaryProperty = bindingOfPrimaryProperty(column.getTableCellEditor());
                                  if (bindingOfPrimaryProperty == null || !bindingOfPrimaryProperty.startsWith(dataSourcePrefix)){
                                       //no attribute found or outside of data source
                                       column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
                                       continue;
                                  String attributeName = bindingOfPrimaryProperty.substring(dataSourcePrefix.length());
                                  Collection subnodes = new ArrayList();
                                  if (attributeName.indexOf('.') >= 0){
                                       //attribute not immediately below data source
                                       String[] tokens = tokenize (attributeName, ".");
                                       for(int i=0; i<tokens.length-1; i++){
                                            subnodes.add(tokens<i>);
                                       attributeName = tokens[tokens.length-1];
                                  if(subnodes.size() == 0){
                                       elementComparator = new NodeElementByAttributeComparator(attributeName, comparator);
                                  }else{
                                       elementComparator = new NodeElementByAttributeComparator(attributeName, comparator, subnodes);
                             // set up internal data structures
                             comparatorForColumn.put(column, elementComparator);
                             //set sort state
                             column.setSortState(WDTableColumnSortDirection.NONE);
                        }else{
                             //column should not be sortable
                             column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
                   }else if (abstractColumn instanceof IWDTableColumnGroup){
                        //it's just a column group -> try to bind the columns of the column group
                        IWDTableColumnGroup columnGroup = (IWDTableColumnGroup)abstractColumn;
                        setComparatorsForColumns(dataSourcePrefix, columnGroup.iterateColumns(), comparators);
          * Tokenizes the input string according to the given delimiters. The delimiters will be left out.
          * Example: tokenize("Hello_World", "_") results ["Hello", "World"]
         private String[] tokenize (String input, String delim){
              StringTokenizer tokenizer = new StringTokenizer(input, delim);
              String[] tokens = new String[tokenizer.countTokens()];
              int index = 0;
              while(tokenizer.hasMoreTokens()){
                   tokens[index] = tokenizer.nextToken();
                   index++;
              return tokens;
          * This method must be called from the event handler of this table sorter's
          * sort action. It performs the actual sort operation.
         public void sort(IWDCustomEvent wdEvent, IWDNode dataSource) {
              // find the things we need
              String columnId = wdEvent.getString("selectedColumn");
              String direction = wdEvent.getString("sortDirection");
              IWDTableColumn column = (IWDTableColumn) table.getView().getElement(columnId);
              NodeElementByAttributeComparator elementComparator = (NodeElementByAttributeComparator) comparatorForColumn.get(column);
              if (elementComparator == null){
                   //not a sortable column
                   column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
                   return;
              // sorting
              elementComparator.setSortDirection(WDTableColumnSortDirection.valueOf(direction));
              dataSource.sortElements(elementComparator);
          * Returns the binding of the given table cell editor's property that is
          * considered "primary" or <code>null</code> if no such binding exists or no
          * such property can be determined.
         private static final String bindingOfPrimaryProperty(IWDTableCellEditor editor) {
              return editor instanceof IWDViewElement ? bindingOfPrimaryProperty((IWDViewElement) editor) : null;
          * Returns the binding of the given view element's property that is
          * considered "primary" or <code>null</code> if no such binding exists or no
          * such property can be determined.
         private static final String bindingOfPrimaryProperty(IWDViewElement element) {
              if (element instanceof IWDAbstractDropDownByIndex)
                   return ((IWDAbstractDropDownByIndex) element).bindingOfTexts();
              if (element instanceof IWDAbstractDropDownByKey)
                   return ((IWDAbstractDropDownByKey) element).bindingOfSelectedKey();
              if (element instanceof IWDAbstractInputField)
                   return ((IWDAbstractInputField) element).bindingOfValue();
              if (element instanceof IWDCaption)
                   return ((IWDCaption) element).bindingOfText();
              if (element instanceof IWDCheckBox)
                   return ((IWDCheckBox) element).bindingOfChecked();
              if (element instanceof IWDLink)
                   return ((IWDLink) element).bindingOfText();
              if (element instanceof IWDProgressIndicator)
                   return ((IWDProgressIndicator) element).bindingOfPercentValue();
              if (element instanceof IWDRadioButton)
                   return ((IWDRadioButton) element).bindingOfSelectedKey();
              if (element instanceof IWDTextEdit)
                   return ((IWDTextEdit) element).bindingOfValue();
              if (element instanceof IWDTextView)
                   return ((IWDTextView) element).bindingOfText();
              return null;
          * Instance of a comparator according to the ordering imposed by the
          * implementation of <code>Comparable</code>.
         private static final Comparator DEFAULT = new Comparator() {
               * Compares the given objects according to the ordering imposed by the first
               * ones <code>compareTo(Object)</code> function. Furthermore, <code>null</code>
               * is treated to be less than any object.
               * @see java.lang.Comparable#compareTo(java.lang.Object)
               * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
              public int compare(Object o1, Object o2) {
                   if (o1 == null && o2 == null)
                        return 0;
                   if (o1 == null)
                        return -1;
                   if (o2 == null)
                        return +1;
                   if (o1 instanceof Boolean && o2 instanceof Boolean)
                        return o1.toString().compareTo(o2.toString()); // false < true
                   if (o1 instanceof String && o2 instanceof String){
                        //Use a Collator for sorting according to the given Locale
                        Collator collate = Collator.getInstance(WDResourceHandler.getCurrentSessionLocale());
                        return collate.compare(o1, o2);                    
                   return ((Comparable) o1).compareTo((Comparable) o2);
          * Map of table column to comparator (<code>ReversableComparator</code>)
          * used for sorting that column (sortable columns only).
         private Map comparatorForColumn = new HashMap();
          * The table to be sorted.
         private IWDTable table = null;
          * Column-IDs of the columns, which should be sortable
         private Map sortableCols = null;
          * Generic comparator that compares node elements by a given attribute with
          * the help of a given comparator.
         public final class NodeElementByAttributeComparator implements Comparator {
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute according to the natural ordering of that attribute's
               * type (which must implement <code>java.lang.Comparable</code>).
              public NodeElementByAttributeComparator(String attributeName) {
                   this(attributeName, null, false, new ArrayList());
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute with the help of the given comparator. If no comparator
               * is given, the natural ordering of that attribute's type is used.
              public NodeElementByAttributeComparator(String attributeName, Comparator comparator) {
                   this(attributeName, comparator, false, new ArrayList());
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute either as objects (i.e. "in internal format") or as text
               * (i.e. "in external format") as indicated. The ordering is the natural
               * ordering of that attribute's type (which must implement
               * <code>java.lang.Comparable</code>) in case objects are compared or the
               * natural ordering of <code>java.lang.String</code> in case texts are compared.
              public NodeElementByAttributeComparator(String attributeName, boolean compareAsText) {
                   this(attributeName, null, compareAsText, new ArrayList());
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute according to the natural ordering of that attribute's
               * type (which must implement <code>java.lang.Comparable</code>). In addition it is possible
               * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
               * (List of child node names in the correct order)
              public NodeElementByAttributeComparator(String attributeName, Collection subnodes) {
                   this(attributeName, null, false, subnodes);
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute with the help of the given comparator. If no comparator
               * is given, the natural ordering of that attribute's type is used. In addition it is possible
               * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
               * (List of child node names in the correct order)
              public NodeElementByAttributeComparator(String attributeName, Comparator comparator, Collection subnodes) {
                   this(attributeName, comparator, false, subnodes);
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute either as objects (i.e. "in internal format") or as text
               * (i.e. "in external format") as indicated. The ordering is the natural
               * ordering of that attribute's type (which must implement
               * <code>java.lang.Comparable</code>) in case objects are compared or the
               * natural ordering of <code>java.lang.String</code> in case texts are compared. In addition it is possible
               * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
               * (List of child node names in the correct order)
              public NodeElementByAttributeComparator(String attributeName, boolean compareAsText, Collection subnodes) {
                   this(attributeName, null, compareAsText, subnodes);
               * Internal constructor.
              private NodeElementByAttributeComparator(
                   String attributeName,
                   Comparator comparator,
                   boolean compareAsText,
                   Collection subNodes) {
                   if (attributeName == null)
                        throw new IllegalArgumentException("Attribute name must not be null");
                   if (comparator == null)
                        comparator = DEFAULT;
                   this.attributeName = attributeName;
                   this.comparator = comparator;
                   this.compareAsText = compareAsText;
                   this.sortDirection = true;
                   this.subNodes = subNodes;
               * Sets the sort direction of this comparator to the given direction. The comparator sort in ascending order by default.
               * @see com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTableColumnSortDirection
              public void setSortDirection(WDTableColumnSortDirection direction){
                   if(direction.equals(WDTableColumnSortDirection.UP)){
                        sortDirection = true;
                   }else if(direction.equals(WDTableColumnSortDirection.DOWN)){
                        sortDirection = false;
               * Compares the given objects which must be instances of <code>IWDNodeElement</code>
               * according to the values of the attribute given at construction time
               * with the help of the comparator given at construction time.
               * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
               * @see com.sap.tc.webdynpro.progmodel.api.IWDNodeElement
              public int compare(Object o1, Object o2) {
                   IWDNodeElement element1 = (IWDNodeElement) o1;
                   IWDNodeElement element2 = (IWDNodeElement) o2;
                   if(subNodes.size() > 0){
                        element1 = getSubNodeElement(element1, 0);
                        element2 = getSubNodeElement(element2, 0);
                   Object attributeValue1 = null;
                   Object attributeValue2 = null;
                   if(element1 != null){
                        attributeValue1 =
                             compareAsText
                                  ? element1.getAttributeAsText(attributeName)
                                  : element1.getAttributeValue(attributeName);
                   if(element2 != null){
                        attributeValue2 =
                             compareAsText
                                  ? element2.getAttributeAsText(attributeName)
                                  : element2.getAttributeValue(attributeName);
                   if(sortDirection){
                        return comparator.compare(attributeValue1, attributeValue2);
                   }else{
                        return comparator.compare(attributeValue2, attributeValue1);
               * Determines recursivly the child node, which have an attribute with the given name.
               * The path to this child node must be specified in the subnodes property of this comparator.
               * Start this method with index = 0.
              private IWDNodeElement getSubNodeElement(IWDNodeElement currentElement, int index){
                   if(currentElement == null || index >= subNodes.size()){
                        //end of recursion
                        return currentElement;
                   }else{
                        return getSubNodeElement(currentElement.node().getChildNode((String)subNodes.toArray()[index], currentElement.index()).getCurrentElement(), index+1);
                        //return getSubNodeElement(currentElement.node().getChildNode((String)subNodes.toArray()[index], currentElement.index()).getElementAt(0), index+1);
               * Name of the attribute used for comparisons.
              private final String attributeName;
               * Comparator used for comparing the attribute's values.
              private final Comparator comparator;
               * Indicates whether attribute values are compared as text (as opposed to
               * "as objects").
              private final boolean compareAsText;
               * Sort direction (true = ascending order, false = descending order)
              private boolean sortDirection;
               * List of child node names
               * (Description of the path from the given context node to the specified attribute)
              private Collection subNodes;
    Re: Webdynpro Table: Column Header sort icon not visible
    Regards,
    Mithu

  • How to check internal table sorted or not

    Hi all
    I need to check internal table sorted or not which is without header line and having only one field and six values. please let me know how to check it is sorted or not because i need to display message if it is not sorted.
    thanks,
    Minal

    Hi Minal,
    Go through  this info.
    Sorted tables
    This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHERE condition.
    Stable sort
    The option
    SORT <itab> ... STABLE.
    allows you to perform a stable sort, that is, the relative sequence of lines that are unchanged by the sort is not changed. If you do not use the STABLE option, the sort sequence is not preserved. If you sort a table several times by the same key, the sequence of the table entries will change in each sort. However, a stable sort takes longer than an unstable sort.
    Examples
    DATA: BEGIN OF LINE,
            LAND(3)  TYPE C,
            NAME(10) TYPE C,
            AGE      TYPE I,
            WEIGHT   TYPE P DECIMALS 2,
          END OF LINE.
    DATA ITAB LIKE STANDARD TABLE OF LINE WITH NON-UNIQUE KEY LAND.
    LINE-LAND = 'G'.   LINE-NAME   = 'Hans'.
    LINE-AGE  = 20.    LINE-WEIGHT = '80.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'USA'. LINE-NAME   = 'Nancy'.
    LINE-AGE  = 35.    LINE-WEIGHT = '45.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'USA'. LINE-NAME   = 'Howard'.
    LINE-AGE  = 40.    LINE-WEIGHT = '95.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'GB'.  LINE-NAME   = 'Jenny'.
    LINE-AGE  = 18.    LINE-WEIGHT = '50.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'F'.   LINE-NAME   = 'Michele'.
    LINE-AGE  = 30.    LINE-WEIGHT = '60.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'G'.   LINE-NAME   = 'Karl'.
    LINE-AGE  = 60.    LINE-WEIGHT = '75.00'.
    APPEND LINE TO ITAB.
    PERFORM LOOP_AT_ITAB.
    SORT ITAB.
    PERFORM LOOP_AT_ITAB.
    SORT ITAB.
    PERFORM LOOP_AT_ITAB.
    SORT ITAB STABLE.
    PERFORM LOOP_AT_ITAB.
    SORT ITAB DESCENDING BY LAND WEIGHT ASCENDING.
    PERFORM LOOP_AT_ITAB.
    FORM LOOP_AT_ITAB.
      LOOP AT ITAB INTO LINE.
        WRITE: / LINE-LAND, LINE-NAME, LINE-AGE, LINE-WEIGHT.
      ENDLOOP.
      SKIP.
    ENDFORM.
    ************rewords some points if it is helpful.
    Rgds,
    P.Naganjana Reddy

  • New Version of Table Sorter

    Hi All,
    I require new version of Table Sorter.
    The table sorter that I am using may not be updated.
    It doesn't sort the decimal fields.
    Thanks,
    Nikhil

    >
    satish jhariya wrote:
    > Hi
    >
    > Use this link to access the [TableSorter File|https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/tablesorterClassfor+WebDynpro]
    >
    > Best Regards
    > Satish Kumar
    Hi Satish,
    I've just tried to use the updated code you've added to the Wiki and it doesn't appear to be syntactically correct.
    There are two problems I can see - it looks like the Wiki software has corrupted a lot of the code with "Unknown Macro :" added all over the place as well as some special characters being replaced, and some of the lines of code appear to be incomplete.
    Could you please have a look at it and correct so that it works as it's useless at the moment?
    Thanks,
    Gareth.

Maybe you are looking for

  • Can't get SQL 2008 Express installed

    Hope some one can help me. I am trying to install 2008 Express version and I constantly get the following error. I have tried pretty much all flavors of express and get the same thing. I uninstalled several time and reinstall but keep getting the sam

  • Time Capsule backup cannot be seen on new MAC after resetting Time Capsule and changing password.

    I have backed up my MAC to Time Capsule with Time Machine, erased HDD and clean installed OX Yosemite. After installation I have to reconfigure Wi Fi, so I reset my Time Capsule changed password. Now I cannot see my previous back up on reinstalled MA

  • Backword saving from Indesign CS4 to indesign CS

    Hi Im having a problem exporting artwork produced in Indesign CS4 for Mac to be used in Indesign CS for PC. I have used a copy of Indesign CS3, back saving from CS4 to CS3 and then from CS3 to CS. But sadly my client still cant open the files - has a

  • Backup iphone in Time Capsule

    Hi, i have receveid AirPort Time Capsule for xmas and i could not be able to do backup from from my iphone to TC. Ídem for my ipad Anyone could help me?

  • One iphone not recognized, but another is in Windows XP

    I have a user that has an odd problem. This person has 2 iPhones - a 4 and a 4s.  This week the 4 stopped being recognized by Windows XP on his laptop when he plugs it in.  It won't charge from that computer either.  However if you plug it into anoth