Sorting table with custom function

Hello

I use JDev 11.1.1.4.0

I have a table with records.

Public Record (int id, String desc) {}
This.ID = id;
This.Description = desc;
}

I want to implement a sort function, the description column, based on the length of the string.

No idea how to do it?

Hi Pedro,

In this case, the class registration should be 'comparable' as you say.
You can replace the current collection with an ordered list/set and then to implement the comparator interface.
This is an example:

public java.util.TreeSet getRecords() {
  TreeSet records = new TreeSet(new RecordComparator());
  // routine to get the records
  return records;
}
...
class RecordComparator implements Comparator {
  @Override
  public int compare(Record o1, Record o2) {
    // be careful with null records/attributes!
    return o1.getDescription().length() > o2.getDescription().length() ? 1 : o1.getDescription().length() < o2.getDescription().length() ? -1 : 0;
  }
}

After that, try this:
http://technology.AMIS.nl/2012/03/01/ADF-11g-Programmatically-Configuring-sort-for-rich-table/

AP

Correction:
Just add a transitional attribute to the Record class and try this with this new attribute: http://technology.amis.nl/2012/03/01/adf-11g-programmatically-configuring-sort-for-rich-table/

AP

Published by: Alejandro Profet on November 12, 2012 15:32

Tags: Java

