Sorting datatable based on column

Hi,
I am new to java studio creator and java. I am trying to sort the datatable based on a column using the methods given in previous posts which uses a button in the column header. I am trying to implement the same method but getting an error when using dataTable1Model.execute().
My code is
public String button1_action() {
// TODO: Process the button click action. Return value is a navigation
// case name where null will return to the same page.
// SesssionBean1.tbl_sde_helpRowSet1
getSessionBean1().getTbl_sde_helpRowSet().setCommand("select * from tblSample order by tblSample.serial_no");
// getDataTable1Model()
dataTable1Model.execute();
return null;
The error i am getting is
Cannot find symbol
symbol:method execute()
location: class com.sun.jsfcl.data.CachedRowSetDataModel
Please help me solve this.
Thanks,
Sru

Hi,
Thanks for the reply John. I tried using the Table component. But the problem I am facing with using that is I am not able to add scroll bars to it. I tried using the table component inside group panel just like using dataTable component inside group panel to get scroll bars. But didnt work. Any idea on how to add scroll bars to the table.
Thanks,
Sru

Similar Messages

  • Sort the month name column based on month id in rpd itself only

    sort the month name column based on month id in rpd itself only without creating the logical column.

    Hi,
    sort the month name column based on month id in rpd itself only without creating the logical column. Can you be bit specific?
    Is this what you want..http://www.biconsultinggroup.com/knowledgebase.asp?CategoryID=198&SubCategoryID=368
    Regards,
    Srikanth
    http://bintelligencegroup.wordpress.com

  • Table Sorting based on Column Selection

    Dear All,
    I am using an AbstractTableModel. I would like to implement the sorting based on Column selection. Could anyone help me in this please.
    Thanks in advance,
    Regards
    Irfaan

    check this
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.UIManager;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumnModel;
    import java.awt.Component;
    import java.awt.GridLayout;
    import java.awt.Insets;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.util.Hashtable;
    public class TableSorter extends JPanel
        private boolean             DEBUG       = false;
        private Object[]            columnNames = { "First Name", "Last Name", "Sport", "# of Years",
                                                    "Vegetarian"};
        private Object[][]          data        = { { "Mary", "Campione", "Snowboarding", 1, 2 },
                { "Alison", "Huml", "Rowing", 3, 4 }, { "Kathy", "Walrath", "Knitting", 5, 9 },
                { "Sharon", "Zakhour", "Speed reading", 6, 10 }, { "Philip", "Milne", "Pool", 7, 11 },
                { "Isaac", "Rabinovitch", "Nitpicking", 8, 12 }, };
        private SortFilterModel     m_modSortFilterModel;
        private TableColumnModel    m_modColumnModel;
        private TableHeaderRenderer m_btnSorterRenderer;
        protected boolean           m_bAbCOC    = true;
        JTable                      table       = new JTable();
        public TableSorter()
            super(new GridLayout(1, 0));
            m_modSortFilterModel = new SortFilterModel();
            m_modSortFilterModel.addMouseListener(table);
            table.setModel(m_modSortFilterModel);
            m_btnSorterRenderer = new TableHeaderRenderer();
            m_modColumnModel = table.getColumnModel();
            for (int i = 0; i < columnNames.length; i++)
                m_modColumnModel.getColumn(i).setHeaderRenderer(m_btnSorterRenderer);
            JScrollPane scrollPane = new JScrollPane(table);
            add(scrollPane);
        private class SortFilterModel extends AbstractTableModel
            int[]           indexes;
            ATSTableSorter  sorter;
            public String[] tableHeadersArray;
            boolean         isAscent = true;
            public void addMouseListener(final JTable table)
                table.getTableHeader().addMouseListener(new MouseAdapter()
                    public void mouseClicked(MouseEvent event)
                        int tableColumn = table.columnAtPoint(event.getPoint());
                        m_btnSorterRenderer.setPressedColumn(tableColumn);
                        m_btnSorterRenderer.setSelectedColumn(tableColumn);
                        if (TableHeaderRenderer.DOWN == m_btnSorterRenderer.getState(tableColumn))
                            isAscent = true;
                        else
                            isAscent = false;
                        // translate to table model index and sort
                        int modelColumn = table.convertColumnIndexToModel(tableColumn);
                        sortByColumn(modelColumn, isAscent);
            public Object getValueAt(int row, int col)
                int rowIndex = row;
                if (indexes != null)
                    rowIndex = indexes[row];
                return data[rowIndex][col];
            public void setValueAt(Object value, int row, int col)
                int rowIndex = row;
                if (indexes != null)
                    rowIndex = indexes[row];
                super.setValueAt(value, rowIndex, col);
            public void sortByColumn(int column, boolean isAscent)
                if (sorter == null)
                    sorter = new ATSTableSorter(this);
                sorter.sort(column, isAscent);
                fireTableDataChanged();
            public int[] getIndexes()
                int n = getRowCount();
                if (indexes != null)
                    if (indexes.length == n)
                        return indexes;
                indexes = new int[n];
                for (int i = 0; i < n; i++)
                    indexes[i] = i;
                return indexes;
            public int getRowCount()
                return data.length;
            public String getColumnName(int c)
                return columnNames[c].toString();
            public int getColumnCount()
                return columnNames.length;
            public Class getColumnClass(int col)
                switch (col)
                case 0:
                    return String.class;
                case 1:
                    return String.class;
                case 2:
                    return String.class;
                case 3:
                    return Integer.class;
                case 4:
                    return Integer.class;
                          default:
                    return Object.class;
        class ATSTableSorter
            SortFilterModel model;
            public ATSTableSorter(SortFilterModel model)
                this.model = model;
            public void sort(int column, boolean isAscent)
                int n = model.getRowCount();
                int[] indexes = model.getIndexes();
                for (int i = 0; i < n - 1; i++)
                    int k = i;
                    for (int j = i + 1; j < n; j++)
                        if (isAscent)
                            if (compare(column, j, k) < 0)
                                k = j;
                        else
                            if (compare(column, j, k) > 0)
                                k = j;
                    int tmp = indexes;
    indexes[i] = indexes[k];
    indexes[k] = tmp;
    public int compare(int column, int row1, int row2)
    Object o1 = model.getValueAt(row1, column);
    Object o2 = model.getValueAt(row2, column);
    if (o1 == null && o2 == null)
    return 0;
    else if (o1 == null)
    return -1;
    else if (o2 == null)
    return 1;
    else
    Class type = model.getColumnClass(column);
    if (type.getSuperclass() == Number.class)
    return compare((Number) o1, (Number) o2);
    else if (type == String.class)
    return ((String) o1).compareTo((String) o2);
    else
    return ((String) o1).compareTo((String) o2);
    public int compare(Number o1, Number o2)
    double n1 = o1.doubleValue();
    double n2 = o2.doubleValue();
    if (n1 < n2)
    return -1;
    else if (n1 > n2)
    return 1;
    else
    return 0;
    class TableHeaderRenderer extends JButton implements TableCellRenderer
    public static final int NONE = 0;
    public static final int DOWN = 1;
    public static final int UP = 2;
    int pushedColumn;
    Hashtable state;
    public TableHeaderRenderer()
    pushedColumn = -1;
    state = new Hashtable();
    setMargin(new Insets(0, 0, 0, 0));
    setHorizontalTextPosition(LEFT);
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus,
    int row, int column)
    setText((value == null) ? "" : value.toString());
    setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    boolean isPressed = (column == pushedColumn);
    getModel().setPressed(isPressed);
    getModel().setArmed(isPressed);
    return this;
    public void setPressedColumn(int col)
    pushedColumn = col;
    public void setSelectedColumn(int col)
    if (col < 0)
    return;
    Integer value = null;
    Object obj = state.get(new Integer(col));
    if (obj == null)
    value = new Integer(DOWN);
    else
    if (((Integer) obj).intValue() == DOWN)
    value = new Integer(UP);
    else
    value = new Integer(DOWN);
    state.clear();
    state.put(new Integer(col), value);
    public int getState(int col)
    int retValue;
    Object obj = state.get(new Integer(col));
    if (obj == null)
    retValue = NONE;
    else
    if (((Integer) obj).intValue() == DOWN)
    retValue = DOWN;
    else
    retValue = UP;
    return retValue;
    private static void createAndShowGUI()
    JFrame frame = new JFrame("TableDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    TableSorter newContentPane = new TableSorter();
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args)
    javax.swing.SwingUtilities.invokeLater(new Runnable()
    public void run()
    createAndShowGUI();

  • Sorting a conditional list column doesn't roll up same results?

    I have a list with a column that adds the data of some other columns.
    When I look at the list in Standard View, and click on the column heading to sort, the dropdown looks like:
    Smallest on Top
    Largest on Top
    Clear Filter...
    0
    0
    0
    1
    1
    2
    2
    2
    2
    etc
    Why wouldn't it be rolling up same output? And how to fix?
    Thanks,
    Scott

    The average is also called the mean. To calculate the average of numbers in two or more columns in a row, use the AVERAGE function.
    COLUMN1
    COLUMN2
    COLUMN3
    FORMULA
    DESCRIPTION (RESULT)
    6
    5
    4
    =AVERAGE([Column1], [Column2],[Column3])
    Average of the numbers in the first three columns (5)
    6
    5
    4
    =AVERAGE(IF([Column1]>[Column2], [Column1]-[Column2], 10), [Column3])
    If Column1 is greater than Column2, calculate the average of the difference and Column3. Else calculate the average of the value 10 and Column3 (2.5)
    I tested in my local environment,it is giving average value only.Please  check the same thing in another list.
    If your number contains N/A value, then check the below article
    http://sharepoint.stackexchange.com/questions/67678/sharepoint-2007-calculated-column-formula-for-calculation-based-on-column-con

  • N9 Photo Gallery sort order - based on what?

    Hello,
    I am thrilled with my N9, but have one problem: I want to use the phone to keep not only photos made with it. I therefore saved extra photos in the Pictures folder. They appear in the gallery, but in a weird order, not based on either the name, EXIF date, modification date or creation date. Is there a possibility to sort them on either of these? All I want is to control the sort order. After all, it is MY gallery...
    On my previous phone (N8) sorting was based on the last modification date. Also not optimal (EXIF date would have been perfect) but still controllable.
    Solved!
    Go to Solution.

    Well, maybe those pictures were never edited outside the phone, I don't know.
    Anyway, I believe I found the explanation: I exported the photos from Picasa, maxing them to a resolution of 1600xXXX. This way all files were created... today. Nevertheless the EXIF information is correctly saved by Picasa, so Date Image Taken was preserved. Although I modified in all files the creation date to be equal to EXIF Date Image Taken (ACDSee/batch/AdjustTimeStamp) , and then also renamed all pictures based on that, the "new" creation date still remains saved somewhere in the picture files and the Gallery sorts the pictures on it! The pictures were sorted in the reversed order I exported them from Picasa... Bad.
    Anyway, since this is not a request forum, it would be futile to say (again) that Nokia should use the EXIF Date Picture Taken for picture sorting. So I don't say it (!).

  • Create "Object" Type based on columns of a table

    Hi Experts
    is it possible to create an Object Type based on columns of a table?
    for example the syntax for creation of type is
    CREATE OR REPLACE TYPE temp_t
    AS OBJECT (ID number, code number)
    can we create a type that is based on columns of an existing table? so that we donot have to write down all the column names in each type as i have to create types based on 100 and above tables :-s
    Please help me out here!
    Best Regards

    You cannot do that Zia, check below code:
    SQL> create or replace type temp_t as object(object_name all_objects.object_name%TYPE);
      2  /
    Warning: Type created with compilation errors.
    SQL> sho err
    Errors for TYPE TEMP_T:
    LINE/COL ERROR
    0/0      PL/SQL: Compilation unit analysis terminated
    1/35     PLS-00201: identifier 'ALL_OBJECTS.OBJECT_NAME' must be declared

  • Performance operations based on Column values in SQL server 2008

    Hi ,
    I have a table which consist of following columns
    ID    Formula              
    Values                 
    DisplayValue
    1                    
    a*b/100       100*12/100    
          null
    2                    
    b*c/100       
    12*4/100              
    null
    I want to perform operation based on column "Values" and save data after operations in new column Name "Display Value" .i.e I want to get the below result . Can anyone please help.
    ID    Formula              
    Values                 
    DisplayValue
    1                    
    a*b/100       100*12/100    
          12
    2                    
    b*c/100       
    12*4/100             
    0.48
    Thanks for the help.
    Regards, Priti A

    Try this,
    create table #mytable (ID int,Formula varchar(10), [Values] varchar(10), DisplayValue decimal(10,4))
    insert into #mytable values(1 ,'a*b/100','100*12/100',null)
    insert into #mytable values(2 ,'b*c/100','12*4/100',null)
    declare @rowcount int=1
    while @rowcount <= (select max(id) from #mytable)
    begin
    declare @expression nvarchar(max)
    select @expression=[values] from #mytable where id = + @rowcount
    declare @sql nvarchar(max)
    set @sql = 'select @result = ' + @expression
    declare @result decimal(10,4)
    exec sp_executesql @sql, N'@result decimal(10,4) output', @result = @result out
    update #mytable set DisplayValue= @result where id = @rowcount
    set @rowcount=@rowcount+1
    end
    select * from #mytable
    Regards, RSingh

  • Sort order and hierarchical columns

    I have a report with a hierarchical column (say total, country, city), another dimension (say outdated, actual, undecided) and a measure. In the report should show the results grouped, sorted by the hierarchical column. So i configured the report to be sorted by column one.
    But if i click on the + in front of total, i get
    + total actual 200
    ...... outdated 400
    ...... undecided 700
    +france         actual          150
    +germay        actual          50
    +france         outdated     300
    +germany      outdated     100
    +france         undecided    300
    +germany      undecided    400
    instead of
    +total  actual          200
    ...... outdated 400
    ...... undecided 700
    + france actual 150
    ...... outdated 300
    ...... undecided 300
    + germany actual 50
    ...... outdated 100
    ...... undecided 400
    Is there a possibility to get the second version?
    Thanks
    Martin

    Ok, this one is on me. The reason for this behaviour is:
    The country field has a sort field defined, but (we are still in development) this is allways zero, therefore OBI sorts by zero and assumes, the column is sorted now...

  • DataTable with dynamic columns

    Does somebody have an example of how to code a h:dataTable with dynamic columns? I have seen hints about how to do it in these two articles:
    http://forum.java.sun.com/thread.jspa?forumID=427&threadID=5218508
    http://forum.java.sun.com/thread.jspa?threadID=577589&messageID=2909047
    but a complete working example would be really helpful.
    I think the key is understanding the "binding" parameter to h:dataTable but I'm having a hard time understanding it. Thanks.

    I found it here:
    http://balusc.blogspot.com/2006/06/using-datatables.html#PopulateDatatable

  • SQL Developer 1.5.1 - Sorting Table / List of Columns - Why So Slow

    Hi All,
    why is it so slow to sort the list of columns names in a table.
    It appears to be going back and querying the database again. - shouldn't it just be doing a local sort of the JTable ?
    Thanks
    Bill
    Edited by: wfs on Oct 28, 2008 2:31 PM

    Yes, it does query again - as it does with everything else being sorted.
    You're right they could implement local sorting on a little, complete set, but that should be requested at the announced SQL Developer Exchange, since I recon that would get pretty tedious (taking in count NLS sorting settings).
    Then mind you have to query again anyway if a result set is not complete (by default, fetches are 50 records at a time), or fetch everything before being able to apply the local sort, which will give you even more problems on large tables.
    Regards,
    K.

  • Trouble using MyFaces dataTable and t:columns tag in JSR168 portlet

    Hi, I have a question and need some help.
    I am building a JSF portlet, and trying to use Appache MyFaces custom tags.
    I need to use t:dataTable, and t:columns tags to display a dynamic ListDataModel, since the number and content of columns will vary.
    The problem is, the dataTable will only display the first row of the ListDataModel, although the data is all there. It seems that the page only reads the first row of the ListDataModel. Anybody has similar experience, or have some work around?
    Thank you in advance.

    Thats a way I had not thought of to approach this
    problem.
    I'd like to see what your backing bean looks like in
    this instance.
    How does the binding to #{item.data} map to anything?As usual BackingBean
    TableInfoBean.contentTable is UIData. I use binding just for combobox. You can drop this binding.
    TableInfoBean.content.currentPage is any container supported by dataTable. In my case this is Collection. This Collection contains item objects. Each item can has one property with array, List, Collection etc. In my case this property is data (row.data). Each item of this data collection is some object too. In my case this objects has property data too.
    The hierarchy is
    dataTableList:Collection->itemObjectYAxis:SomeType->data:Collection->itemObjectXAxis:SomeAnotherType->properties for output.
    >
    Thanks
    -Matthew

  • Hi how to apply Chronological sort for a month column?

    Hi All,
    I am struck with how to apply Chronological sort for a month column that contains values like January, February, March, April, May, June.... December. If we apply normal sorting then we can arrange the column values either in ascending order or descending order. But i want the column values to be in this format like jan, feb, mar,apr....dec. Is it possible???
    If this is possible then pls tell me the way in a step wise manner for my better understanding..
    Thanks in Advance
    Thenmozhi

    Hi Deva,
    I tried with the below formula :
    CASE WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='January' THEN 1 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='February' THEN 2 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='March' THEN 3 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='April' THEN 4 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='May' THEN 5 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='June' THEN 6 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='July' THEN 7 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='August' THEN 8 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='September' THEN 9 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='October' THEN 10 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='November' THEN 11 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='December' THEN 12 ELSE '' END
    But it is showing the error like this:
    Error Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 17001] Oracle Error code: 604, message: ORA-00604: error occurred at recursive SQL level 1 ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at line 8 ORA-00932: inconsistent datatypes: expected NUMBER got CHAR at OCI call OCIStmtExecute. [nQSError: 17010] SQL statement preparation failed. (HY000)
    What it is problem? Please help me...
    Thanks

  • XML Forms Builder: Sorting news based on a date field in a XML form

    Hi Experts
    I have a requirement and I am stuck up in finding a solution. I have a XML form and this has been mapped to a folder in KM. It publishes news. In the collection renderer settings there is an option to sort the news ascending or descending based on created/modified criteria.
    The requirement is to sort the news based on a date field in XML form. Can you experts help me in getting the solution for same?
    The users who post the news in our portal needs the information to be sorted based on a date field shown.
    Thank you
    Best regards
    Ramamoorthy D

    Hi Experts
    I have not got any solution for this issue. Can any of you get me some clue to work on this issue with sorting news based on a date field in a XML form?
    I removed the property link from the screen field Input field.
    Thank you
    Best Regards
    Ramamoorthy D

  • How to aggregate a column based date column (for weekly single row)?

    How to aggregate a column based date column (for weekly single row)?

    Hi,
    Consider the below statement for daily bases which is ok
    SELECT ID, DATE, SUM(AMOUNT) FROM TABLE_NAME GROUP BY ID, DATE ORDER BY ID, DATE
    The same like the above statement, I want output on weekly, fortnightly, and monthly bases, How to do this? Need your help...

  • Controlling the sort order for a column?

    I have a column which uses strings that I want to sort on. But, I don't want to do simple string sorting. Can I effect the sort order somehow? Maybe enumerate the values and assign integers to them?
    For example, I want to use Low, Medium, and High. Or maybe: L-, L, L+, M-, M, M+, H-, H, H+
    Any pointers on how to do this?

    Todd,
    Not knowing what you're trying to sort, it is difficult to make specific suggestions. Basically, two approaches come to mind. 1) start the lines of the column you want to sort with some type of sort code or 2) place that sort code in another column and sort on two columns - possible hiding the one with the codes.
    The next problem is designing a code that fits your situation. In the example you gave something like 1L-,2L,3L,...,8H,9H may work because there are only 9 categories. If more than 9, two digit numbers may work but remember to use leading zeros to pad single digit numbers.
    The code could also be alpha characters with relevance such as "Auto", "Clot", "Food", "Hous", "Misc", etc. But again, if these alphabetic categories are not in the order you like you may have to precede them with some sequence device to get what you want. Maybe something like "aFood", "bClot", "cHous", etc. would work. Designing a code applicable to a given situation that one can easily remember is not always easy.
    Hope this gives to something to think about and if you care to give more details you'll surely get some specific suggestions.
    pw

Maybe you are looking for

  • Detect underlaying colour

    Hello! I have a Label control sitting on top of an image control. The image and text are both user submitted. How can I detect what colour is under the text and thus make it white if the bg is black and black if the bg if white? Thank you!

  • Configuration for extensions filter while using Tomahawk 1.1.6

    Hello, I am using Sun RI 1.1 with tomahawk 1.1.6 and using facelets. I am stucked with following error: SEVERE: Error Rendering View[/pages/employees-calendar.xhtml] java.lang.IllegalStateException: ExtensionsFilter not correctly configured. JSF mapp

  • Diagnose My Ipod Problem (5G)

    Okay, so i purchased a 5g ipod about 2 weeks ago. THe first day i got i had some ******** problems. I plug in the usb i get a sad ipod face right away and the clicking WHIRR WHIRRR pattern. I cannot reset the ipod. so i spend a few hours researching

  • Anyone found an answer to the slow time m/c backups?

    This slow back up problem with Time Machine has affected my Mac Pro work station since I installed Mountain Lion a few weeks ago. This is not a wireless problem as my time m/c is connected via a usb lead. I decided to replace my 4 year old 1TB WD HD

  • Same results for 'Permissions repair complete'

    Very strange. I went to "First Aid' and clicked on "Repair Disc Permissions." After a half hour or so, the report showed stuff like "Repaired "System/Library/Core Services/ . . . and ended with "Permissions repair complete." I repeated the process an