Listview column sort

I have code that allows a user to sort columns in a listview. I use it in many forms around my windows project. It works nicely on all pages and searching through the listview works nicely except for one page the searching is slowed down enormously when
the column sorting is enabled but sorting works fine. Below is the code for that page.
I allow the users to search in the search box on top (not showing but it was a textbox the user can type in and it searches in the listview) and then it reloads the listview on bottom based on the search criteria.
Also the user can click on the column header in the listview and it will sort the columns….
SEARCH
private void ProductSearch_TextChanged(object sender,
EventArgs e)
            ProductsSearch(btnAdvancedSearch.Text);
private void ProductsSearch(string filterOption)
StringBuilder sb = new
StringBuilder();
string ID = txtItemID.Text.EscapeLikeValue();
string Name1 = txtItemName1.Text.EscapeLikeValue();
string Name2 = txtItemName2.Text.EscapeLikeValue();
string Name3 = txtItemName3.Text.EscapeLikeValue();
if (ID.Length > 0)
                sb.Append("ITEMSTRING like '" + ID +
if (Name1.Length > 0)
if (sb.Length > 0)
                    sb.Append(" and ");
switch (filterOption)
case "Basic Search":
                        sb.Append("' ' + Description
like '%" + Name1 + "%'");
break;
case "Advanced Search":
                        sb.Append("Description like
'" + Name1 + "%'");
break;
if (Name2.Length > 0)
if (sb.Length > 0)
                    sb.Append(" and ");
switch (filterOption)
case "Basic Search":
                        sb.Append("' ' + Description
like '% " + Name2 + "%'");
                        break;
case "Advanced Search":
                        sb.Append("Description like
'% " + Name2 + "%'");
break;
if (Name3.Length > 0)
if (sb.Length > 0)
                    sb.Append(" and ");
switch (filterOption)
case "Basic Search":
                        sb.Append("' ' + Description
like '% " + Name3 + "%'");
break;
case "Advanced Search":
                        sb.Append("Description like
'% " + Name3 + "%'");
break;
            lsvItems.Items.Clear();
            dtProducts.DefaultView.RowFilter = sb.ToString();
foreach (DataRow row
in dtProducts.Select(sb.ToString()))
ListViewItem lvi = new
ListViewItem(row["Item"].ToString());
                lvi.SubItems.Add(row["Description"].ToString());
                lvi.SubItems.Add(row["Cost"].ToString());
                lvi.SubItems.Add(row["Price"].ToString());
                lsvItems.Items.Add(lvi);
if (dtProducts.DefaultView.Count <= 0)
Validation.ShowMessage(Main.lblStatus,
"No items match your search.");
SORTING
public Form1()
            InitializeComponent();
            lsvColumnSorter =
new ListViewColumnSorter(0);
this.lsvItems.ListViewItemSorter = lsvColumnSorter;
private ListViewColumnSorter lsvColumnSorter;
private void lsvItems_ColumnClick(object sender,
ColumnClickEventArgs e)
           ((ListView)sender).ColumnSort(e, lsvColumnSorter);
public static
void ColumnSort(this
ListView lsv, ColumnClickEventArgs e,
ListViewColumnSorter lsvColumnSorter)
// Determine if clicked column is already the column that is being sorted.
if (e.Column == lsvColumnSorter.SortColumn)
// Reverse the current sort direction for this column.
if (lsvColumnSorter.Order == System.Windows.Forms.SortOrder.Ascending)
                    lsvColumnSorter.Order = System.Windows.Forms.SortOrder.Descending;
else
                    lsvColumnSorter.Order = System.Windows.Forms.SortOrder.Ascending;
else
// Set the column number that is to be sorted; default to ascending.
                lsvColumnSorter.SortColumn = e.Column;
                lsvColumnSorter.Order = System.Windows.Forms.SortOrder.Ascending;
// Perform the sort with these new sort options.
            lsv.Sort();
In this specific page the column sorting code is effecting the searching code.
What could the problem be?
Debra has a question

Hi Debra,
I suggest you could use the listview to search.
you could refer to this post:
http://stackoverflow.com/questions/16549823/filtering-items-in-a-listview
Use the listView item, not to reload the listViewitem.
And then i see you using the ListViewColumnSorter class, what is this class? Is it customized?
If you could share the more details, I could help you better.
Best regards,
Youjun Tang
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

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

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

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

  • Interactive Report wide Column Sorting hangs in Internet Explorer

    I have an application that contains an interactive report. The Column Sorting and Filtering functions work fine in Firefox. However, if I try to sort a wide (110 byte - it contains a hyperlink) column in Internet Explorer, APEX produces the 'loading data' image and then hangs. Even a sort of a narrow (3 byte) column is noticeably slower in Internet Explorer than in Firefox.
    We are running APEX 3.1.1 on Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production with the Partitioning, OLAP, Data Mining and Real Application Testing options

    Hello,
    I answer you over your post.
    Joe Bertram wrote:
    Hi,
    That's an interesting issue. What kind of images are these? Are they the default images installed or are they your custom set of images?The images are png files included as they were icons into the table.
    >
    You say the images disappear when you sort the report. Does it happen when you sort on demand in the dashboard or when you sort it in the report itself? Or both?Only when sort from the dashboard. From the report itself, the answers works fine.
    >
    What are your environment details?Server:
    OBI 10.1.3.4.1.090414.1900
    Windows 2003 server
    JDK 1.6.0.17
    Thin Client:
    Internet explorer 8
    >
    Thanks for the extra info.
    Best regards,
    -JoeIt happens also in other two environments (Development and Pre-production) with the same SW architecture.
    Thanks for your time.

  • Issue Action links,Column sorting in OBIEE(11g) 11.1.1.7.0

    Hello everyone,
    I want to provide the feature column sorting to my users but i dont want to provide any feature to users when they click on right mouse button.When we click on right mouse in action link column value it is giving the "action links","include/exclude columns" options etc.
    I disabled the do not display the action link report name in the column properties.
    Also disable the  include/exclude columns options in the interaction XYZ properties of the view.
    But still i am not able to understand why these links are coming when i run the report from the dashboard.
    Please help me out here.
    thanks,
    prassu

    Hi Timo,
    I am using data control web services to get these attributes on to the jspx page. The table has the value property which is binding to the iterator( #{bindings.SUMMARY_LINES_ITEM.collectionModel}).
    The table has various coulmns like order no, status, request and so on..where Order no and status are converted to a cmd link which navigates to another page on a query.
    I don't understand how setting sorting to true in one of the columns can make it not found in the iterator! And I get the errors only if sorting is done first before querying(clicking on one of the values in a column to navigate to another page).
    Thanks,
    Sue

  • In list view: Why don't searches include results from the Collections field? Why won't the Collections column sort properly?

    In list view: Why don't searches include results from the Collections field? Why won't the Collections column sort properly?

    I create a new index on column2, (INDEX_N3)
    and change SQL to
    select 1 from table T1 where
    T1.COLUMN_002 = '848K 36892'
    This time INDEX_N3 will be used.
    but change SQL to
    select 1 from table T1 where
    T1.COLUMN_002 = '848K 36892'
    and T1.COLUMN_004 = '1000'
    The explain plan will show full scan.
    Why?
    Thanks.

  • Itunes / ipod column sort locked?

    When looking at my ipod via itunes the column sort is locked on sort by "Genre" and i can't change it? When looking at my computer files it works fine it's just on the ipod? I know it worked last week? not sure if i did something or ???
    thanks

    I'm having the same problem with my iphone.  When I click the "manually manage music, it prompts me that the iphone is synced with another library.  Do i want to erase this iphone and sync with this itunes library?
    Of course I dont want to do this!  My iphone is "synced" with my computer at home, while at work, I'd like to listen to music to my iphone through my work mac (which has no mp3s on it) using itunes.  Annoying!
    Anyone find a third party solution to this?

  • DataGrid Column Sort Prevents Drag From Updating DataProvider

    Hi
    I have a datagrid with an XMLListCollection as the Data Provider.
    I have dragging set on so that when I drag a row to somewhere else in the list the XMLListCollection gets updated just fine and so does the DataGrid.
    However, if a column sort has previously been set this seems to stop the XMLListCollection being updated on the drag.
    I have tried setting the sort property on the XMLListColelction to null and then doing a refresh - this works to a point but it restores the default sort order which is not really what I want as the user may wish to continue from where the column sort got them to.
    I was wondering if anyone had any suggestions please ?
    Thanks a lot.
    Chris

    Hi
    Thanks for replying
    This is what the debugger says:
    TypeError: Error #1010: A term is undefined and has no properties.
        at mx.controls.listClasses::ListBase/makeRowsAndColumnsWithExtraRows()[C:\autobuild\3.2.0\fr ameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:1358]
        at mx.controls.listClasses::ListBase/updateDisplayList()[C:\autobuild\3.2.0\frameworks\proje cts\framework\src\mx\controls\listClasses\ListBase.as:3658]
        at mx.controls.dataGridClasses::DataGridBase/updateDisplayList()[C:\autobuild\3.2.0\framewor ks\projects\framework\src\mx\controls\dataGridClasses\DataGridBase.as:581]
        at mx.controls::DataGrid/updateDisplayList()[C:\autobuild\3.2.0\frameworks\projects\framewor k\src\mx\controls\DataGrid.as:1437]
        at mx.controls.listClasses::ListBase/validateDisplayList()[C:\autobuild\3.2.0\frameworks\pro jects\framework\src\mx\controls\listClasses\ListBase.as:3280]
        at mx.managers::LayoutManager/validateDisplayList()[C:\autobuild\3.2.0\frameworks\projects\f ramework\src\mx\managers\LayoutManager.as:622]
        at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.2.0\frameworks\projects \framework\src\mx\managers\LayoutManager.as:695]
        at Function/http://adobe.com/AS3/2006/builtin::apply()
        at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.2.0\frameworks\projects\framew ork\src\mx\core\UIComponent.as:8628]
        at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.2.0\frameworks\projects\framewo rk\src\mx\core\UIComponent.as:8568]
    For instance, after the page with the flash module loads, and I click on a column, I get the error. This is quite random, sometimes I need a couple of tries to get the error...
    If you require more information about it I will try to provide.
    Thank you
    Vlad

  • Problem with Column Sorting in Request Table View

    We've enabled column sorting on the table view in an Answers request but it doesn't work when more than around 400 rows are returned. It works Ok when fewer than 400 rows are returned. Does anyone know if there is a specific limit to the number of rows where column sorting works?
    Thanks,
    Mike

    I've dug into the query log a little more. When this request returns more than around 400 records and you click on a column heading to sort the table view, the query from the log is not changing to reflect the new sort order. It stays as whatever the default sort order was for the request.
    Column heading sorting on other requests in different subject areas on this same server works fine. I've tested this other request with up to 6400 rows returning and it's sorting works.
    All caching is turned off for the subject area.

  • C#: when adding listview items the screen flashes and only single listview column loads?

    When adding listview items, the listview1 items flash and only the first listview column loads (there are 5 columns in all)?
    Background...
    I was having cross-threading issues on 3 form components which I was able to resolve (see
    code here). Now I think the soluiton which involves creating a delegate and performing an "InvokeRequired" check (see
    what I used), I'm having an issue passing 5 values for each column. Below is the code involved calling this invoking check for each and their methods.
    Before having the cross-thread issue the "listview1.Items.Add(values.text) add the comma separated string values to the appropriate columns, but that doesn't happen through the cross-thread fix required.
    The "Loading()" method is handled through and async/await method causing the initial cross-thread issue.
    private void Loading()
    int t = 1;
    foreach (string line in scripts)
    string[] listValues = line.Split(',');
    ListViewItem values = new ListViewItem(listValues);
    if (t == 1)
    AddColumn("Script Name", 200); // Creates column headings
    AddColumn("Date and Time", 150);
    AddColumn("SID", 75);
    AddColumn("Environment", 75);
    AddColumn("Client", 75);
    t++;
    else
    if ((values.Text != "") && (values.Text != "Script Name"))
    //listView1.Items.Add(values);
    AddItem(values.Text);
    if (!dictScript.Contains(values.Text))
    dictScript.Add(values.Text);
    //cbxScriptList.Items.Add(values.Text);
    AddScript(values.Text);
    private void AddItem(object o)
    if (this.listView1.InvokeRequired)
    AddItemCallback d = new AddItemCallback(AddItem);
    this.Invoke(d, new object[] { o });
    else
    { // code that adds item to listView (in this case $o)
    listView1.Items.Add(o.ToString());
    private void AddScript(object o)
    if (this.listView1.InvokeRequired)
    AddCBXCallback d = new AddCBXCallback(AddScript);
    this.Invoke(d, new object[] { o });
    else
    { // code that adds item to listView (in this case $o)
    cbxScriptList.Items.Add(o.ToString());
    private void AddColumn(object o1, object o2)
    if (this.listView1.InvokeRequired)
    AddColCallback d = new AddColCallback(AddColumn);
    this.Invoke(d, new object[] { o1, o2 });
    else
    { // code that adds item to listView (in this case $o)
    listView1.Columns.Add(o1.ToString(), (int)o2); // Creates column headings
    SV

    Ok, I still have the flickering issue, I could use some guidance on that. And I should note that before I had the code-threading issue, I never had any flickering, it all appeared simultaneously.
    However, I was able to populate all columns (5 in all).  I had two corrections to make.
    1) My method should not have been passing the parameter as text but as the object ListViewItem:
    // Not This...
    AddItem(values.text)
    // This is Correct...
    AddItem(values)
    2) Then I needed to cast my object as a ListViewItem in my method call:
    private void AddItem(object o)
    if (this.listView.InvokeRequired)
    AddItemCallback d = new AddItemCallback(AddItem);
    this.Invoke(d, new object[] { (ListViewItem)o });
    else { // code that adds item to listView (in this case $o)
    listView1.Items.Add((ListViewItem)o);
    SV

  • Classic report column sorting

    Hello to APEX forum
    My Apex version is 4.2.1,
    database version is Oracle 10g XE on Windows 7 Pro
    After upgrading from version 3.2 to 4.2.1 report column sorting doesn't work when "Enable Partial Page Refresh" is set to "Yes".
    When "Enable Partial Page Refresh" is "No" sorting is OK.
    Please, help
    Regards
    Mark

    Hi Mark,
    it looks like your json.js causes troubles. It extends every JavaScript "object" with two methods called toJSONString and parseJSON. I did a quick debugging and it looks like when we construct our AJAX request to do the sorting, the jQuery AJAX handling tries to serialize those two function because it thinks it's regular data and fails with a JavaScript error.
    Looking at the original source of your library at https://github.com/douglascrockford/JSON-js even the creators had some doubts using that version of the library
    json.js: This file does everything that json2.js does. It also adds a toJSONString method and a parseJSON method to Object.prototype. Use of this file is not recommended.
    Are you sure that you need the parseJSON and toJSONString methods? Maybe you are fine with json2.js as well.
    Regards
    Patrick
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • Reports serialising when column sort attributes used

    If an Apex user has two sessions and runs the same report page in both, then if the report uses column sort attributes (rather than an ORDER BY in the SQL), the second is blocked by the first; once the first completes the second then runs and completes. This appears to be because the user preferences for column sorting are being updated each time, even if they have not been changed.
    This application demonstrates the problem:
    http://htmldb.oracle.com/pls/otn/f?p=15827:2
    Create 2 sessions using that URL. The page has a report based on ALL_OBJECTS with an item "Owner" to filter on. Enter "%" in the first session and press Enter and the report will run, taking about 1 minute. Meanwhile in the second session enter a specific owner (or just XXX) and press Enter. The second report will finish just after the first finishes, even though when run alone it only takes half a second or so.
    Is this a bug?

    Hi Tony,
    If you're using this on unauthenticated pages, then the sort preferences are stored per user for the APEX_PUBLIC_USER (or HTMLDB_PUBLIC_USER), which is potentially why you're seeing the serialisation/dead-locking.
    Could you perhaps use the suggestion by Scott in this thread -
    Re: Report sorting affected by other users
    To use the session ID as the APEX user (or anything else you prefer), to mitigate the potential for the deadlock? (It's worth trying and should take just a few seconds to test in your sample app?).
    John.

  • Embedded images disappear on column sorts when viewing SSRS via url in an iframe

    RE:   SQL Server - 2008 R2  Reporting Services
    We deliver an ASP.Net MVC (5) application and some of the views show/display SSRS report via url in an iframe (so the report is displayed vi the web viewer).   There are images in the header of some of these reports which display correctly on the initial
    view, but "disappear" when the user uses a report column sort and/or changes the report zoom (via the SSRS web viewer toolbar). There are other quirky behaviors as well (depending on the browser), but we are dealing with IE versions 8 thru 11.  I've
    already set the ReportViewer.aspx to use <meta http-equiv="X-UA-Compatible" content="IE=7">, and our application pages/views use <meta http-equiv="X-UA-Compatible" content="IE=edge">.
    Does anyone have a "fix" for this? I know it's related to the ReportViewer.aspx and displaying the report(s) in an iframe, but I can't seem to find any information on how to fix the issue.

    Hi,
    According to your description, when you preview report through url in an iframe, the embed images can be displayed, images can’t be displayed after users used sort and changed report zoom.
    To troubleshoot the problem, please refer to the following steps:
    Run the report in Business Intelligence Development Studio (BIDS) to make sure that the images can be displayed correctly.
    The issue may be relevant to compatibility of browser, please use different browser to check whether the issue persists.
    If you are using embedded image of jpg type, please change the extension of the image to png.
    Set the ReportViewer.aspx to use <meta http-equiv="X-UA-Compatible" content="IE=8">.
    Here is a relevant thread you can reference:
    https://social.technet.microsoft.com/Forums/en-US/56650bf4-e65d-4f84-8ac0-a57cb26543b2/image-disappears-when-sorting-in-ssrs-for-server-report-on-report-vieweron-aspx-page?forum=sqlreportingservices
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    If you have any feedback on our support, please click
    here.
    Wendy Fu
    TechNet Community Support

  • Customizing column sorting in new jsf table

    The new JSF table in the creator 2 is great. I like it. It includes so many out of the box features. It is the reason we use the creator for our current project.
    But I cannot figure out how to customize the column sorting.
    Why do I need column sorting?
    I need to sort a column that can include ad IP address or a host name. Our customer can either use a host name or an IP address to address a device in the network, both in the same column.
    Now sorting an IP address is already difficult. It is actually a sort over a 4 byte number. Sorting over host names is normal alphabetic string sorting.
    How to sort over both in the same column?
    This cannot be done using standard sorting. I need to use a validator or something similar to customize the sorting of this column.
    Can anybody help me with a hint if:
    1- Customizing sorting over a column is possible. (I really would like to keep all other sorting features (icons, multi column support...)).
    2- A hint or code sample, how to do this.
    If this is not possible, I urge the creator team to think of implementing this soon. Otherwise one killer feature of the creator 2 will lose a lot of its teeth.

    Thx mayagiri for your reply!
    But including the src-code for the dataprovider package into a test project, and debugging in the creator-ide has done the thing!
    Here our solution:
    Class ToCompare is the object type which address field displayed in a page, simply containing a table with 2 adress colums, that can be sorted either according to our ip/hostname-comparison or according to String.compare().
    * ToCompare.java
    * Created on 10. Februar 2006, 10:41
    * This class is a basic model object,
    * with a field - String address - according
    * to which it shall be sortable.
    package comparator;
    * @author mock
    public class ToCompare {
         * holds the IP or Host address
        private String address=null;
         * Instance of a Comparator class that
         * provides our sorting algorithm
        private RcHostComparator hostComparator=null;
        /** Creates a new instance of ToCompare */   
        public ToCompare() {
            this("defaultHost");       
         * when creating a new ToCompare instance,
         * the hostComparator is created for it
         *  @ param aAddress - IP or Hostname
        public ToCompare(String aAddress) {
            address=aAddress;
            hostComparator=new RcHostComparator(address);
        public String getAddress() {
            return address;
        public RcHostComparator getHostComparator() {
            return hostComparator;
    }Here the code of the Class RcHostComparator, it is created with the address field of the ToCompare object that it holds. It first checks if the address field is an IP or not, and then chooses the comparison algorithm according to its own field state and the field state of the object to compare to:
    * RcHostComparator.java
    * Created on 10. Februar 2006, 10:43
    *  This class is used to provide a method for
    *  comparing objects that have an address field,
    *  containing either IP adresses or hostnames.
    package comparator;
    import java.text.CollationKey;
    import java.text.Collator;
    import java.util.Comparator;
    import java.util.Locale;
    * @author mock
    public class RcHostComparator implements Comparator
         * holds the IP or Host address
        private String address=null;
         * Is the address an IP
        private boolean isIPAddress=false;
         * if (!isIPAddress) this is created out of the address
         * to provide a performant way of comparing it with another
         * CollationKey, in order to sort Strings localized
         *  @ see java.text.Collator
         *  @ see java.text.CollationKey
        private CollationKey hostnameCollationKey=null;
         * if (isIPAddress) this array holds
         * the 4 byte of the Ip address to compare
        private int[] intValues=null;
         * minimum for IP bytes/ints
        private static final int minIntValue=0;
         * maximum for IP bytes/ints
        private static final int maxIntValue=255;
         * Creates a new instance of IpComparator
         *  @ param aAddress  - holds the IP or Host address
        public RcHostComparator(String aAddress) {
            address=aAddress;
             * check if address is an IP
            isIPAddress=checkIP();
             * if Hostname -> instantiate localized CollationKeys
            if(!isIPAddress){
                 Collator _localeCollator=Collator.getInstance(Locale.getDefault());
                 hostnameCollationKey=_localeCollator.getCollationKey(address);
            }else{}
         *  Here the comparison of the address fields is done.
         *  There a 4 cases:
         *  -1 both Hostnames
         *  -2 aObject1 IP, aObject2 Hostname
         *  -3 aObject1 Hostname, aObject2 IP
         *  -4 both IPs
         *  @ param aObject1, aObject2 - Comparator objects
        public int compare(Object aObject1, Object aObject2)
          int _result= 0;
          if(aObject1 instanceof RcHostComparator && aObject2 instanceof RcHostComparator )
               RcHostComparator _ipComparator1=(RcHostComparator)aObject1;
               RcHostComparator _ipComparator2=(RcHostComparator)aObject2;
               *  Compare algorithms, according to address types
               if(!_ipComparator1.isIPAddress()&&!_ipComparator2.isIPAddress()){
                       *  If both addresses are Strings use collationKey.compareTo(Object o)
                    _result=_ipComparator1.getHostnameCollationKey().compareTo(_ipComparator2.getHostnameCollationKey());
               }else{
                       *  IPs are smaller than Strings -> aObject1 < aObject2
                    if(_ipComparator1.isIPAddress()&&!_ipComparator2.isIPAddress()){
                         _result=-1;
                    }else{
                                *  IPs are smaller than Strings -> aObject1 > aObject2
                         if(!_ipComparator1.isIPAddress()){
                              _result=1;
                         }else{
                             int _intIndex=0;
                             int[] _int1=_ipComparator1.getIntValues();
                             int[] _int2=_ipComparator2.getIntValues();
                                      * compare IP adresses per bytes
                             while(_result==0 && _intIndex<4){
                                  if(_int1[_intIndex]>_int2[_intIndex]){
                                       _result=1;
                                  }else if(_int1[_intIndex]<_int2[_intIndex]){
                                       _result=-1;
                                  }else{}                            
                                             _intIndex++;
          }else{}   
          return _result;
         *  checks if the address field holds an IP or a hostname
         *  if (_isIP) fill intValues[] with IP bytes
         *  if (!isIP)  create hostnameCollationKey
        private boolean checkIP(){
           boolean _isIP=false;
           String[] _getInts=null;
            *  basic check for IP address pattern
            *  4 digits also allowed, cause leading
            *  0 stands for octet number ->
            *  0172=122                  ->
            *  0172.0172.0172.0172 = 122.122.122.122
           boolean _firstcheck=address.matches("[0-9]{1,4}\\.[0-9]{1,4}\\.[0-9]{1,4}\\.[0-9]{1,4}");
           if(_firstcheck){
                _getInts=address.split("\\.");           
                intValues=new int[4];
                for (int _count=0; _count<4; _count++){
                   try{                     
                       int _toIntValue;
                       if(_getInts[_count].startsWith("0")){
                                // if leading 0 parse as octet -> radix=8
                               _toIntValue=Integer.parseInt(_getInts[_count], 8);                          
                       }else{  
                                // parse as is -> radix=10 -> (optional)
                               _toIntValue=Integer.parseInt(_getInts[_count]);                          
                       if(_toIntValue<minIntValue||_toIntValue>maxIntValue){
                              // out of unsigned byte range -> no IP
                              return _isIP;
                       }else{
                              // inside byte range -> could be part of an IP
                              intValues[_count]=_toIntValue;
                   }catch(NumberFormatException e){
                           // not parseable -> no IP
                           return _isIP;
               // all 4 bytes/ints are parseable and in unsigned byte range -> this is an IP
                _isIP=true;
           }else{}      
           return _isIP;
        public boolean isIPAddress() {
                return isIPAddress;
        public int[] getIntValues() {
                return intValues;
        public CollationKey getHostnameCollationKey() {
                return hostnameCollationKey;
        public String getAddress()
            return address;
    }The page bean holds an array of ToCompare objects. It is the model for a new table component, hold by an ObjectArrayDataProvider. Here a code excerpt:
    public class Page1 extends AbstractPageBean
        private ToCompare[] toCompare= new ToCompare[]{
            new ToCompare("1.1.1.1"),
            new ToCompare("2.1.1.1"),
            new ToCompare("9.1.1.1"),
            new ToCompare("11.1.1.1"),
            new ToCompare("0172.0172.0172.0172"),
            new ToCompare("123.1.1.1"),
            new ToCompare("a"),
            new ToCompare("o"),
            new ToCompare("u"),
            new ToCompare("z"),
            new ToCompare("�"),      
            new ToCompare("�"),
            new ToCompare("�")        
         * This method is automatically generated, so any user-specified code inserted
         * here is subject to being replaced
        private void _init() throws Exception
            objectArrayDataProvider1.setArray(toCompare);
        private TableRowGroup tableRowGroup1 = new TableRowGroup();   
        private ObjectArrayDataProvider objectArrayDataProvider1 = new ObjectArrayDataProvider();
    }The relevant .jsp section for the two column table looks like:
    <ui:tableRowGroup binding="#{Page1.tableRowGroup1}" id="tableRowGroup1" rows="10" sourceData="#{Page1.objectArrayDataProvider1}" sourceVar="currentRow">
      <ui:tableColumn binding="#{Page1.tableColumn1}" headerText="SortIP" id="tableColumn1" sort="#{currentRow.value['hostComparator']}">
        <ui:staticText binding="#{Page1.staticText1}" id="staticText1" text="#{currentRow.value['address']}"/>
      </ui:tableColumn>
      <ui:tableColumn binding="#{Page1.tableColumn2}" headerText="SortString" id="tableColumn2" sort="address">
        <ui:staticText binding="#{Page1.staticText2}" id="staticText2" text="#{currentRow.value['address']}"/>
      </ui:tableColumn>
    </ui:tableRowGroup>Sorting localized with Locale="DE_de" according to ip/hostcompare sorts:
    SortIP
    1.1.1.1
    2.1.1.1
    9.1.1.1
    11.1.1.1
    0172.0172.0172.0172
    123.1.1.1
    a

    o

    u

    zWhereas normal sort over String address whitout localization sorts:
    SortString
    0172.0172.0172.0172
    1.1.1.1
    11.1.1.1
    123.1.1.1
    2.1.1.1
    9.1.1.1
    a
    o
    u
    z


    �Not that short, but I hope it will help - if anyone has the need for another than the default sorting algorithms
    Best regards,
    Hate E. Lee

  • Drag-drop data column sorting

    Hey guys,
    Does any one know how to achieve drag-drop data column
    sorting? I tried, but could not find an efficient way to do this.
    It would be an awesome spry feature if possible, but if someone
    else knows how to do this already it would help.
    Thanks,
    Timothy D Farrar

    Hey guys,
    We aim to be as compatible as possible with the other
    frameworks but sometimes problem may exists. We need to see the
    crashing pages to be able to determine the causes for the JS error
    message and where the incompatibilities are located and either fix
    the problems or help you to change your pages to work.
    In this situation I suspect the issue appears because the
    spry region is generated after the drag and drop code from the
    script.aculo.us is instantiated and we destroy the initial elements
    to which this widget is binded. In this situation the solution is
    to instantiate the drag and drop after the region generate its
    content by using the region observers. You'll have to put the drag
    and into a separated function and register the code so the region
    will call it automatically onPostUpdate.
    We include in our documentation more details about the
    Region
    observer notifications. Please search the dedicated chapter
    inside this doc: "Region observer notifications"
    Regards,
    Cristian MARIN

  • Datatable multible column sort labels

    How can i change labels of multible column sort panel to another language (Turkish). For example i want to convert "Primary Sort Column:" to "Birincil S&#305;ralama S&uuml;tunu" .
    Thanks for your helps.
    Edited by: m4erler on 15.Tem.2008 13:39

    Generally speaking, keep your localizable strings in a properties file attached to a resource bundle. Then access the strings via the resource bundle. JSF has support for this.
    In you need more details, google for internationalization and localization in Java and JSF. Check the javadoc for the ResourceBundle class, examine the documentation of the <f:loadBundle> tag, the documentation for the <resource-bundle> and <message-bundle> directives in the faces-config.xml, and see section 2.5.2 in the JSF spec.

Maybe you are looking for