Similar Questions

  • How to maintain the synchronization of the hierarchy of the table with customer-specific data

    Series of paintings in our system, we have:

    Promotions (id, descr, datefrom, dateto,...)
    PromotionClients (promotionId, clientId) = list of clients whose promotion is valid
    PromotionProducts (promotionId, itemId) = list of products on sale

    The synchronization logic is simply that all promotion tables must be synchronized just to the customers present in the PromotionClients table. So each select element for these tables of publication contains something like "... and there are (select 1 from c PromotionClients where c.clientId =: CLIENTID). It works fine until there are some changes in the PromotionClients table. After the change of PromotionClients table starts to sync, but other tables do not - there is in fact no updates on their respective folders.

    Is there a solution to this problem other than to manually create the triggers for the PromotionClients table that would execute model-update on each related table? I mean - is there an existing function in OracleLite that woud let set a few references - to load to a point of publication/table?

    And in the face of similar problem - there is also Promotions.datefrom/dateto limitation. Promotion tables must be synchronized at the time where actual date is between Promotions.datefrom and dateto. When someone modifies some of these values and so the promotion valid for the time related tables does not automatically update and so they do not start to synchronize. Just the Promotions table begins to synchronize. So we might need to implement another trigger to perform updates dummy on the tables of PromotionClients + products, Promotions.datefrom/dateto update.

    I do not like the personalized relaxation approach - it just duplicates the synchronization logic and it is inconvenient to maintain the synchronization logic in two places (pubitem selects + custom triggers). I would like to find a solution of OL-native - as referring to load tables for each publication element that would cause triggers to OL to also catch the person in charge of the lines of tables (which were not actually modified) to be marked as dirty and synchronized to the client. Is there a solution like this? Or is there an alternative better than custom triggers?

    When you trigger an event in a related table, it gets registered for PGM compose the data in this table. If there is a suspicion, MGP will compose the data in these tables as well.

    So if you have something like a REGION_MAPPING table that maps the users in various locations and if you change the table data and want other tables that are joined with him to compose the data, and then add a hint of dependency to the tables mapping them to REGION_MAPPING. If these tables is regularly updated and data are being composed for the child tables, then you don't need the trick, just good practice to add it.

  • Personalized with custom functions callabe DataModel

    Hi all

    I am creating a data template customized with some features available in the QML code. This is the header file:

    #ifndef XMLDATAMODEL_HPP
    #define XMLDATAMODEL_HPP
    
    #include 
    #include 
    #include 
    #include 
    
    #include 
    #include 
    #include 
    #include 
    
    class XmlDataModel: public bb::cascades::DataModel{
    
    public:
        XmlDataModel();
        virtual ~XmlDataModel();
    
        // Required interface implementation
        virtual int childCount(const QVariantList& indexPath);
        virtual bool hasChildren(const QVariantList& indexPath);
        virtual QVariant data(const QVariantList& indexPath);
    
    public:
    
        Q_INVOKABLE
        void load(const QString& file_name);
    
        Q_INVOKABLE
        void setHeaderName(const QString& headerName);
    
    private:
        QVariant *m_sourceList;
        QString *m_headerName;
    
    };
    
    #endif
    

    And it's the QML app:

    onCreationCompleted: {
            console.log("main.qml loaded");
    
            _model.setHeaderName("hello");
        }
    

    But when the QML code try to run the setheaderName function, I get this error:

    TypeError: Result of expression '_model.setHeaderName' [undefined] is not a function.
    

    I have the _topSpeed is accessible by the QML code, but I don't know why I can't run my own functions...

    Can someone help me?

    Make a Q_OBJECT:

    class XmlDataModel: public bb::cascades::DataModel{  Q_OBJECT  ...
    
  • Sort Table data with text fields (form)

    I googled and searched forms of days for a response, but were unsuccessful.

    The only wire that I found being a year old, I wanted to start a new instead of bumping an old

    Ref: http://forums.adobe.com/message/3000436

    I'm looking for a script to sort the data in a form that is based on user input.

    The shape is just a table with multiple rows and columns of 3-5 (according to the dept) it's used)

    Using the thread referenced above, I was able to get a static table to sort, but I need to have all the fields to be text fields and the users enters the data.

    The example of the other thread static:

    http://forums.adobe.com/servlet/JiveServlet/downloadImage/2-3000436-35301/364-128/Untitled.png

    I'll use the same layout, just need to be a shape rather than static.

    If anyone can help or point me in the right direction, it would be great.

    Update #1:

    I find this page:http://cookbooks.adobe.com/post_Sorting_tables_in_dynamic_PDF-18993.html

    I'm the kind of work and it seems to be mostly what I look for, but how to deal with field empty?

    For example, the last three lines are empty (no data) the genre fails.

    Here is the code of the page, how can I change to fix the empty fields?

    ------------------------------------------------

    pass var = 0; column index

    var num = false; Is the numeric column

    var OrderAsc = true; Sort order

    function SortTable (tableRef, colIndex, isNumeric, CSA)

    {

    Try

    {

    Col = colIndex;

    NUM = isNumeric;

    OrderAsc = Asc;

    String variable that contains the data of the form as the XML string

    data var = tableRef.saveXML ('pretty');

    A XML variable contains the deserialized XML data

    xmlData var = xfa.datasets.createNode ("dataGroup", tableRef.name);

    xmlData.loadXML (data);

    Number of rows in the table

    var rowsCount = xmlData.nodes.length;

    Number of columns in the table

    passes of the var = xmlData.nodes.item (1).nodes.length;

    Two dimension table contains data of the complete table

    Master of var = new Array();

    Fill in the chart with XML data

    for (var i = 1; i < rowsCount; i ++)

    {

    Master [i-1] = new Array();

    for (var j = 0; j < passes; j ++)

    {

    Master [i-1] [j] = xmlData.nodes.item (i).nodes.item (j) .value;

    }

    }

    Sort the table 2D

    Master.sort (sortFunc);

    Re-fill the XML variable with data in table

    for (var i = 0; i < master.length; i ++)

    {

    for (var j = 0; j < master [i] .length; j ++)

    {

    xmlData.nodes.item(i+1).nodes.item (j) .value = master [i] [j];

    }

    }

    Change the data in the table and the back of the form

    var result = xmlData.saveXML ('pretty');

    tableRef.loadXML (result, 1, 1);

    XFA. Form.remerge ();

    } catch (e)

    {

    App.Alert (e)

    }

    }

    Customize the sort function to manage the 2D array and numeric columns

    function sortFunc (a, b)

    {

    var x = a [col];

    var y = b [col];

    Try

    {

    If (num)

    {

    x = parseInt (a [col]);

    y = parseInt (b [col]);

    }

    } catch (e) {}

    If (OrderAsc)

    {

    return x == y? 0: (x < y?-1: 1)

    }

    on the other

    {

    return x == y? 0: (x < y?-1: 1)

    }

    }

    Solution found!

  • Sorting table 2D with header?

    I'm not trying to apply anything in particular. I'm just wondering what would be the best aproach to solve this problem, if I asked.

    If I have a table 2D of strings with columns that contain text, others that contain numbers or timestamps, and the first line is the header, how I would go about how to sort on a particular column? The results did not come from a query of database so not "order by".

    I thought to use ActiveX calls to Excel. Another possibility is to use a temporary table of SQLite. How would you do that?

    SteveChandler wrote:

    I thought to use ActiveX calls to Excel. Another possibility is to use a temporary table of SQLite. How would you do that?

    In LabVIEW, of course!

    Here's what I'd do:

    (1) remove the header line, leaving a table 2D-data channels

    (2) extract the desired sort column.  In a loop for, browse the table 1 d resulting from chains.  Convert each string the appropriate representation and together with the number of iterations, so the output is an array of a cluster of two elements.

    (3) using 1-d matrix sort to sort the array of clusters.

    (4) browse the sorted table.  Unbundle the meter element, take this rank on the original 2D array and add it to a new table.

    (5) Insert the header row in the sorted table.

  • LOV cascading if I don't have only one table with the customer name and the name of the product in the ADF.

    Hi Please help me how to use cascade, if I don't have only one table with the customer name and the name of the product in the ADF... I use Jdeveloper 11.1.

    For the client, I used customer VO with client list to fill but to populate the product that I use bind variable PrODUCT_NAME select distinct from TABLE where client_name =: bindCustomer

    so first of all, I need to set the variable of liaison on behalf of the selected customer.

    Can you please tell me how to set this variable binding in this case.

    After you set the LOV to your product attribute, correspondting VO in the LOV will appear under view accessors.

    Change the accessor of the view, you will see the variable binding. Set its value to the customer field of the parent object.

    Visit this link: https://www.youtube.com/watch?v=nXwL2_RP7AQ

    Kind regards

    Elias.

  • Fill a table with two columns using a custom bean

    Hello

    Can you provide me or give me a link to an example of populating a table (with two columns) with a custom bean?

    Thank you

    TSPS

    Hello..
    I'm Jules Destrooper is what you want

    http://download.Oracle.com/docs/CD/E18941_01/tutorials/jdtut_11r2_36/jdtut_11r2_36.html

    Hopes, will help you

  • How to make a SUM function on table with TI-auto

    Hi all
    I created a table with column 2:
          CREATE TABLE Suppliers
          (
              Id                     NUMBER(10)              PRIMARY KEY,
              ProductNum       NUMBER(10)              NOT NULL,
              Amount             NUMBER(10)              NOT NULL
         );
    Example: I have these data in the table
    ----------------------------------
    Id|ProductNum|Amount|
    ----------------------------------
    1|      4A        |    50   |
    ----------------------------------
    2|      10Q      |     3    |
    ---------------------------------
    1|      4A        |    40   |
    ---------------------------------
    3|      Q9       |     32  |
    ---------------------------------
    2|      10Q      |     60 |
    .          .                .
    .          .                .
    .          .                .
    And I want a query to get the sum of the amount of each product, that is if I run this query o the previous table, I expect the following result
    ------------------------------
    ProductNum|Amount|
    ------------------------------
    4A            |     90    |
    10Q          |      63   |
    Q9            |      32   |
    .               |       .    |
    .               |        .   |
    Thanks in advance

    Something like this->

    select ProductNum, sum(Amount)
    from Suppliers
    group by ProductNum;
    

    Kind regards.

    LOULOU.

  • Why is there a limit to the number of Boolean parameters in a custom function?

    We have a custom function which "flattens" four time values of the text in a single time value.

    We want to do the same thing with the Boolean time values.

    However, OPM throws an error when it reads the metadata for the function in extensions.xml.  It shows all the Boolean parameters must be the last.  We can not put all changed because there is more than one.

    This is error code W00001-OPM OPM.

    Any ideas on how I can work around this limitation?

    Excerpt from the OPA developer assistance:

    Only a Boolean parameter can be passed to a function, and it must be the last parameter.  This is due to a limitation in the compiler of the rule.  Any number of other parameters may however be present.

    If you want to pass multiple Boolean values, create a temporary text variable / document values "True" / "False" using the table of rules.

  • Impossible to get a style work table with dat Spry in DW CS6

    Hi - I hope someone can help me to get a table style to work as a Spry data set. I first put in place a beautiful table with extendable drop down:

    http://designerandpublisher.com/tables/index.html

    I then followed this Adobe tutorial:

    http://www.Adobe.com/devnet/Dreamweaver/articles/spry_creating_html_data_set.html

    For the final result, you can see that all of the style has been removed:

    http://designerandpublisher.com/tables/Spry-test.html

    Although when you click the column header, sorting seems to work great, but I obviously cannot submit this to the customer because it does not resemble the style table.

    Can someone tell me what I am doing wrong?  I thought by styling the table first and then put in Spry, I thought it would work.  I also get this data style set working for the customer because I used Spry for other things like accordions and it is easy to use.

    Thank you.

    Just thinking a little further, with stretch panels Table seems to work pretty well. Why would you want to complicate things by introducing a dataset?

  • How to create dynamically sorting table?

    For example, I have a table with 2 columns: 'Name', 'value x; and 1 table with columns 'name' value 'y' (which is based on the value of x + a formula). What I want to achieve is to get table2 sorted whenever I change value in table1. The "Filter/Sort" tool only applies sort once and doesn't react to any changes made to the table 1.

    I don't know how the practice is (I find it easier at the station just manually), but here's a way to generate an array sorted automatically.

    Add a column "index" for the value of Y in the same table (this can be hidden if you want) with a formula like this:

    The formula in C2, filled to the bottom:

    = B2 + 5 + LINE () / 10000

    The idea is to calculate Y using some formula that you use and then add a very small number based on the number of line so that it becomes a unique value that can be used for searches, even when the same value 'original' appears more than once.

    Then in column B of the table "Sorted" list the values for Y in Crescent order like this:

    The formula in B2, filled to the bottom:

    = SMALL (Table 1: $C, ROW (−1))

    And, finally, to get the name corresponding to this value of Y as this:

    The formula in A2, filled to the bottom:

    = INDEX (table 1: $A, MATCH (B2, table 1: $C, 0))

    Now, whenever you change a value in the column X, "Sorted" table is automatically sorts.

    SG

  • BUG: 1 D table sort isn't sorting table of Classes and table Clusters contain Classes

    the function "sort the table 1 d.

    I wanted to sort the array of Clusters [number and class]. But to my surprise, LV is not like him.

    Okay, I need sort table Classes. But maybe once in the future I will. :-)

    'Research in table 1 d' is the use of classes I do not understand why 'sort the table 1 d' does not work.

    This problem is in LabVIEW 8.2 and 8.5 2009

    I think that the search feature of table 1 d can address each element in the table as an agregate whereas sort requires access to the private data in the data from the class and carrying it even further...

    Say all the elements are in the Parent class and a tow children who both have private data that are uniqie each and not present in the class of parents...

    How they manage breaking when there are different fields to sort on?

    Ben

  • Comparison of table with a threshold

    Hello

    I want to compare a table with a threshold value and then draw the table values that are above the threshold.

    Thanks in advance

    Best regards

    RASHID

    Hi rachid,.

    For normal comparison with thresholds, you must make use of one for indexing of each elements and comparison functions and structure of matter...

    For your idea, I just add code examples.

    Thank you and best regards,

    srikrishnaNF

  • Using subset of table with loops

    I have a 2D (m * n) table and I want to look at a subset of this table (x * y). I am having some problems using the subset of the table by doing this. If I want to browse 'y' columns of items containers 'x', I thought I could use a loop with the function of the subset of the array for interior but the resulting table I receive is actually a populated by the diagonal elements of my natal chart. I enclose my current VI where I hope that things.

    For example, if I load an image that is 800px * 600px then my program creates an array of 800 * 600 and each element is the maximum of the value of red, green and blue pixel. So, I want to watch the first 320px * 600px (which is a subset of the array with size 320 * 600). So, how can I use subset table properly to generate that 2d hack? My goal after this step would be to perfom some basic mathematical calculations like averaging on the subset.

    This is what you want?

  • Unexplained error with custom events

    LabVIEW 8.6.1f1, Win Vista

    I have an error an once-in-a-blue-moon in my program, I need to track down.

    I have it boiled down to a simple test case, where the error occurs more frequently (but still relatively rarely).

    I have a program called MERS, which is separated from my main code HDT.

    TCM can run on a separate machine, but for this test, it is on the same machine, running under the development of LV system.

    This test simply opens a TCP connection to the TCM, calls for a "signature", it receives and stop the connection.

    The part that opens the connection starts also the TCM RECEIVER running, and kill the connection stops this receiver.

    Here's the code for the main event, and you can see that I get an error apparently because I get no response in MS 2000:

    ---------

    The code to GET the SIGNATURE of TCM is here: what it does is to send a request for the signature and then waiting for an event SIGNATURE RECEIVED by the RECEIVER, or a timeout 2000 mSec.

    The error that I get (-100005) comes from there.  If the TCM has failed to respond, it would look like this.  Indeed, this is why the timeouot trap is here.

    -----------

    However, here is the code of the receiver and the Panel, immediately after a failure.

    It is clear from the TABLE that he received the SIGNATURE of TCM TCM.

    There are NO orders in the table indicates that the receiver was still running for 2000 mSec (4 x 500 mSec) after receipt of the order.

    When it receives a SIGNATURE, the code written will trigger an event.  No errors are reported here.

    So what's happening?  It seems that the event should be raised, but it is not received (Event #0 in photo #2 reacts to the event and returns the word signature, without error).

    This happens not all the time - this case is broken loop # 211 - this number is between 20 and 2000.

    With all those open windows in fact do more often: without them always fails, but she performs thousands of do loops.

    So perhaps it is related to the CPU bustle.

    I checked that there is no error with the function SAVE of EVENTS, even when it fails.

    I come back to the fact that the PICTURE in photo #3 says that the signature was received, but it seems that the EVENT did not get generated or received.

    What are the causes that?

    Is it possible that, since the receiver is dynamically loaded and run, that things are not really created and ready when he says they are?

    OK, that seems to have fixed. -He managed 5000 loops, with the windows open and no failure.

    How completely obvious it sounds, when I put it in words:

    Don't ask a question until you are ready to hear the answer.

    The revised registers for events and THEN asks for the signature.

    So, when the answer comes, even if it is immediately, you're ready.

    Don't ask a question until you are ready to hear the answer.

    Don't ask a question until you are ready to hear the answer.

    Don't ask a question until you are ready to hear the answer.

    Don't ask a question until you are ready to hear the answer.

    Don't ask a question until you are ready to hear the answer.


Maybe you are looking for