Newbie trying to sort 2D string array

Dear all,
After read some book chapters, web sites including this, I still don't get the point.
If I have a file like,
1 aaa 213 0.9
3 cbb 514 0.1
2 abc 219 1.3
9 bbc 417 10.4
8 dee 887 2.1
9 bba 111 7.1
and I load into memory as a String[][]
here comes the problem, I sort by column 1 (aaa,...,bba) using an adaptation of the Quicksort algorithm for 2D arrays
* Sort for a 2D String array
* @param a an String 2D array
* @param column column to be sort
public static void sort(String[][] a, int column) throws Exception {
QuickSort(a, 0, a.length - 1, column);
/** Sort elements using QuickSort algorithm
static void QuickSort(String[][] a, int lo0, int hi0, int column) throws Exception {
int lo = lo0;
int hi = hi0;
int mid;
String mitad;
if ( hi0 > lo0) {
/* Arbitrarily establishing partition element as the midpoint of
* the array.
mid = ( lo0 + hi0 ) / 2 ;
mitad = a[mid][column];
// loop through the array until indices cross
while( lo <= hi ) {
/* find the first element that is greater than or equal to
* the partition element starting from the left Index.
while( ( lo < hi0 ) && ( a[lo][column].compareTo(mitad)<0))
++lo;
/* find an element that is smaller than or equal to
* the partition element starting from the right Index.
while( ( hi > lo0 ) && ( a[hi][column].compareTo(mitad)>0))
--hi;
// if the indexes have not crossed, swap
if( lo <= hi )
swap(a, lo, hi);
++lo;
--hi;
/* If the right index has not reached the left side of array
* must now sort the left partition.
if( lo0 < hi )
QuickSort( a, lo0, hi, column );
/* If the left index has not reached the right side of array
* must now sort the right partition.
if( lo < hi0 )
QuickSort( a, lo, hi0, column );
* swap 2D String column
private static void swap(String[][] array, int k1, int k2){
String[] temp = array[k1];
array[k1] = array[k2];
array[k2] = temp;
----- end of the code --------
if I call this from the main module like this
import MyUtil.*;
public class kaka
public static void main(String[] args) throws Exception
String[][]a = MyUtil.fileToArray("array.txt");
MyMatrix.printf(a);
System.out.println("");
MyMatrix.sort(a,1);
MyMatrix.printf(a);
System.out.println("");
MyMatrix.sort(a,3);
MyMatrix.printf(a);
for the first sorting I get
1 aaa 213 0.9
2 abc 219 1.3
9 bba 111 7.1
9 bbc 417 10.4
3 cbb 514 0.1
8 dee 887 2.1
(lexicographic)
but for the second one (column 3) I get
3 cbb 514 0.1
1 aaa 213 0.9
2 abc 219 1.3
9 bbc 417 10.4
8 dee 887 2.1
9 bba 111 7.1
this is not the order I want to apply to this sorting, I would like to create my own one. but or I can't or I don't know how to use a comparator on this case.
I don't know if I am rediscovering the wheel with my (Sort String[][], but I think that has be an easy way to sort arrays of arrays better than this one.
I've been trying to understand the Question of the week 106 (http://developer.java.sun.com/developer/qow/archive/106/) that sounds similar, and perfect for my case. But I don't know how to pass my arrays values to the class Fred().
Any help will be deeply appreciated
Thanks for your help and your attention
Pedro

public class StringArrayComparator implements Comparator {
  int sortColumn = 0;
  public int setSortColumn(c) { sortColumn = c; }
  public int compareTo(Object o1, Object o2) {
    if (o1 == null && o2 == null)
      return 0;
    if (o1 == null)
      return -1;
    if (o2 == null)
      return 1;
    String[] s1 = (String[])o1;
    String[] s2 = (String[])o2;
    // I assume the elements at position sortColumn is
    // not null nor out of bounds.
    return s1[sortColumn].compareTo(s2[sortColumn]);
// Then you can use this to sort the 2D array:
Comparator comparator = new StringArrayComparator();
comparator.setSortColumn(0); // sort by first column
String[][] array = ...
Arrays.sort(array, comparator);I haven't tested the code, so there might be some compiler errors, or an error in the logic.

Similar Messages

  • Sorting a String Array in alpha order (Using ArrayList)

    Hello all!
    I am pretty new to Java and am trying to do a, seemingly, simple task; but cannot get the syntax right. I am trying to sort an ArrayList in aplha order based off of the variable String Product. Any help would be awesome!
    First Class:
    //This program stores all of the variables for use in Inventory.java
    public class Vars {
         // defining all variables
         private String product;
         private String prodCode;
         private double price;
         private double invCount;
         // Begin listing getters for class
         public Vars(String product) {
              this.product = product;
         public String getProdCode() {
              return prodCode;
         public String getProduct() {
              return product;
         public double getPrice() {
              return price;
         public double getInvCount() {
              return invCount;
         // Declaring the total variable
         public double total() {
              return invCount * price;
         // Begin listing setters for variables
         public void setProduct(String product) {
              this.product = product;
         public void setProdCode(String prodCode) {
              this.prodCode = prodCode;
         public void setInvCount(double invCount) {
              this.invCount = invCount;
         public void setPrice(double price) {
              this.price = price;
    Second Class:
    //This program will use the variables stored in Vars.java
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Scanner;
    public class Inventory {
         public static void main(String args[]) {
              Scanner input = new Scanner(System.in);
              //defining and declaring local variables
              String exit;
              int counter;
              double gtotal;
              exit = "exit";
              counter = 0;
              gtotal = 0;
              //beginning message and beginning of the loop
              System.out.print("Welcome to the Inventory Contol System\nPlease enter the Product name: ");
              System.out.println();
              System.out.println("When finished entering in the data, please enter EXIT in place of Product name.");
              String name = input.next();
              List<Vars> var = new ArrayList<Vars>(); //creating arraylist object
              //loop while exit is not entered, exit loop once exit is typed into product variable
              while (name.compareToIgnoreCase(exit) != 0) {
                   Vars vars = new Vars(name); //calling Vars methods
                   counter = counter ++;
                   System.out.println("Please enter the Product Code: ");
                   vars.setProdCode(input.next());
                   System.out.println("Inventory Count: ");
                   vars.setInvCount(input.nextDouble());
                   //Making sure that the value entered is a positive one
                   if(vars.getInvCount() < 0){
                        System.out.println("Please enter a positive number: ");
                        vars.setInvCount(input.nextDouble());
                   System.out.println("Price per product:");
                   vars.setPrice(input.nextDouble());
                   //Making sure that the value entered is a positive one
                   if(vars.getPrice() < 0) {
                        System.out.println("Please enter a positive number: ");
                        vars.setPrice(input.nextDouble());
                   System.out.println("Please enter the next Product name, or enter EXIT: ");
                   name = input.next();
                   gtotal += vars.total(); //calculation for Grand Total of all products entered
                   var.add(vars);
                   static void slectionSort(int[] product) {
                   for (int lastPlace = product.length-1; lastPlace > 0; lastPlace--) {
                   int maxLoc = 0;
                   for (int j = 1; j <= lastPlace; j++) {
                   if (product[j] > product[maxLoc]) {
                   maxLoc = j;
                   int temp = product[maxLoc];
                   product[maxLoc] = product[lastPlace];
                   product[lastPlace] = temp;
              //Sorting loop function will go here, before the information is displayed
              //Exit message and array list headers
              System.out.print("Thank you for using the Inventory program.\nHave a wonderful day.\n");
              System.out.printf("Code\tProduct\tCount\tPrice\tTotal\n");
              System.out.println();
              //For loop to display all entries via an ArrayList
              for (Vars vars : var) {
                   System.out.printf("%5s\t%5s\t%.01f\t$%.02f\t$%.02f\n\n", vars.getProdCode(),
                             vars.getProduct(), vars.getInvCount(), vars.getPrice(),vars.total());
              //Displays the amount of entries made and Grand Total of all products entered
              System.out.println();
              System.out.printf("The number of products entered is %d\n", var.size());
              System.out.printf("The Grand Total cost for the products entered is $ %s\n", gtotal);
              System.out.println();
    }

    go through below links, you can easily understand how to sort lists.
    http://www.onjava.com/lpt/a/3286
    http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html
    http://www.javaworld.com/javaworld/jw-12-2002/jw-1227-sort.html

  • Sorting 2D string array

    Hi I am new to labview. I want to sort my 2D string array by col 1. But I dont know how to sort it perfectly. My sorted array will be something like this.
    Col 1
    A1
    A2
    A3
    A4
    A5
    A6
    A7
    A8
    A9
    A10
    A11

    duplicate, see: http://forums.ni.com/ni/board/message?board.id=170&thread.id=317581&jump=true
    LabVIEW Champion . Do more with less code and in less time .

  • Trying to sort a multidimensional array

    I'm in a Java class and am trying to create an inventory program. It doesn't have to store the data to a file, just create and sort arrays to display the information sorted. I'm using golfing discs as my inventory and was able to get the arrays stuffed and printed out how I liked. Now I just need to figure out how to sort the MasterArray by the disc name column (MasterArray[ ][2]) and, if those are the same, the SKU column (MasterArray[ ][0]).
    The error I'm getting is:
    DiscInventoryCall.java:134: non-static variable this cannot be referenced from a
    static context
    Arrays.sort( MasterArray, new DiscComparator() );
    ^
    Note: DiscInventoryCall.java uses unchecked or unsafe operations.
    Here is my code:
    // Disc Inventory Program
    import java.util.*;
    public class DiscInventoryCall
         // start main method
         public static void main( String args[] )
        // create Scanner to grab input
        Scanner input = new Scanner( System.in );
              // declare variables
              String sendDiscSKU;
              String sendDiscBrand;
              String sendDiscName;
              String sendDiscType;
              int sendDiscWeight = 0;
              double sendDiscPrice = 0.00;
              int sendDiscCount = 0;
              double InventoryTotal = 0.00;
              int AllDone = 0;
              int Counter = 0;
              String DiscStop = "done"; // string value to stop the program
              int Weight1 = 0;
              int Weight2 = 0;
              int Price1 = 0;
              int Price2 = 0;
              int Count1 = 0;
              int Count2 = 0;
              int Value1 = 0;
              int Value2 = 0;
              // declare array variables
              String MasterArray[][] = new String[100][12];
              Double DoubleArray[][] = new Double[100][2];
              int IntArray[][] = new int[100][2];
              System.out.print( "Enter Disc SKU (enter \"done\" when finished): " );
              sendDiscSKU = input.nextLine();
              if ( sendDiscSKU.equals(DiscStop) )
             AllDone = 1;
        } // bypass while loop
              // begin while loop
              while ( AllDone == 0 )
                   System.out.print( "Enter Disc Brand: " );
                   sendDiscBrand = input.nextLine();
                   System.out.print( "Enter Disc Name: " );
                   sendDiscName = input.nextLine();
                   System.out.print( "Enter Disc Type: " );
                   sendDiscType = input.nextLine();
                   System.out.print( "Enter Disc Weight (in grams): " );
                   sendDiscWeight = input.nextInt();
                   System.out.print( "Enter Disc Price: $" );
                   sendDiscPrice = input.nextDouble();
                   System.out.print( "Enter Disc Count: " );
                   sendDiscCount = input.nextInt();
                   // instantiate DiscInventory object
                   DiscInventory Disc = new DiscInventory( sendDiscSKU, sendDiscBrand, sendDiscName, sendDiscType, sendDiscWeight, sendDiscPrice, sendDiscCount );
                   // get Disc data
                   //System.out.println();
                   //System.out.println( "Disc information summary:");
                   //System.out.println();
                   //System.out.printf( "%15s %s\n", "Disc SKU:", Disc.getDiscSKU() );
                   //System.out.printf( "%15s %s\n", "Disc Brand:", Disc.getDiscBrand() );
                   //System.out.printf( "%15s %s\n", "Disc Name:", Disc.getDiscName() );
                   //System.out.printf( "%15s %s\n", "Disc Type:", Disc.getDiscType() );
                   //System.out.printf( "%15s %d grams\n", "Disc Weight:", Disc.getDiscWeight() );
                   //System.out.printf( "%15s $%.2f\n", "Disc Price:", Disc.getDiscPrice() );
                   //System.out.printf( "%15s %d\n", "No. Available:", Disc.getDiscCount() );
                   System.out.printf( "%15s $%.2f\n\n", "Total Value:", Disc.DiscValue() );
                   // System.out.printf( "\n%s:\n\n%s\n", "Disc information obtained by toString", Disc );
                   // Add total inventory values
                   InventoryTotal = InventoryTotal + Disc.DiscValue();
                   System.out.printf( "%15s %.2f\n", "Total Inventory Value:", InventoryTotal );
                   // Stuff the array
                   MasterArray[Counter][0] = Disc.getDiscSKU();
                   MasterArray[Counter][1] = Disc.getDiscBrand();
                   MasterArray[Counter][2] = Disc.getDiscName();
                   MasterArray[Counter][3] = Disc.getDiscType();
                   MasterArray[Counter][4] = Integer.toString(Counter);
                   MasterArray[Counter][5] = "0";        
                   MasterArray[Counter][6] = Integer.toString(Counter);
                   MasterArray[Counter][7] = "0";        
                   MasterArray[Counter][8] = Integer.toString(Counter);
                   MasterArray[Counter][9] =  "1";
                   MasterArray[Counter][10] = Integer.toString(Counter);
                   MasterArray[Counter][11] =  "1";
                   DoubleArray[Counter][0] = Disc.getDiscPrice();
                   DoubleArray[Counter][1] = Disc.DiscValue();
                   IntArray[Counter][0] = Disc.getDiscWeight();
                   IntArray[Counter][1] = Disc.getDiscCount();
                   Counter++;
                   System.out.print( "Enter Disc SKU (enter \"done\" when finished): " );
                   input.nextLine();
                   sendDiscSKU = input.nextLine();
             if ( sendDiscSKU.equals(DiscStop) )
                  AllDone = 1;
                 } // stop while loop
              } // end while loop
              Arrays.sort( MasterArray, new DiscComparator() );
              System.out.printf( "%-11s %-6s %-6s %-15s %-5s %-10s %-6s %-10s\n", "SKU", "Brand", "Name", "Type", "Weight", "Price", "Count", "Value" );
              for ( int Countup = 0; Countup < Counter; Countup++ )
                   Weight1 = Integer.parseInt(MasterArray[Countup][4]);
                   Weight2 = Integer.parseInt(MasterArray[Countup][5]);
                   Price1 = Integer.parseInt(MasterArray[Countup][6]);
                   Price2 = Integer.parseInt(MasterArray[Countup][7]);
                   Count1 = Integer.parseInt(MasterArray[Countup][8]);
                   Count2 = Integer.parseInt(MasterArray[Countup][9]);
                   Value1 = Integer.parseInt(MasterArray[Countup][10]);
                   Value2 = Integer.parseInt(MasterArray[Countup][11]);
                   System.out.printf( "%-11s %-6s %-6s %-15s %-6d $%-8.2f %5d $%-9.2f\n",
                   MasterArray[Countup][0],
                   MasterArray[Countup][1],
                   MasterArray[Countup][2],
                   MasterArray[Countup][3],
                   IntArray[Weight1][Weight2],
                   DoubleArray[Price1][Price2],
                   IntArray[Count1][Count2],
                   DoubleArray[Value1][Value2] );
              System.out.printf( "\n\nThank you for using this program. \nYour total inventory value is: $%.2f\n", InventoryTotal );
         } // end main method
         // begin sorting method
         class DiscComparator implements Comparator
              public int compare( Object obj1, Object obj2 )
                   int result = 0;
                   String[] str1 = (String[]) obj1;
                   String[] str2 = (String[]) obj2;
                   // sort on name of disc
                   if (( result = str1[2].compareTo(str2[2])) == 0 )
                        // if disc names are the same, sort on sku
                        result = str1[0].compareTo(str2[1]);
                   return result;
         }     // end sorting method
    } // end class DiscInventoryCallAny help on what I'm doing wrong would be appreciated.

    I'm pretty new to OOP and, to be honest, wouldn't know what parts could be broken into separate objects.
    There are some extra lines in there I could have removed (commented out) but forgot to do so before I posted it.
    So when it shows:
    DiscInventoryCall.java:134: non-static variable this cannot be referenced from a
    static context
    Arrays.sort( MasterArray, new DiscComparator() );
    ^
    Is that saying the DiscComparator() is a non-static variable? or the MasterArray?

  • Sort an String Array

    Im having trouble sorting an Array. Before i add my new post to a[0] I would like to push all values one step. So value of a[0] will be stored in a[1] and value of [1] will be stored in [2] before a[0] = new value.
    I haven found a way yet, anyone else?
    Sebastian Green

    Hmm, I worked my own way of handle it. Like this:
    for (int i=4; i >= 0 ; i--) {
                   if (i==0){
                        a[i] = getNewData();
                   } else {
                        a[i] = a[i-1];
                 }Which one is best? I could set the "int=4" dynamiclly . But why should I use Vector? I thought that it would be better with a String[]. Then I have set the amount of memory to use for my Array? Or is is better to store it in an Vector and call New Vector () every round so the size dosent get large then it has to?

  • Trying to compare string array using equals not working

    Hi,
    im prolly being really dumb here, but i am trying to compare 2 string arrays using the following code:
    if(array.equals(copymearray))
    System.out.println("they match");
    else
    {System.out.println("dont match");}
    the trouble is that even though they do match i keep getting dont match, can anyone tell me why?

    try
    if (Arrays.equals(array, copymearray))
    System.out.println("they match");
    else
    {System.out.println("dont match");}

  • String Array Sorting

    Question 1. Anybody know how to easily sort a string array?
    Question 2. Is there any good data base management VI's out there anywhere?
    Thank you

    > Question 1. Anybody know how to easily sort a string array?
    >
    There is this icon in the Array palette called Sort 1D Array. You might want
    to give it a try.
    > Question 2. Is there any good data base management VI's out there anywhere?
    >
    There may be some freebie stuff floating around, but I know that NI has
    an SQL add-on for communicating with most standard databases. As mentioned
    in a previous posting this morning, you can also use ActiveX if that is
    more convenient/easier for you. From my experience, most people find the
    SQL approach easier once they get past the three letter acronym.
    Greg McKaskle

  • How to Display string array in jsp page using netui-data:repeater tag ??

    hi,
    I am trying to display a string array in a table using the netui-data:repeater tag.
    I have to use a page flow controller Array(1 Dimensional) to be displayed in the jsp.
    Can any one tell me how to print the array in a table of 3rows & 5 columns.
    Here is the code on which I am crrently working on.
    <netui-data:repeater dataSource="{pageFlow.strWorkObject_Array}">
    <netui-data:repeaterHeader>
    <table cellpadding="4" border="1" class="tablebody">
    </netui-data:repeaterHeader>
    <netui-data:repeaterItem>
    <tr>
    <td><netui:label value="{container.item}" >
    </netui:label></td>
    <td><netui:label value="{container.item}">
    </netui:label></td>
    <td><netui:label value="{container.item}">
    </netui:label></td>
    </tr>
    </netui-data:repeaterItem>
    <netui-data:repeaterFooter>
    </table>
    </netui-data:repeaterFooter>
    </netui-data:repeater>

    weblogic.developer.interest.workshop
    Mansoor Naseem wrote:
    I would like to know where the pageflow newsgroup is.
    These are all the groups in weblogic.developer.interest:
    weblogic.developer.interest.60beta.* (5 groups) weblogic.developer.interest.management
    weblogic.developer.interest.61beta.* (2 groups) weblogic.developer.interest.misc
    weblogic.developer.interest.clustering.* (1 group) weblogic.developer.interest.performance
    weblogic.developer.interest.commerce weblogic.developer.interest.personalization
    weblogic.developer.interest.ejb.* (3 groups) weblogic.developer.interest.portal
    weblogic.developer.interest.environment weblogic.developer.interest.rmi-iiop
    weblogic.developer.interest.jdbc weblogic.developer.interest.security
    weblogic.developer.interest.jms weblogic.developer.interest.servlet
    weblogic.developer.interest.jndi weblogic.developer.interest.tools
    weblogic.developer.interest.jsp weblogic.developer.interest.weblogicenterprise
    MN

  • DateTime String array in Graph

    Greetings.
    I tried to plot DateTime string array VS Numbers array with no success in the XY Graph object.
    I even converted the DateTime string array to DateTime type using the VI called "Convert_String_to_TimeStamp.vi" with also no success as the X (Time) is just very big numbers and a datetime format.
    Please check the attached shot, it will describe the situation clearly.
    Thanks in advance
    Ayman
    Ayman Mohammad Metwally
    Automation Engineer
    Egypt - Cairo
    Solved!
    Go to Solution.
    Attachments:
    Graph.JPG ‏93 KB

    You could read the file line by line and use the scan from sting function to convert to a timestamp.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • Pass String Array to DLL

    Hi,
     I m trying to pass a String Array to a DLL, but I can't found the type for the  "Char *heihei[ ]"
    Here I attached the screenshot here. Hopefully some expert here can help me to solve out this thing. Thanks a lot in advance.
    DLL input:
    int __stdcall RunDLLUI (char * pszMainPath, char * pszFileName, int * nArrayErrorRow, char * pszArrayErrorCol[], int nNumOfErrors, int nOffsetError);          
    Please refer to the pictures attached. Thanks again for your time.
    Attachments:
    code.JPG ‏29 KB
    front.JPG ‏40 KB
    DataType.JPG ‏49 KB

    You should post your LabVIEW question to the LabVIEW board.

  • Problem when passing string array in sessions showing null value

    i am trying to pass a string array but it is showing me the null value
    i think the the problem is seem to be in session.settAttribute("subject['"+i+"']",subject) in 2.login_action.jsp
    or in String sub1=(String) session.getAttribute("subject[0]"); in 3.user_home.jsp
    i have following three pages
    1.login.html
    2.login_action.jsp
    3.user_home.html
    1.login.html
    <html>
    <body>
    <form method="post" action="login_action.jsp">
    Username<input type="text" name="username"></input>
    <br>
    Password<input type="password" name="password"></input>
    <input type="submit" value="login"></input>
    </form>
    </body>
    </html>
    2.login_action.jsp
    <%@ page contentType="text/html"%>
    <%@ page import="java.sql.*" %>
    <%!
    String user,pwd;
    String subject[]=new String[10];
    int i,totalsubject;
    %>
    <%
    try
    user=request.getParameter("username");
    pwd=request.getParameter("password");
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:ods","scott","tiger");
    PreparedStatement ps = con.prepareStatement("select password from users where username='"+user+"'");
    ResultSet rs = ps.executeQuery();
    if(rs.next())
    if(rs.getString("password").equals(pwd))
    session.setAttribute("username",user);
    PreparedStatement ps2 = con.prepareStatement("select subject_id from allot_teachers where staff_id='"+user+"'");
                        ResultSet rs2 = ps2.executeQuery();          
                             while(rs2.next())
                             i=0;
                             subject[i]=rs2.getString(1);
    // if i display here the subjects in out.println(subject[i]) it is working fine
    // but in next redirected page it is showing null
                             session.setAttribute("subject['"+i+"']",subject[i]);
                             //out.println(subject[i]);
                             i++;
    response.sendRedirect("user_home.jsp");
    else
    out.println("error invalid username or password");
    else
    out.println("error invalid username or password");
    con.close();
    catch(Exception e)
    out.println(e);
    %>
    3. user_home.jsp
    <%@ page contentType="text/html"%>
    <%@ page import="java.sql.*" %>
    <html>
    <%
    String user,pwd,cat,cat1;
    String username=(String) session.getAttribute("username");
    if(username==null)
    response.sendRedirect("login.html");
    //just tried for first two subjects
    String sub1=(String) session.getAttribute("subject[0]");
    String sub2=(String) session.getAttribute("subject[1]");
    //here it is printing null
    out.println(sub1);
    //here it is printing null
    out.println(sub2);
    %>
    <form method="post" action="logout.jsp">
    <input type="submit" value="Logout"></input>
    </form>
    </html>
    Cheers & Regards
    sweety

    The name in getAttributre doesnt match the name in setAttribute.
    Note "subject[0]" is a string containing 10 chars, "subject" is a string containing 7 chars.
    Here is your code:
    session.setAttribute("subject",subject);
    String sub1=(String) session.getAttribute("subject[0]");

  • Display string array in a table using netui-data:repeater tags

    hi,
    I am trying to display a string array in a table using the netui-data:repeater tag.
    I have to use a page flow controller Array(1 Dimensional) to be displayed in the jsp.
    Can any one tell me how to print the array in a table of 3rows & 5 columns.
    Here is the code on which I am crrently working on.
    <netui-data:repeater dataSource="{pageFlow.strWorkObject_Array}">
    <netui-data:repeaterHeader>
    <table cellpadding="4" border="1" class="tablebody">
    </netui-data:repeaterHeader>
    <netui-data:repeaterItem>
    <tr>
    <td><netui:label value="{container.item}" >
    </netui:label></td>
    <td><netui:label value="{container.item}">
    </netui:label></td>
    <td><netui:label value="{container.item}">
    </netui:label></td>
    </tr>
    </netui-data:repeaterItem>
    <netui-data:repeaterFooter>
    </table>
    </netui-data:repeaterFooter>
    </netui-data:repeater>

    weblogic.developer.interest.workshop
    Mansoor Naseem wrote:
    I would like to know where the pageflow newsgroup is.
    These are all the groups in weblogic.developer.interest:
    weblogic.developer.interest.60beta.* (5 groups) weblogic.developer.interest.management
    weblogic.developer.interest.61beta.* (2 groups) weblogic.developer.interest.misc
    weblogic.developer.interest.clustering.* (1 group) weblogic.developer.interest.performance
    weblogic.developer.interest.commerce weblogic.developer.interest.personalization
    weblogic.developer.interest.ejb.* (3 groups) weblogic.developer.interest.portal
    weblogic.developer.interest.environment weblogic.developer.interest.rmi-iiop
    weblogic.developer.interest.jdbc weblogic.developer.interest.security
    weblogic.developer.interest.jms weblogic.developer.interest.servlet
    weblogic.developer.interest.jndi weblogic.developer.interest.tools
    weblogic.developer.interest.jsp weblogic.developer.interest.weblogicenterprise
    MN

  • Simpler way to sort 2-d string array?

    I have a long 2d string array, and I would like to sort by the 2nd value. It originates as:
        public static final String names[][] = {
         {"000000", "Black"},
         {"000080", "Navy Blue"},
         {"0000C8", "Dark Blue"},
         {"0000FF", "Blue"},
            {"000741", "Stratos"},
         {"FFFFF0", "Ivory"},
         {"FFFFFF", "White"}
        };As you can see, they are pre-sorted by the hex values. That is useful for part of the app.
    There are 1,567 entries. I would like to alphabetize the color names and place them in a list widget. I need to keep the associated hex color values with the name values. All I can think of to do something like:
    1) make a temporary long 1-d string array
    2) fill it by loop that appends the hex values to the name values: temp[i] = new String (names[1] + names[i][0])
    3) sort temp[] with built in Java sort
    4) make a permanent new string array, hexValues[] for the hex values
    5) copy the last 6 characters of each item to hexValues[]
    6) truncate the last 6 characters of each item in temp[]
    7) build list widget with temp[]
    Is there a more elegant way? What I'd really like to do is build a 1-d array of int's, with the values representing the alphabetized locations of the names. However, I don't see any built-in which would do that kind of indirect sort.
    Second question -- Can the backgrounds of each item in a list widget be a different color? Ideally the list would show the color name in black or white, and the its color value as background. Specifically, I'm trying to build the list accomplished by the Javascript code here:
    * http://chir.ag/projects/name-that-color/
    and add it to my Java interactive color wheel:
    * http://r0k.us/graphics/SIHwheel.html
    BTW, I have converted his name that color Javascript (ntc.js) to a native Java class. It is freely distributable, and I host it here:
    * http://r0k.us/source/ntc.java
    -- Rich
    Edited by: RichF on Oct 7, 2010 7:04 PM
    Silly forum software; I can't see what made it go italic at the word new.

    I am implementing a sort infrastructure along the lines of camickr's working example, above. Part of my problem is that I am new to both lists and collections. I've tried searching, and I cannot figure out why the compiler doesn't like my "new":
    public class colorName implements Comparable<colorName>
        String     name, hex;
        int          hsi;
        static List<colorName> colorNames;
        public colorName(String name, String hex)
         float     hsb[] = {0f, 0f, 0f};
         int     rgb[] = {0, 0, 0};
         int     h, s, b;     // b for brightness, same as i
         this.name = name;
         this.hex  = hex;
         // Now we need to calculate hsi,
         this.hsi = (h << 10) + (s << 6) + b;  //  hhhhhhssssiiiiii
        ***   findColorName() performs 3 functions.  First, it
        *** will auto-initialize itself if necessary.  Second,
        *** it will perform 3 sorts:
        ***   -3) byHSI:  sort by HSI and return first element of sorted list
        ***   -2) byNAME: sort by name and return first element of list
        ***   -1) byHEX:  (re)reads ntc.names, which is already sorted by HEX;
        ***               returns first element of list
        *** Third, on 0 or greater, will return the nth element of list
        *** Note: ntc.init() need not have been called.
        public colorName findColorName(int which)
         if (which < -3)  which = -3;
         if (which >= ntc.names.length)  which = ntc.names.length - 1;
         if (which == -1)  colorNames = null;     // free up for garbage collection
         if (colorNames == null)
         {   // (re)create list
             colorNames = new ArrayList<colorName>(ntc.names.length);
             for (int i = 0; i < ntc.names.length; i++)
                 colorNames.add(new colorName(ntc.names[1], ntc.names[0]));
            if (which == -1)  return(colorNames.get(0));
    }On compilation, I receive:
    D:\progming\java\ntc>javac colorName.java
    colorName.java:117: cannot find symbol
    symbol  : constructor colorName(java.lang.String[],java.lang.String[])
    location: class colorName
                    colorNames.add(new colorName(ntc.names[1], ntc.names[0]));
                                   ^
    1 errorLine 117 is the second-to-last executable line in code block. I know it is finding the ntc.names[][] array the ntc.class file. I had forgotten to compile ntc.java, and there were other errors, such as in line 115 where it couldn't find ntc.names.length. Compare camickr's two lines:
              List<Person> people = new ArrayList<Person>();
              people.add( new Person("Homer", 38) );As far as I can tell, I'm doing exactly the same thing. If you have any other feedback, feel free to make it. The full source may be found at:
    * http://r0k.us/rock/Junk/colorName.java
    PS1: I know I don't need the parenthesis in my return's. It's an old habit, and they look funny to me without them.
    PS2: My original design had the "static List<colorName> colorNames;" line defined within the findColorName() method. The compiler did not like that; it appears to be that one cannot have static variables within methods. Anyway, that's why I don't have separate sorting and getting methods. I'm learning; "static" does not mean, "keep this baby around". Its meaning is, "there is only one of these babies per class".
    -- Rich

  • Sort String Array by Date

    I use the following code to populate a string array:
    File dirFile          = new File("C:\\somedir");
    String fileImport[]      = dirFile.list();
    This gives me a string array with a whole bunch of files in the following format:
    XXXDDMMYYHHMISS.xml
    What I need to know is what is the easiest way to sort this array based on this date format, or any date format, in the ascending order, so that when I am loading my XML files, I get the oldest one first.
    Appreciate any input.
    Sam

    Use the String name of the file (the Date part), together with a java.text.SimpleDateFormat object to parse() the String. You have to set the formatter with a pattern - these are explained fully in the Javadocs for the SimpleDateFormat class. After parsing, you will have java.util.Date objects for each of the files - you can then use these as keys in a java.util.SortedMap (the values would be the files) - the natural ordering of dates will ensure that they are ordered appropriately

  • Trying to setText on random JPanels via a String array?

    My assignment is to create a bunch of JButtons, and randomly have an "X" appear on one, until it is clicked, and then it goes away and reappears on another random one. It does this ten times and displays the time it took to do so.
    I've created all the JButtons, named b01 to b48 and put them in a gridLayout. That part works fine.
    I created a String[] array with the 48 names of the JButtons in it, then I was thinking I could go this route...
    Random r = new Random();
    String random = panels[r.nextInt(panels.length)];
    random.setText("X");  //This is where the program hangs up.I can replace the setText statement with a System.out.println statement, and it shows up on the console correctly...

    Brandon,
    Have a chook at my minesweeper game at http://forum.java.sun.com/thread.jspa?forumID=54&threadID=5248903 ... it uses a matrix of cells[rows][cols]... each Cell is a JPanel which contains a Button.
    I think you'll end up with something like ...
      // create an array of Buttons
      Button buttons[] = Button[NUM_BUTTONS];
      for (int i=0; i<NUM_BUTTONS; i++) {
        buttons[] = new Button(i);
      // Xify a random button for a random time
      buttons[random.nextInt(NUM_BUTTONS)].xify()I'd create a:
    class Button extends JButton
    * provides a constructor(int index) which sizes and places the button according to it's index
    * provides an "xify" method, which setText("X"), then sets-up a SwingTimer to setText(null) after a random time.
    Cheers. Keith.

Maybe you are looking for

  • Xml publisher excel output

    Hi. I have the rtf-template for xml-publisher report with excel output. There is the table there. I need format the table according appointed requirements (in output excel file). For example, width of the columns of the table must be fixed width. How

  • How do I use one (sm

    aller)array of index locations to access another larger array and perform calculations on the larger array before retrieving the next index location. A for loop doesn't seem to do the trick neither does a shift register, or I'm using them wrong. New

  • ECC 6.0 HCM / Crystall Reports

    Hello : I would like to know if we can use CR2008 with HCM in some scenarious  instead of Standard SQ01/SQ02/SQ03 and infosets queries. If am aware that we need ODBC if we connect with Access or any other source. How do we connect ECC 6.0 with Crysta

  • Airport to close to notebook then it hickups

    I use my Airport Express to listen to Itunes using my stereo. The airport is connected to my wireless system, and works fine as long my notebook is at least 50 cm away from the Airport. The Airport, connected to my stereo, is on a shelf in a cabinet,

  • How to identify the required version of SAPINST and other SAP software?

    I have a dell poweredge machine with quad processor . On this we installed win 2k3 std x86 when I go to my computer and properties, it shows me intel processor, and win 2k3 x86_64 Then I download the IA64 verison and X86 versions of PI71 and related