Can only arrays be multi-dimensional?

Hi, i've been looking at ways to reference two objects together.
eg.
date1 is linked with position '1' in the vector
date2 is linked with position '5' in the vector
date3 is linked with position '7' in the vector
so the 2D array would look like this:
| Col 0 | Col 1|
Row 0 | Date1 | 1 |
Row 1 | Date2 | 5 |
Row 2 | Date3 | 7 |
the only way i've thought of doing this is by using a 2D array. but arrays are a set size and if i want to make it bigger i would need to create another array and copy it all over to the bigger one.
are there such things as 2D vectors or lists i can use instead of arrays?

the dates are not important, it's just an example.
But if I wanted to retrieve those values back from
the array list, how would you do that.
ThanksRetrieve which values from the list? Retrieve the day, month, year from the list? You don't do that, you retrieve Records from the list.
Are you asking how to retrieve records from the List? The usual way is with an iterator. Do you need to retrieve a specific Record that you identify explicitly? Then maybe you want a Map, not a List.
[url http://java.sun.com/docs/books/tutorial/collections/]Collections Tutorial
As for getting a given field from a record, you could either make the field public (almost always a bad idea) or you could provide a getter method (often a bad idea, but often preferable to public fields).
http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html
Here are some intro-to-Java type resources you may find useful.
Sun's basic Java tutorial
Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
Bruce Eckel's Thinking in Java (Available online.)
Joshua Bloch's Effective Java
Bert Bates and Kathy Sierra's Head First Java.

Similar Messages

  • How can I (neatly) control mouse click events in a multi-dimensional array?

    Hello everyone!
         I have a question regarding the use of mouse clicks events in a multi-dimensional array (or a "2D" array as we refer to them in Java and C++).
    Background
         I have an array of objects each with a corresponding mouse click event. Each object is stored at a location ranging from [0][0] to [5][8] (hence a 9 x 6 grid) and has the specific column and row number associated with it as well (i.e. tile [2][4] has a row number of 2 and a column number of 4, even though it is on the third row, fifth column). Upon each mouse click, the tile that is selected is stored in a temporary array. The array is cleared if a tile is clicked that does not share a column or row value equal to, minus or plus 1 with the currently targeted tile (i.e. clicking tile [1][1] will clear the array if there aren't any tiles stored that have the row/column number
    [0][0], [0][1], [0][2],
    [1][0], [1][1], [1][2],
    [2][0], [2][1], [2][2]
    or any contiguous column/row with another tile stored in the array, meaning that the newly clicked tile only needs to be sharing a border with one of the tiles in the temp array but not necessarily with the last tile stored).
    Question
         What is a clean, tidy way of programming this in AS3? Here are a couple portions of my code (although the mouse click event isn't finished/working correctly):
      public function tileClick(e:MouseEvent):void
       var tile:Object = e.currentTarget;
       tileSelect.push(uint(tile.currentFrameLabel));
       selectArr.push(tile);
       if (tile.select.visible == false)
        tile.select.visible = true;
       else
        tile.select.visible = false;
       for (var i:uint = 0; i < selectArr.length; i++)
        if ((tile.rowN == selectArr[i].rowN - 1) ||
         (tile.rowN == selectArr[i].rowN) ||
         (tile.rowN == selectArr[i].rowN + 1))
         if ((tile.colN == selectArr[i].colN - 1) ||
         (tile.colN == selectArr[i].colN) ||
         (tile.colN == selectArr[i].colN + 1))
          trace("jackpot!" + i);
        else
         for (var ii:uint = 0; ii < 1; ii++)
          for (var iii:uint = 0; iii < selectArr.length; iii++)
           selectArr[iii].select.visible = false;
          selectArr = [];
          trace("Err!");

    Andrei1,
         So are you saying that if I, rather than assigning a uint to the column and row number for each tile, just assigned a string to each one in the form "#_#" then I could actually just assign the "adjacent" array directly to it instead of using a generic object to hold those values? In this case, my click event would simply check the indexes, one at a time, of all tiles currently stored in my "selectArr" array against the column/row string in the currently selected tile. Am I correct so far? If I am then let's say that "selectArr" is currently holding five tile coordinates (the user has clicked on five adjacent tiles thus far) and a sixth one is being evaluated now:
    Current "selectArr" values:
           1_0
           1_1, 2_1, 3_1
                  2_2
    New tile clicked:
           1_0
           1_1, 2_1, 3_1
                  2_2
                  2_3
    Coordinate search:
           1_-1
    0_0, 1_0, 2_0, 3_0
    0_1, 1_1, 2_1, 3_1, 4_1
           1_2, 2_2, 3_2
                  2_3
         Essentially what is happening here is that the new tile is checking all four coordinates/indexes belonging to each of the five tiles stored in the "selectArr" array as it tries to find a match for one of its own (which it does for the tile at coordinate 2_2). Thus the new tile at coordinate 2_3 would be marked as valid and added to the "selectArr" array as we wait for the next tile to be clicked and validated. Is this correct?

  • Best practice in JSTL with multi-dimensional arrays

    Hi,
    I'm working in a project and I'm trying to convert some code into JSTL way, I have a first.jsp that calls addField(String, String) from fieldControl.jsp:
    (first.jsp)
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ include file="fieldControl.jsp" %>
    <html>
    <head><title>JSP Page</title></head>
    <body>
    <%! String[][] list1;
    %>
    <%
    list1 = new String[2][2];
    list1[0][0]="first_1";
    list1[0][1]="first_2";
    list1[1][0]="second_1";
    list1[1][1]="second_2";
    for (int i=0;i<list1.length;i++){
    String html;
    html = addField (list1[0], list1[i][1]);
    out.println(html);
    %>
    </body>
    </html>
    (fieldControl.jsp)
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ page language="java" %>
    <%! public void addField(String name,String label)
    return ...
    Now for JSTL I've this example from "JSTL pratical guide for JSP programmers" Sue Spielman:
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <html>
    <head>
    <title>
    Display Results
    </title>
    </head>
    <body>
    <%-- Create a HashMap so we can add some values to it --%>
    <jsp:useBean id="hash" class="java.util.HashMap" />
    <%-- Add some values, so that we can loop over them --%>
    <%
         hash.put("apples","pie");
         hash.put("oranges","juice");
         hash.put("plums","pudding");
         hash.put("peaches","jam");
    %>
    <br>
    <c:forEach var="item" items="${hash}">
    I like to use <c:out value="${item.key}" /> to make <c:out value="${hash[item.key]}" />
    <br>
    <br>
    </c:forEach>
    </body>
    </html>
    and my problem is :
    1st - how to use the multi-dimensional array in this way (<jsp:useBean id="hash" class="java.util.HashMap" />) ? because if I use it like this
    <% String[][] list1;
    list1 = new String[2][2];
    list1[0][0]="first_1";
    list1[0][1]="first_1";
    list1[1][0]="second_1";
    list1[1][1]="second_2";%>
    <c:out value="${list1}" />
    <c:out value="${list1.lenght}" />
    I get nothing,
    also tryed <c:set var="test" value="<%=list1.length%>" /> and got "According to TLD or attribute directive in tag file, attribute value does not accept any expressions"
    2nd hot to make the call to the method addField?
    Thanks for any help, I really want to make this project using JSTL, PV

    When you are using JSTL, it is best to not put data inside the JSP. Put it inside JavaBeans. Then make calles to the methods in those JavaBeans.
    So you should get used to JavaBeans and their requirenments.
    Access JavaBeans only through 2 types of methods: getters and setters.
    Getters are used to "get" values (properties) from the bean, and always have the form
    public Type getPropertyName(void)
    That is, they are public, return some value, start with the exact string "get" end with the name of the property (first letter of the property name capitalized) and have a void (empty) argument list.
    For example, this is a good signature to get HTML from a bean:
    public String getHtml()
    Setters are used to assign values to a bean. They always have the form
    public void setPropertyName(Type value)
    That is, they are public, do not return anything, start with the string "set", end with the name of the property (first letter capitalized), and take a SINGLE parameter.
    public void setHtml(String value)
    Also, JavaBeans must have a no argument constructor and need to be Serializable.
    The way I would approach this would be to create a JavaBean that holds the two dim array for you, and has a getter that returns a list of all the formatted html.
    package mypack;
    import java.util.List;
    import java.util.ArrayList;
    public class DataFormatterBean implement java.io.Serializable {
      private String[][] list;
      public DataFormatterBean() {
        list = new String[2][2];
        list[0][0]="first_1";
        list[0][1]="first_2";
        list[1][0]="second_1";
        list[1][1]="second_2";
      public List getHtml() {
        List outputHtml = new ArrayList(list.length);
        for (int i = 0; i < list.length; i++) {
          String html = addField(list[0], list[i][1]);
    outputHtml.add(html);
    return outputHtml;
    private addField(String a, String b) { .. do work .. }
    Then, the JSP would look like this:
    <jsp:useBean id="dataFormatter" class="mypack.DataFormatterBean"/>
    <c:forEach var="htmlString" items="${dataFormatter.html}">
      <c:out value="${htmlString}"/>
    </c:forEach>Once you start thinking in terms of having JavaBeans do your work for you JSTL is so much easier... and it gets even easier when you start to delve into custom tags.

  • Multi-dimensional arrays in Cocoa

    Oh, dear. After spending the best part of 12 hours entering 2,000+ elements of a multi-dimensional array into a 'plist', I then start looking on the net for reasons why my C-style code won't compile and read that I can only use single-dimensional arrays?
    WHAT? Arrrrrgghhh! ^#&}@!
    Looking at both array types in a 'plist' they look like:
    // one-dimensional...
    <array>
    <array>
    <string>Aberayron</string>
    </array>
    <array>
    <string>Abergavenny</string>
    </array>
    <array>
    <string>Aberystwyth</string>
    </array>
    </array>
    // ...and multi-dimensional
    <array>
    <array>
    <string>Aberayron</string>
    <string>XXVII</string> // pre-1852 style
    <string>11b</string> // modern style
    </array>
    <array>
    <string>Abergavenny</string>
    <string>XXVI</string>
    <string>11a</string>
    </array>
    <array>
    <string>Aberystwyth</string>
    <string> XXVII </string>
    <string>11b</string>
    </array>
    </array>
    but apparently I can't access the other column elements using say:
    [aTextField setStringValue: [anArray objectAtIndex: [counter][2]]];
    What makes it even more frustrating is that when my app is launched, the runlog quite happily displays the contents of the array as:
    'districts array' returned (
    (Aberayron, XXVII, 11b),
    (Abergavenny, XXVI, 11a),
    (Aberystwyth, XXVII, 11b),
    ....... etc. etc .........
    Can anyone (hopefully) tell me I misread all those 'net posts and suggest a simple way I can access this data using maybe, an offset of bytes in memory please?
    Ernie

    Ernie Thompson wrote:
    Oh sure, with the benefit of hindsight my beginners example had serious Cocoa syntax errors, but what was so wrong with the underlying idea on which my question was based?
    There wasn't anything "wrong", it was just in the wrong context. I'll explain...
    I am mindful of the efforts good people like yourself put into helping us 'newbies' here, and rather than waste your collective times posting every trivial question that we ourselves could solve in a few short minutes with an internet search, I spend a considerable amount of time doing just exactly that before I post. However, I constantly come across statements like:
    ...Since Obj-C, like C++, is a superset of C (and basically IS C...)... It's actually one of the
    major annoyances (to me anyway) of working in pure Obj-C code on this project: there is no direct
    support for multi-dimensional arrays... etc. etc..
    I completely understand your confusion. The Internet is stuffed full of information of all kinds. Not all of it is correct information, however. I'm not even sure the majority is correct.
    and that is just a tiny cross-section of comments. As I found myself doing on at least one previous occasion, I once again apologise for having been misled, Quite clearly, with arrays being supported in Obj-C (as you have demonstrated) -- while at the same time not being supported , and Obj-C being C -- while also not being C, learning Cocoa is clearly going to take a little more time than I initially anticipated.
    OK, I'll explain. Objective-C is a superset of C. Anything you can do in C, you can do in Objective-C. You can certainly create and use multidimensional arrays in Objective-C exactly how you wanted to originally. But that kind of array is a C array, such as:
    int arr[512];
    or
    double * matrix = malloc(sizeof(double) * 32 * 32);
    An "NSArray" is an entirely different thing. It is not a C array, it is an Objective-C object. Any time you have bracket characters, you are dealing with Objective-C objects. They have no built-in syntax other than:
    [receiver message: arg param2: arg2 param3: arg3 ... paramN: argN];
    If you really want to get confused, you could look at C++ or even Objective-C++. There, you can have arrays that really are arrays but are objects too. On second thought, you probably don't want to do that
    PS: Don't worry about wasting my time. I only post here so I can clear my mind from whatever I'm working on and give my subconscious an opportunity to find a fix for all the screw-ups I've done in my code.
    Message was edited by: etresoft

  • Assigning values to 2D Multi-Dimensional arrays ??

    How do I assign a value to a Multi-dimensional 2D Array,
    that has the righter array size omitted as it changes�.
    Code�
    SomeObj foobar = new SomeObj (first, second);
    SomeObj [ ] [ ] d2D = new SomeObj [10] [ ];
    d2D [0][0] = foobar;     //Causes a null pointer exception�
    NB: seems if I initiate �d2D = new SomeObj [10] [10];� with the righter array size initiated then the error doesn�t occur, but because of the nature of the data the size of each secondary array varies�
    Thx. Kharsim

    apparently not...
    from what i read up on Multi-Dimensional arrays, you only have to give a value to the leftest bracket...
    e.g.
    int [ 5 ] [     ] [     ] <~ Acceptable in Java
    int [ 5 ] [  6 ] [     ] <~ Acceptable in Java
    int [ 5 ] [  6 ] [ 24 ] <~ Acceptable in Java
    int [ 5 ] [     ] [ 24 ] <~ Not acceptable in Java
    so using arrays it should be possible to assign a value in either of the acceptable cases, but couldnt find a source that had such an example...

  • Populating ADF Table from Multi-Dimensional Array

    Hello!
    I'm trying to populate an ADF table from a multi-dimensional array.
    Let's say that my array is
    String [] [] myArr = new String [3][5].
    On my page backing bean, I have a private attribute called tmpArr like this...
    String [] [] tmpArr;
    ...which I will initialize later after I know the proper dimensions. The dimensions will come from a multimap that contains a key and and another array (for the key's value) containing values for the key. So once I know the dimensions I initialize my array with...
    tmpArr = new String [x][y] where x and y are the dimensions (counters).
    Now I have my multidimension array. On an jsp page I have an ADF table, and I'm setting the value for the table to the array (the table's value property is bound to the backing bean's tmpArr attribure).
    Like so:
    <af:panelForm id="availableOptions"
    binding="#{myBackingBean.availableOptionsValues}">
    <af:table emptyText="No items were found" rows="10"
    value="#{myBackingBean.tmpArr}" var='myArr'>
    Now I need to know how to do the following:
    1) Set the table's columns based on the number of attributes on the array.
    2) Set the table's rows based on the array's length.
    3) Set each table cell value to values on the array's 2nd dimension. I'm assuming that ADF takes care iterating through the array, and that I should do something like...
    <af:outputText value="#{myArr[][0]}"/>
    <af:outputText value="#{myArr[][1]}"/>
    etc...
    However, this isn't working...
    javax.faces.el.ReferenceSyntaxException: myArr[][0]
    ...bla bla bla...
    Was expecting one of:
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <STRING_LITERAL> ...
    "true" ...
    "false" ...
    "null" ...
    "not" ...
    "empty" ...
    <IDENTIFIER> ...
    Is there a blog or resource (article, book, etc) that shows how this is done? Anyone has done this and would like to share how?
    Thank you.

    This is in fact possible. I'm not sure about the "best practice" around doing this but there is a couple of ways to do this.
    You can either create a managed bean then right click on it and use the wizard to create a data control or you can do it as per below
    The a table will convert an array into a collection.
    Once you have created an array and generated the accessors in a bean you can then reference the mutli-dimensional array from a table as per below.
    <af:table value="#{pageFlowScope.PageBean.sessionArr}" var="row" rowBandingInterval="0" id="t1" varStatus="status">
    <af:column sortable="false" headerText="col1" id="c1">
    <af:outputText value="#{pageFlowScope.PageBean.sessionArr[status.index][0]}" id="ot1"/>
    </af:column>
    </af:table>
    String [][] sessionArr = new String[5][2];
    public void setSessionArr(String[][] sessionArr) {
    this.sessionArr = sessionArr;
    public String[][] getSessionArr() {
    sessionArr[0][0]="rice";
    sessionArr[1][0]="water";
    return sessionArr;
    EDIT: For either of the above methods the managed bean must have a scope of pageFlow or longer.
    Cheers,
    Aaron
    Edited by: Aaron Rapp on Oct 6, 2011 3:28 PM

  • Setting up a multi dimensional array of objects

    Hey ya'll. How would i setup a multi dimensional array with this structure?
    TypeSave(Title, material(name, quantity))
    TypeSave[1](Lego Shop, material[1](Lego Blocks, 100))
                   material[2](Roof, 1))
    TypeSave[2](Lego Car, material[1](Door, 2))
              material[2](Gravy, 3, ounces))
    TypeSave will be saved as a serialised object to a file so i can load everything within it and keep the structures integrity.
    I'll have an add button that will add the name and quantity to the next empty position of "material" array. This will then be listed in a list box and allow me to save all the materials with a title to the TypeSave list in the next empty position.
    I'm getting mightily confused how to set up the classes and the array structure :(
    Any help would be greatly appreciated!

    private TypeSave t = new TypeSave();
    private void btnSaveItemActionPerformed(java.awt.event.ActionEvent evt) {                                             
            t.addItem(txtItemTitle.getText(), new Material(txtMaterialName.getText(),txtQuantity.getText()));
            t.saveToFile();
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new MainForm().setVisible(true);
        class Material implements Serializable {
         String name = null;
         String quantity = null;
         //To restrict default constructor
         private Material() {
         public Material(String name, String quantity) {
              this.name = name;
              this.quantity = quantity;
         public String getName() {
              return this.name;
         public String getQuantity() {
              return this.quantity;
         public String toString() {
              return "Name : " + this.name + "Quantity : " + this.quantity;
    class TypeSave implements Serializable {
         private Hashtable items = null;
         public TypeSave() {
              items = new Hashtable();
         public void addItem(String title,Material material) {
              ArrayList materials = (ArrayList) items.get(title);
              if(materials == null) {
                   materials = new ArrayList();
                   items.put(title,materials);
              materials.add(material);
         public Hashtable getItems() {
              return this.items;
         public ArrayList getItem(String title) {
              return (ArrayList)this.items.get(title);
            void saveToFile() {
        ObjectOutputStream oos = null;
            try
            oos = new ObjectOutputStream(new FileOutputStream("item.ser"));
            catch (IOException i)
              System.out.println( "Error opening file");
          try
            oos.writeObject(items);
            catch (IOException o)
                System.out.println("Error writing file");
          try
              if(oos != null)
              oos.close();
            catch (IOException x)
                System.out.println("Error closing file");
    }My save class was working, but i tried to merge it to test this code structure and now it's failing with excepion:
    "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"
    any ideas?

  • Binding arraylist, list, or multi-dimensional array to table in web dynpro

    Greetings,
    I like to ask if anyone knows how to bind data from an arraylist, list, or multi-dimensional array list to a table in web dynpro, your help is much appreciated.
    Thanks in advance.
    Cory

    Is there a way to create or cast a multi-dimensional
    array from a Collection or Vector ?
    ArrayList list = new ArrayList();
    list.add( new Object[4] );
    Object[] array2 = list.toArray(); // is only
    single dimension !
    Of course it is a single dimension array.
    Check the definition of the toArray() function, and the specification of arrays in general.
    toArray() returns a one dimensional array.
    In your case it will return an array of arrays. So array2[0] will be an array of 4 objects.
    That just happens to be a 2 dimensional array though you may (I haven't checked it) need some parentheses to call the elements.
    Try Object o = array2[0][1]; and if that doesn't work Object o = (array2[0])[1];

  • JNI: Multi-dimensional (3-D) Array [][][]

    Hi,
    Am having trouble with passing multi-dimensional arrays from C++ to Java.
    The Java method receives an object but it's contents are null.
    The received (in Java) object's length is correct.
    If I only have a 2d array, I do not encounter a problem.
    // Create the class
    jclass intClass = env->FindClass("[I");
    // Create 1st and 2nd array
    jobjectArray array1 = env-> NewObjectArray(30, intClass, NULL)
    jobjectArray array2 = env-> NewObjectArray(2, intClass, NULL)
    // Create 3rd Array
    jintArray array3 = env->NewIntArray(100);
    // Put some data into array3
    env-> SetIntArrayRegion(array3 , 0, 1, myBuffer);
    // Add array 3 to array 2 and array 2 to array 1
    env->SetObjectArrayElement(array2 , 0, array3);
    env->SetObjectArrayElement(array1 , 0, array2 );
    // Call the Java method
    env->CallVoidMethod(obj, mid, array1 )I have checked before calling the Java method that all 3 arrays are created and have the correct sizes.
    The example in Sheng Liang's book is only for 2d Arrays.
    Any ideas ?
    Many thanks.
    Andy

    Hi,
    I'm not very aware of arrays under JNI but I thought the number of [ were the number of dimension :
    // Create the class
    jclass intClass = env->FindClass("[[[I");--Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Cloning multi-dimensional arrays

    I am working on this program of mine and really need some help since I am completely stuck, the thing is that I am trying to clone a multi-dimensional array, I have tried with a simple array and that worked fine, but not with the multi-dimensional. Like this:
    int[] initialSquareValues3 = {1,2,3};
    int[] squareValues3 = initialSquareValues3.clone();
    System.out.println(initialSquareValues3[0]);
    System.out.println(squareValues3[0]);
    squareValues3[0] = 3;
    System.out.println(initialSquareValues3[0]);
    System.out.println(squareValues3[0]);
    Will give the output "1 1 1 3", just what i want. While this:
    int[][] initialSquareValues2 = {{1,2,3}, {4,5,6}, {7,8,9}};
    int[][] squareValues2 = initialSquareValues2.clone();
    System.out.println(initialSquareValues2[0][0]);
    System.out.println(squareValues2[0][0]);
    squareValues2[0][0] = 3;
    System.out.println(initialSquareValues2[0][0]);
    System.out.println(squareValues2[0][0]);
    Will give the output "1 1 3 3" where "squareValues2" only seems to be a reference to the same data as the original "initialSquareValues2"
    So the question is simply: How do i clone a multi-dimensional array?
    I'm running Java SE 5.0 (1.5.0) and the code is run inside the contructor in a class extending JPanel.

    No need to explicitly do any copying of elements except as part of deepening the clone.
        public int[][] cloneIntArrays(int[][] array)
            // Create shallow clone
            int[][] clonedArray = array.clone();
            // Deepen the shallow clone
            for (int index = 0; index < clonedArray.length; index++)
                clonedArray[index] = clonedArray[index].clone();
            return clonedArray;
        }

  • Error : Array constants can only be used in initializers

    Hello All,
    I am using tableview model and declared two-dimensional array.
    Getting error Array constants can only be used in initializers in the line retVal<i>[j] =  {  {  createBy,desc,dispName }  };
    String[][] retVal;
    retVal = new String[20][20]
    //Fetching IResorce propeties here
    int resourceCounter = 0;
    for (int i = 0; i < list.size(); i++) {
       for (int j = 0; j < i; j++) {
          IResource ir = list.get(i);
          createBy = ir.getCreatedBy();
          desc = ir.getDescription();
            dispName = ir.getDisplayName();
         retVal<i>[j] =  {  {  createBy,desc,dispName }  };
         resourceCounter++;
    return retVal;
    Please help me out.
    Thanks
    Risha                              }

    I created ArrayList 
    static public String[] colnames =
                   "News Title",
                   "Short Description",
                   "Published",
                   "Valid To",
                   "Read Count",
                   "Users Details",
                   "Reply" };
         public ArrayList createData() {
               ArrayList rowArrList = new ArrayList();
              ArrayList tableArrList = new ArrayList();
              String createBy = null;
              String desc = null;
              String dispName = null;
              String lastMod = null;
              String name = null;
              String resType = null;
              try {
                   com.sapportals.portal.security.usermanagement.IUser user = null;
                   user = WPUMFactory.getUserFactory().getEP5User(request.getUser());
                   IResourceContext resourceContext = new ResourceContext(user);
                   String path = "/documents/Australia/News";
                   RID rid = RID.getRID(path);
                   com.sapportals.wcm.repository.IResource res =
                        ResourceFactory.getInstance().getResource(rid, resourceContext);
                   IProperty prop = null;
                   String propValue = null;
                   PropertyName propName = null;
                   if (res != null) {
                        if (res.isCollection()) {
                             ICollection collection = (ICollection) res;
                             IResourceList list = collection.getChildren();
                             int resourceCounter = 0;
                             for (int i = 0; i < list.size(); i++) {                              
    //                              for (int j = 0; j < i; j++) {
                                       IResource ir = list.get(i);
                                       createBy = ir.getCreatedBy();
                                       desc = ir.getDescription();
                                       dispName = ir.getDisplayName();
                                       lastMod = ir.getLastModifiedBy();
                                       name = ir.getName();
                                       resType = ir.getResourceType();
                                       rowArrList.add(createBy);
                                       rowArrList.add(desc);
                                       rowArrList.add(dispName);
                                       rowArrList.add(lastMod);
                                       rowArrList.add(name);
                                       rowArrList.add(resType);
                                       tableArrList.add(i,rowArrList);
                                  //}//Inside for loop
                             }//First for loop
                        }//Inside If
              } catch (ResourceException e) {
                   // TODO Auto-generated catch block
                   response.write("Error " + e.getMessage());
              } catch (UserManagementException ex) {
                   ex.printStackTrace();
                   response.write("Error " + ex.getMessage());
              return tableArrList;
          * Constructor.
         public TableViewBean() {
              ArrayList tabArr = createData();
              String[][] data = (String[][])tabArr.toArray();          
              model = new DefaultTableViewModel(data, colnames);
    Edited by: Risha on May 26, 2011 8:52 AM

  • Messages in multi-message format can only be sent to one Adapter Engine

    Hi,
    Using XI 7.0 SPS 12 I have a scenario Single Flat File->XI->Multiple Messages to ECC.
    Due to an annoying limitation/bug in ECC we have to send workorders in to be processed as individual transactions.  This means generating seperate calls to ECC from PI.
    I've adjusted my message map (No BPM) to split the source messages out, but when it calls the XI adapter to send them to ECC I get the following:
    <!-- Technical Routing -->
    <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30"
    xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"
    SOAP:mustUnderstand="">
         <SAP:Category>XIServer</SAP:Category>
         <SAP:Code area="OUTBINDING">CO_TXT_MMF_ENGINETYPE</SAP:Code>
         <SAP:P1/>
         <SAP:P2/>
         <SAP:P3/>
         <SAP:P4/>
         <SAP:AdditionalText/>
         <SAP:ApplicationFaultMessage namespace=""/>
         <SAP:Stack>
         Messages in multi-message format can only be sent to one Adapter Engine
         </SAP:Stack>
         <SAP:Retry>M</SAP:Retry>
    </SAP:Error>
    I am generating multiple structures under
    messages/message1/xx_my_structure_repeated_at_this_level
    which gives the correct amount of payloads in moni.
    I believe this error is because the http/idoc adapters dont go through the AE and it is the AE that splits the multiple messages into individual calls.  Is there a clean workaround which doesnt involve BPM or intermediate writing to disk etc?
    Thanks
    James.
    Points awarded where appropriate.

    <i>I believe this error is because the http/idoc adapters dont go through the AE and it is the AE that splits the multiple messages into individual calls.</i>
    Perfectly correct
    <i>Is there a clean workaround which doesnt involve BPM or intermediate writing to disk etc?</i>
    May be writin a module.
    Otherwise to avoid other development time, go for BPM.
    Regards,
    Prateek

  • Use of multi-dimensional arrays in forms - forms debugger crash

    Hello All readers,
    have an issue with use of multi-dimensional arrays in forms when debugging and/or calling another form post array-population.
    USING VERSIONS: oracle forms 9.0.4, Jinitiator 1.3.1.17, oracle db 10.1
    the following code snippet works from a when-button-pressed trigger when called without the debugger. when called with the debugger it crashes when any element of the multi-dimensional associative array is accessed/populated/read. In addition, if i populate the multi-dimensional array then call a form (a msgbox form to display the arrays content as a string) it crashes too.
    declare
    type datasource_rec is record (field varchar2(32), val varchar2(3999));
    type datasource_arr is table of datasource_rec index by binary_integer;
    type datasource_arr_arr is table of datasource_arr index by binary_integer;
         l_arr datasource_arr_arr;
         procedure poparr(i_arr out datasource_arr_arr) is
              idx binary_integer := 1;
              iidx binary_integer := 1;
         begin
              while (idx <= 10) loop
                   iidx := 1;
                   while (iidx <= 10) loop     
                        i_arr(idx)(iidx).field := 'field'||to_char(iidx)||':'||to_char(idx); --# debugger crashes here with JVM aborting... message (which crashes forms builder too)
    i_arr(idx)(iidx).val := 'test value';
                   iidx := iidx+1;     
                   end loop;
              idx := idx+1;
              end loop;
         end;
         procedure printarr is
              idx binary_integer := l_arr.first;
              iidx binary_integer;
              l_msg varchar2(4000);
              l_response pls_integer;
         begin
              while (idx is NOT null) loop
                   iidx := l_arr(idx).first;
                   while (iidx is NOT null) loop
                        l_msg := l_msg||chr(10)||l_arr(iidx)(idx).field||' = '||l_arr(iidx)(idx).val;
                   iidx := l_arr(idx).next(iidx);
                   end loop;
              idx := l_arr.next(idx);
              end loop;
              alerts.info('see console for full printout: '||chr(10)||l_msg);
    --l_response := msgbox.show(l_msg); --calls another modal form to display a long message, which crashes the runtime with a java console message*
         r$debug.print(l_msg);
         end;
    begin
         poparr(l_arr);
         printarr;
    end;
    The java console does not print anything useful when both forms builder and the runtime crash/hangs as a result of the debugger being attached (except displaying a "JVM aborting" message) but when the runtime alone crashes as a result of calling another form after popping the MD array it prints:
    oracle.forms.net.ConnectionException: Forms session <28> aborted: unable to communicate with runtime process.
         at oracle.forms.net.ConnectionException.createConnectionException(Unknown Source)
         at oracle.forms.net.HTTPNStream.getResponse(Unknown Source)
         at oracle.forms.net.HTTPNStream.doFlush(Unknown Source)
         at oracle.forms.net.HTTPNStream.flush(Unknown Source)
         at java.io.DataOutputStream.flush(Unknown Source)
         at oracle.forms.net.StreamMessageWriter.run(Unknown Source)
    has anyone else encountered this problem and found a solution/workaround? is their some sort of memory limitation for forms-side handling of (multi-dimensional) arrays?+
    many thanks
    ps: i get similar problems when a) populating the array from a server/db-side packaged procedure (crashes with java console message as above even when not debugging) b) using server/db-side packaged types for the array.

    Hello All readers,
    have an issue with use of multi-dimensional arrays in forms when debugging and/or calling another form post array-population.
    USING VERSIONS: oracle forms 9.0.4, Jinitiator 1.3.1.17, oracle db 10.1
    the following code snippet works from a when-button-pressed trigger when called without the debugger. when called with the debugger it crashes when any element of the multi-dimensional associative array is accessed/populated/read. In addition, if i populate the multi-dimensional array then call a form (a msgbox form to display the arrays content as a string) it crashes too.
    declare
    type datasource_rec is record (field varchar2(32), val varchar2(3999));
    type datasource_arr is table of datasource_rec index by binary_integer;
    type datasource_arr_arr is table of datasource_arr index by binary_integer;
         l_arr datasource_arr_arr;
         procedure poparr(i_arr out datasource_arr_arr) is
              idx binary_integer := 1;
              iidx binary_integer := 1;
         begin
              while (idx <= 10) loop
                   iidx := 1;
                   while (iidx <= 10) loop     
                        i_arr(idx)(iidx).field := 'field'||to_char(iidx)||':'||to_char(idx); --# debugger crashes here with JVM aborting... message (which crashes forms builder too)
    i_arr(idx)(iidx).val := 'test value';
                   iidx := iidx+1;     
                   end loop;
              idx := idx+1;
              end loop;
         end;
         procedure printarr is
              idx binary_integer := l_arr.first;
              iidx binary_integer;
              l_msg varchar2(4000);
              l_response pls_integer;
         begin
              while (idx is NOT null) loop
                   iidx := l_arr(idx).first;
                   while (iidx is NOT null) loop
                        l_msg := l_msg||chr(10)||l_arr(iidx)(idx).field||' = '||l_arr(iidx)(idx).val;
                   iidx := l_arr(idx).next(iidx);
                   end loop;
              idx := l_arr.next(idx);
              end loop;
              alerts.info('see console for full printout: '||chr(10)||l_msg);
    --l_response := msgbox.show(l_msg); --calls another modal form to display a long message, which crashes the runtime with a java console message*
         r$debug.print(l_msg);
         end;
    begin
         poparr(l_arr);
         printarr;
    end;
    The java console does not print anything useful when both forms builder and the runtime crash/hangs as a result of the debugger being attached (except displaying a "JVM aborting" message) but when the runtime alone crashes as a result of calling another form after popping the MD array it prints:
    oracle.forms.net.ConnectionException: Forms session <28> aborted: unable to communicate with runtime process.
         at oracle.forms.net.ConnectionException.createConnectionException(Unknown Source)
         at oracle.forms.net.HTTPNStream.getResponse(Unknown Source)
         at oracle.forms.net.HTTPNStream.doFlush(Unknown Source)
         at oracle.forms.net.HTTPNStream.flush(Unknown Source)
         at java.io.DataOutputStream.flush(Unknown Source)
         at oracle.forms.net.StreamMessageWriter.run(Unknown Source)
    has anyone else encountered this problem and found a solution/workaround? is their some sort of memory limitation for forms-side handling of (multi-dimensional) arrays?+
    many thanks
    ps: i get similar problems when a) populating the array from a server/db-side packaged procedure (crashes with java console message as above even when not debugging) b) using server/db-side packaged types for the array.

  • Multi-dimensional arrays with non-specified dimension

    Hi all,
    I'm trying to write a method to create a multi-dimensional array of
    Integer, based on another one, taken as parameter. I would like the
    method to work for an array of a non-specified dimension, that is,
    it could take as parameter a Integer[], or a Integer[][], or a
    Integer[][][] and so on.
    The idea is to have as a result an array with the original elements
    doubled.
    Here is my recursive function:
        public static Object[] f(Object[] a) {
             // the array to be returned is created with the
             // same size as the original
            Object[] r = new Object[a.length];
            for (int i=0; i<a.length; i++) {
                Object elem = a;
    Object newElem = null;
    if (elem instanceof Object[]) {
    // Recursive case
    newElem = f((Object[]) elem);
    } else if (elem instanceof Integer) {
    // Base case
    newElem = new Integer(((Integer)elem).intValue() * 2);
    r[i] = newElem;
    return r;
    This method returns an array with the same structure (that is, same
    dimensions) of the array taken in the constructor. In the recursive
    case, it just calls the function to the inner arrays. In the base
    case, where I have an Integer, it creates a new Integer, whose
    value is the old multiplied by 2.
    Then I initialize an array:
        public static void main(String args[]) throws Exception {
            Integer[][] a = new Integer[][] {
                new Integer[] {
                    new Integer(0), new Integer(2)
                new Integer[] {
                    new Integer(1), new Integer(4), new Integer(3)
      // And try to call the function like this:
            Integer [][] b = (Integer [][]) f(a);
        }   And I get a java.lang.ClassCastException: [Ljava.lang.Object;
    I don't understand the reason of this exception, because the
    object returned is a Integer[][]. Isn't it?
    And since I don't have a compiler error in the cast, that means
    that Object[] and Integer[][] are not inconvertible. Right?
    Could anyone explain me why this is wrong and/or give me some
    ideas to do what I'm trying to do?
    Thanks a lot,
    Angela

    I retract my previous statement about using
    reflection. Use "Object[] r =(Object[])a.clone()"
    to create a new array of the same type.You don't need temporary array variable here.
    You could simply use argument a instead of r.
    (But this my gotcha is derived from your clever rep.)Well, this isn't a temporary variable, its the return variable, which is different. If you don't want the original matrix changed, you have to clone the argument.

  • Read file into multi-dimensional array - ideal world...

    Hello all, would be very grateful if you could help me...
    I have a file which has a format...
    string1a,string1b
    string2a,string2bi need to read this file, which will have a variable length, into a two dimensional array.
    the code below is just demonstrating my approach...
              List lines = new ArrayList();
              BufferedReader in = new BufferedReader(new FileReader(filename));
              String str;
              while ((str = in.readLine()) != null) {
                   lines.add(str.split(","));
              in.close();but when i later try and invoke the toArray() method of lines it complains about unsafe or unchecked operations.
    does any have any pointers about the best way to read a file into a multi-dimensional array? is it best practice to use the interface List?
    thanks in advance
    poncenby

    This is just a List of Lists - no worries there.
    Sounds like your toArray code is incorrect. Post that.
    %

Maybe you are looking for

  • Problem with Zhuyin input in Mountain Lion

    Zhuyin input from Lion to Mountain Lion is uncomfortably differently. If you type a wrong word by mistake the dictionary would remember the wrong word and you could not override the auto-fix by typing the right word like in Lion. For example, if I ty

  • Account Assignment in the Purchase order

    Hi I am trying to create Purchase order with Account assignment category "Q"  wherein system displays a GL account (4011100) which is mapped in the OBYC in the transaction GBB and general modification VBR. Further when I enter WBS element, it changes

  • Unable to sign forms

    I created several forms in acrobat X pro; however, several people are not able to sign the documents. The signature box is selected, but they cannot enter any text. I had them download the latest version of reader, but that is not helping. Appreciate

  • Device CALs User CALs?

    This CAL thing is throwing me for a loop and maybe someone can help me out. I'll lay out my network first.  I have 2 server currently, one is SBS 2008 and one is Server 2008 R2.  I plan on updating them to Server 2012 Standard.   The networks I have

  • Why doesn't the downloads window in firefox 3.6.25 display all downloads?

    whenever i download a web page or attachment, the downloads window in firefox 3.6.25 remains blank. the tools' options are set to "show the downloads window when downloading a file." the only other option checked is "save files to" but the browse but