Objects (leafs) in Objects (Nodes) in JTree ?

i have Vector a from (Class 1)Objects, each includes Vector b from (Class 2)Objects.
when i pass the Vector a to the JTree i see the (Class 1)Objects as Leafs. but i want to see them as Nodes and the (Class 2)Objects as children for the Nodes.
how to do it?

Hi Satya,
You need to choose the Infoarea while installing the BI content , sothat the Object will sit properly
Alternatively you can simple drag and drop the Object in the desired Infoarea you need , its very simple
Hope this helps ,
Sathya

Similar Messages

  • Confining objects to a particular node in a distributed cluster

    I have a partitioned cache for a cluster and there are n nodes(jvm instance) within that particular cluster. Both the data and backup data are randomly and evenly spread accross different nodes. Is there any way to put a constraint based on the cached object value (eg object with value >5) or the newly cached object should always reside in a particular node? Is partitioned near cache supports that facility? I want that object to be loaded in a particular user preffered node for the first time itself irrespective of where it is referred?

    Hi,
    there is support to a somewhat similar functionality, but it is impossible to exactly achieve what you want.
    First of all, Coherence places and locates objects in the partitioned caches (distributed cache and near cache are partitioned caches) strictly based on the key. So it is impossible to achieve data placement based on any part of the value. Placement can depend only based on the key.
    Second: when nodes come and go, data in a partitioned cache moves around with the granularity of these movements being the partition. There is a way to influence which partition a specific key ends up or rather to influence that certain keys end up in the same partition, but the placement of partitions on nodes is not static, it varies over time. However you can determine which node a certain partition resides at the time of asking. Of course it might change right afterwards :-).
    So what you can do is you can ensure that groups of your keys end up on the same partition and hence they always reside on the same node.
    To achieve this either your keys must implement KeyAssociation or you must define a KeyAssociator instance for your cache. When this is done, then you can optimize your queries and aggregations by using the KeyAssociatedFilter or PartitionFilter to execute only on certain nodes or partitions.
    For more about this, look at the following Wiki page:
    http://wiki.tangosol.com/display/COH34UG/Data+Affinity
    Best regards,
    Robert

  • How to show only all children of selected node in JTree??

    Dear friends:
    I have Two Panels, PA and PB,
    PA has a Jtree as code below, and PB listens to PA,
    I hope to do following,
    If I select a node called A in PA, then Node A's all children such as A1, A2, A3 will be displayed in PB, but not display A1, A2, A3's children such as A3 has C1, C2, C3, C4 & C5, until I select A3 then PB will display only all A3's children: C1, C2, C3, C4 & C5;
    i.e, only populate each ONE level of children of Node A or any node I select, not its grandchildren and its grand-grand children;
    Please help how to do it??
    I tried amny times, failed.
    Thanks
    [1]. PA panel code:
    package com.atest;
         import java.awt.BorderLayout;
         import java.awt.event.MouseAdapter;
         import java.awt.event.MouseEvent;
         import java.util.Enumeration;
         import java.awt.Dimension;
         import javax.swing.JFrame;
         import javax.swing.JPanel;
         import javax.swing.JScrollPane;
         import javax.swing.JTextField;
         import javax.swing.JTree;
         import javax.swing.tree.DefaultMutableTreeNode;
         import javax.swing.tree.TreeModel;
         import javax.swing.tree.TreePath;
         public class DefaultMutableTreeMain extends JPanel {
         protected DefaultMutableTreeNode    top = new DefaultMutableTreeNode("Options");
         protected DefaultMutableTreeNode      selectedNode = null;
         protected final JTree tree;
         protected final JTextField jtf;
        protected Enumeration      vEnum = null;
         private      TreeModel                m;
         protected  DefaultMutableTreeNode      getDefaultMutableTreeNode()  {
              //textArea.getText();
                   return selectedNode;
         protected  DefaultMutableTreeNode setDefaultMutableTreeNode(DefaultMutableTreeNode tt)  {
              //textArea.getText();
                   selectedNode = tt;
                   return selectedNode;
         protected  TreeModel getJTModel()  {
              //textArea.getText();
                   return m;
         protected  TreeModel setJTModel(TreeModel ta)  {
                   m = ta;
                   return m;
           public DefaultMutableTreeMain() {
             setSize(300,300);
             setLayout(new BorderLayout());
             DefaultMutableTreeNode a = new DefaultMutableTreeNode("A");
             top.add(a);
             DefaultMutableTreeNode a1 = new DefaultMutableTreeNode("A1");
             a.add(a1);
             DefaultMutableTreeNode a2 = new DefaultMutableTreeNode("A2");
             a.add(a2);
             DefaultMutableTreeNode a3 = new DefaultMutableTreeNode("A3");
             a.add(a3);
             DefaultMutableTreeNode b = new DefaultMutableTreeNode("B");
             top.add(b);
             DefaultMutableTreeNode b1 = new DefaultMutableTreeNode("B1");
             b.add(b1);
             DefaultMutableTreeNode b2 = new DefaultMutableTreeNode("B2");
             b.add(b2);
             DefaultMutableTreeNode b3 = new DefaultMutableTreeNode("B3");
             b.add(b3);
             DefaultMutableTreeNode c = new DefaultMutableTreeNode("C");
             a3.add(c);
             DefaultMutableTreeNode c1 = new DefaultMutableTreeNode("C1");
             c.add(c1);
             DefaultMutableTreeNode c2 = new DefaultMutableTreeNode("C2");
             c.add(c2);
             DefaultMutableTreeNode c3 = new DefaultMutableTreeNode("C3");
             c.add(c3);
             DefaultMutableTreeNode c4 = new DefaultMutableTreeNode("C4");
             c.add(c4);
             DefaultMutableTreeNode c5 = new DefaultMutableTreeNode("C5");
             c.add(c5);
             tree = new JTree(top);
             JScrollPane jsp = new JScrollPane(tree);
             jsp.setPreferredSize(new Dimension(400,300));
             add(jsp, BorderLayout.CENTER);
             jtf = new JTextField("", 20);
             add(jtf, BorderLayout.SOUTH);
               tree.addMouseListener(new MouseAdapter() {
               public void mouseClicked(MouseEvent me) {
                  TreePath   path = tree.getSelectionPath();
                  DefaultMutableTreeNode      selectedNode = (DefaultMutableTreeNode)path.getLastPathComponent();
                 TreePath tp = tree.getPathForLocation(me.getX(), me.getY());
                 setDefaultMutableTreeNode(selectedNode);
                     System.out.println("Current node selected is (tp.toString()=" + tp.toString());
                     System.out.println("Current node selected is getDefaultMutableTreeNode()=" + getDefaultMutableTreeNode());
                 if (tp != null){
                     jtf.setText(tp.toString());
                      System.out.println("It Has Children as selectedNode.getChildCount()= " + selectedNode.getChildCount());
                            Enumeration vEnum = selectedNode.children();
                                int i = 0;
                                while(vEnum.hasMoreElements()){
                                    System.out.println("2 selectedNode = " +  path.toString() + "  has " + i++ + " Children in vEnum.nextElement(" + i + ") = " + vEnum.nextElement());
                 else
                   jtf.setText("");
           public static void main(String[] args) {
             JFrame frame = new JFrame();
             frame.getContentPane().add(new DefaultMutableTreeMain());
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             frame.setSize(400, 400);
             frame.setVisible(true);
         }[2]. PB Panel code
    package com.atest;
    import java.awt.BorderLayout;
    import javax.swing.JScrollPane;
    import javax.swing.JTree;
    import javax.swing.JPanel;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.*;
    import javax.swing.JButton;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreePath;
    public class DefaultMutableTreeSub extends JPanel implements java.io.Serializable{
      private JButton removeButton;
      private JButton addButton;
      JTree tree;
      private TreeModel      m;
      protected TreeDragSource ds;
      protected TreeDropTarget dt;
    protected  TreeModel getJTModel()  {
              //textArea.getText();
                   return m;
    protected  TreeModel setJTModel(TreeModel ta)  {
                   m = ta;
                   return m;
    protected DefaultTreeModel model;
    protected DefaultMutableTreeNode rootNode;
    DefaultMutableTreeMain dmm = null;
    JPanel inputPanel  = new JPanel();
      public JPanel SLTreeDNDEditableDynamic(DefaultMutableTreeMain tdnd ) {
        //super("Rearrangeable Tree");
        setSize(400,450);
        dmm = tdnd;
             setLayout(new BorderLayout());
             inputPanel.setLayout(new BorderLayout());
             JPanel outputPanel = new JPanel();
             System.out.println("Sub selectedNode tdnd= " + tdnd);
             tdnd.tree.addTreeSelectionListener(new TreeSelectionListener(){
                  public void valueChanged(TreeSelectionEvent evt){
                  TreePath[] paths = evt.getPaths();
                  TreePath   path = dmm.tree.getSelectionPath();
                  DefaultMutableTreeNode      selectedNode = (DefaultMutableTreeNode)path.getLastPathComponent();
                 DefaultMutableTreeNode itemNode = dmm.getDefaultMutableTreeNode();
                     System.out.println("Sub node selected is dmm.getDefaultMutableTreeNode()=" + dmm.getDefaultMutableTreeNode());
                  model = new DefaultTreeModel(itemNode);
                  tree = new JTree(model);
                  System.out.println("Sub selectedNode paths= " + paths);
                  System.out.println("Sub selectedNode path= " + path);
                  System.out.println("Sub selectedNode = " + selectedNode);
                  System.out.println("Sub itemNode = " + itemNode);
                  tree.putClientProperty("JTree.lineStyle", "Angled");
                  tree.setRootVisible(true);
                   inputPanel.add(new JScrollPane(tree),BorderLayout.CENTER);
             return inputPanel;
         public DefaultMutableTreeSub() {
              super();
    }thanks
    sunny

    Thanks so much, I use your code and import followig:
    import java.util.ArrayList;
    import java.awt.List;
    but
    private static List<Object> getChildNodes(JTree j) {
         Object parent = j.getLastSelectedPathComponent();
         int childNodeCount = j.getModel().getChildCount(parent);
         List<Object> results = new ArrayList()<Object>;
         for (i = 0; i < childNodeCount; i++) {
              results.add(parent, i);
         return results;
    here List<Object> and ArrayList()<Object> show red,
    Is my JDK version problem??
    my one is JKD
    C:\temp\swing>java -version
    java version "1.4.2_08"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
    Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
    Error as follows:
    C:\temp\swing>javac DefaultMutableTreeSub.java
    DefaultMutableTreeSub.java:38: <identifier> expected
    private static List<Object> getChildNodes(JTree j) {
    ^
    1 error
    any idea??
    Thanks

  • Read child nodes in Jtree

    Need some help in reading the child nodes in a jTree after a parent node has been selected.
    I've created a Jtree using DefaultMutableTreeNode. When I select a node, I'm able to read the contents of that node but can't figure out how to read all the children beneath it.
    I'm using this code to read the current selected path:
    TreePath tp1 = jTreeTOC.getSelectionPath();
    Object bal_Grp[] = tp1.getPath();
    int iNodeCnt = bal_Grp.length;
    if (iNodeCnt > 1) {
    String sTOCNode = bal_Grp[iNodeCnt-1].toString();
    So my sTOCNode is the selected one, now how do I get the children.
    Any help is appreciated.
    Thanks

    Read the tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html#select
    If you use getLastSelectedPathComponent you get back DefaultMutableTreeNode object of the selected node.
    You can use it to get the children of the selected node.

  • Add node to JTree

    I have an already populated JTree. At Runtime I add one or more node to JTree, using something like
    parentNode.add(newNode)....
    If I call a repaint method, the new node isn't visible, I have to reload model using
    DefaultTreeModel dtm = ((DefaultTreeModel)myTree.getModel());
    TreeNode rootNode = (TreeNode) dtm.getRoot();
    dtm.reload(rootNode);
    Unfortunately this method cause the lost of focus on the currently selected node and the collapse of all JTree around its root node; If I change an existing node (for example changing its text or icon) I must reload the model too!!!
    Does exist an other more "soft" method to change the aspect of a JTree without reload the entire model?

    You must use or implement the
        public void valueForPathChanged(javax.swing.tree.TreePath path,java.lang.Object newNode) {
            Object[]    p = path.getPath();
            Object[]    pp = p;
            //insert node here
            int[] ci = new int[] {index};
            Object[] cc = new Object[] {node};
            fireTreeNodesChanged(this, pp, ci, cc);
            fireTreeStructureChanged(this, pp, ci, cc);
        }from the TreeModel. To fire the last two is essensial.
    I implemented a GP in JAVA so i had the same problem wehn i started.

  • How to add  z object to root object in BOL

    hi,
    I have to add my z object to BuilStandardAddress (standard object for BP Address ).I hav created a external object by using ztable.I can see that object in transaction GENIL_MODEL_BROWSER as a Root Object but I hav to add this object as dependent object under BuilStandardAddress .
    Please suggest any possible solution for this.
    Thanks in Advance.
    Hem

    hi carsten,
    Thanks a lot for reply.
    Acc to my opinion there is 2 method first one is enhance standard implementaion class.
    second one is to use this class.CL_CRM_GENIL_GEN_TABLE_OBJ
    I opt. second mehtod:
    Actually ,Our requirement is that we hav to add some custom  fields in addresss view.If weadd custom fields through EEWB then it adds fields to builheader rather then standard address.To achieve this I have created a external object and assign a impleimentation class (CL_CRM_GENIL_GEN_TABLE_OBJ). after this I hav define Object defination in which I define this object as dependent object of builstandardaddress.and give my z table name.After that I hav define Model defination in which i hav define relationship.By doing this I am able to use my object in view.Now I added this z attribute to the standardaddress node of standaddress view of component BP_ADDR.
    Now, I can see this field on UI screen but My Implementation Class has some methods(like modify, Save )that will save the data in z table.these methods are not calling at runtime.
    Plz suggest any solution
    Hem
    Edited by: janawa hemlata on Dec 4, 2008 7:31 AM

  • Replacing nodes in JTree

    Hi,
    The following situation: I have a split pane with a tree view on the left and a panel on the right displaying detailed information related to the selected node in the tree. However, some nodes in the tree do not have associated any detailed information to them, they just hold a String object. Precisely, such nodes are containing nodes (folders, if you want), which have child nodes.
    What I want to do?
    It might happen during runtime of the program that such a containing node needs to be "enriched" with detailed information, which obviously should be displayed in the detail panel on selection of the node. This detailed information comes from an object which should replace the String object hold by the node.
    According to you, what is the best way to do that? Do I have to replace the node holding the String with a node holding the new object (I read some posts and articles that this is a difficult task), or can I just change the object behind the node from String to the new object?
    I'd be really thankful for any tip, since I'm not so experienced in Swing :-)
    Thank you!

    vexity wrote:
    well i didn't run the program Yeah, I know, because you have syntax errors. You can get descriptive messages for those sytax errors that you can copy and paste here.
         Incompatible operand types IntList.IntNode and int
         Type mismatch: cannot convert from int to IntList.IntNode
         at IntList.replace(IntList.java:157)
         at IntListTest.dispatch(IntListTest.java:84)
         at IntListTest.main(IntListTest.java:25)
    Yeah, like that. That's what we want to see.
    But as I already told you, the problem is that you're trying to mix ints and IntNodes.
    What should i do to solve this problem?Use ints where appropriae, IntNodes where appropriate, and convert between the two when you need to. You do know how to create an IntNode from an int, and how to get an int out of an IntNode, right?

  • Object Group Vs Object Libraries

    Hi ,
    I have not used Object Groups and Object Libraries extensively....and am trying to understand them
    Having read the form builder help ,I am still not clear with the following.
    My questions are as follows
    1)When should I be giving preference to Object Group over OBL?
    2)Why will i use an Object Group ,when an object group's object is just a pointer to the
    object in the form module?
    Grouping of similar objects for one single form module only,does'nt provide me much benefits?
    3)How will I reference an Object group's object and not a form's object which I have
    moved into the object group and vice versa?
    4)OBL module has a data block(say emp) as one of its many object,
    how can I use this data block in my new forms module(will I be copying this data block
    object from the attached OBL to the data block node of the form module in OBJECT navigator?).
    will i have to create a Layout manually if I use the data block of OBL or will forms
    builder automatically create a layout for this OBL data block.?
    5)What are the types of objects which CANNOT be included in OBL and Object groups?
    I am aware that I can't include an item of a data block if i don't include the data block itself.
    rgds
    s

    Hi,
    WIP  wrote:
    Hi ,
    I have not used Object Groups and Object Libraries extensively....and am trying to understand them
    Having read the form builder help ,I am still not clear with the following.
    My questions are as follows
    1)When should I be giving preference to Object Group over OBL?Depends on the requirement. The objects in the Object group are limited to the current form module. However, Object libraries can be used across the forms. Of course, you can subclass this object group in other modules.
    >
    2)Why will i use an Object Group ,when an object group's object is just a pointer to the
    object in the form module?Its like a template. You define set of properties (say width, height and font for a text item), and then subclass the object to all the object you create in your form. So, they all will look similar. Also, once after creating the object group, you can add the object group to the object library. This can be very useful.
    Grouping of similar objects for one single form module only,does'nt provide me much benefits?
    So, here we use Object Library
    3)How will I reference an Object group's object and not a form's object which I have
    moved into the object group and vice versa?
    You cannot reference the individual objects in the object groups.
    4)OBL module has a data block(say emp) as one of its many object,
    how can I use this data block in my new forms module(will I be copying this data block
    object from the attached OBL to the data block node of the form module in OBJECT navigator?).
    will i have to create a Layout manually if I use the data block of OBL or will forms
    builder automatically create a layout for this OBL data block.?You can add all the Blocks, canvaces, etc to the Object grou, add the object group to the object library. Then, if you just copy/subclass the object group from the Object library, all the blocks, items, canvaces would be created automatically in the target form.
    >
    5)What are the types of objects which CANNOT be included in OBL and Object groups?
    I am aware that I can't include an item of a data block if i don't include the data block itself.
    Only the Parent objects can be included in the Object Group (Child objects cannot). However, in the Object Library, you can add the parent as well as child objects. Here, for ex, parent is a data block and child are the items inside the data block
    -Arun
    >
    rgds
    s

  • Using null for parameterized "newInstance(Object [])" method in Object[].

    I have a really serious problem. I am creating instances of specific classes by using reflection techniques. I am reading a flat file, finding class from its name and creating it by using its parameterized constructor. Example:
    line 1: Dummy("A",Dummy2("B"),12,,"C");
    I create an instance of Dummy with parameters "A", an instance of Dummy2 object with value "B", 12 (I use here Integer as wrapper), null (There is no wrapper for null :( ) and "C".
    I find constructor by using findConstructors() and looking their parameter counts, creating an object array with given values and calling:
    constructorIFoundBefore.newInstance(objectArrayIPrepared);
    But!!!
    Because I use null directly, I got this message:
    java.lang.IllegalArgumentException: argument type mismatch
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
         at reader.parser.ObjectCreator.createObjectFromObjectItem(ObjectCreator.java:192)
         at reader.parser.ObjectCreator.createObjectFromParseItem(ObjectCreator.java:112)
         at reader.parser.ObjectCreator.createObject(ObjectCreator.java:78)
         at reader.analyzer.FileAnalyzer.analyzeAndCreateObjects(FileAnalyzer.java:95)
         at reader.ReverseReader.main(ReverseReader.java:43)
    I will be very glad if you help me.
    Thanks a lot!
    Gokcer

    I said something wrong. Sorry. While invoking a method (or a constructor) we need an object array which are equivalent to parameters. For example to call a method or constructor for class A;
    class A {
    int age;
    String name;
    public A(int age, String name){
    this.age = age;
    this.name = name;
    public set(int age, String name){
    this.age = age;
    this.name = name;
    we use in any place
    A a1 = new A(12,"Gokcer");
    A a2 = new A(15,null);
    To achieve this by using reflection techniques, we must find constructor with two parameters of class A. At this point "BetterMethodFinder" will give great help.
    After finding right constructor, we must create an object array to tell the constructor parameters (age and name). At this point we need an object array which stores our parameters. Code must be like this.
    Object []params = new Object[2]; // we have two parameters.
    params[0] = new Integer(12); // we can't use params[0]=12
    // because 12 is not an object. (It is a
    // primitive type)
    params[1] = "Gokcer";
    Now create the new object.
    A a1;
    a1 = constructorWeFound.newInstance(params);
    While creating param[], we could also use:
    Object []params = new Object[2] {new Integer(12),"Gokcer"};
    While creating a2, we can use "null" directly for second parameter.
    params = new Object[2] = {new Integer(15), null};
    or
    Object []params = new Object[2];
    params[0] = new Integer(15);params[1] = null;
    Thanks again everyone who replied me.
    My sincerely...

  • Design Problem: Object reference another object at different states

    Hi,
    This is a problem I came across today while developing a simple prototype. Imagine I have a class Boy which has a one-to-many relation with a class Dog.
    The class Boy has the following methods: getName(), setName(), getAge(), setAge(), getDogs().
    The class Dog has the following methods: getName(), getOwner()
    When the application starts I load a Boy from the database as follows:
    Boy peter = BoyFactory.loadBoyByName("Peter");
    peter.setAge(10);
    I then add peter to a static list which can be accessed from everywhere within my application.
    At a different stage in the application I want to load a dog (just a dog). So I use the following code:
    Dog dog = DogFactory.loadDogByOwnerName("Peter");
    The dog object (using JDO or Hibernate) would also have a reference to the Boy object. However when calling the getOwner() method, the boy returned will not be the same boy stored in that static list (I expect the age, which was not persisted in the database, to be different).
    Is there a way how when loading the Dog object, since its Owner of type Boy is already loaded in my object model, a Framework such as Hibernate or JDO will use this object rather then re-build a new one.
    I am planning to use either Hibernate or some JDO framework and that is why I am asking this question.
    If I where going to use some custom made way to load Dog then I would just search if the Owner was in that static list and if yes then set the owner of the dog equal to the object found in the static list.
    However I was wondering if there is some design I should consider (study) to handle such a problem.
    Thanks and Regards,
    Sim085

    Thanks uj :) I had another thought...
    I will give another scenario so things are more clear.
    Imagine having a class Teacher which has one-to-many relation with a class Student.
    If you where programming the classes for these two entities then would you program the student class as follows:class Student{
    Teacher t = null;
    void setTeacher(Teacher t){...}
    Teacher getTeacher(){...}
    }ORclass Student{
    int teacherId = -1;
    void setTeacherId(int tId){...}
    int getTeacherId(){...}
    }The difference between these two methods is that in the first method, if I wanted to know the teacher of a student then I would only have to call the getTeacher() method while using the second design I would first need to get the teacher Id and then make a database call to actually get the Teacher object (or else get it from a static list where the teacher could be saved.
    Personally I prefer the first method since I like to have an object model where objects are directly linked with other rather then linked through some form of id. However I do not know which design is best to use...
    Thanks
    Sim085

  • How to get attribute value from an object inside an object in Xpress

    Does anyone know how to get an attribute value from an object in Xpress in a workflow? I have an object structured as follows:
    <ResourceInfo accountId='mj628' tempId='3483372b787ce7dd:-5d99a0c5:130cb238483:-3600'>
    <ObjectRef type='Resource' name='Google Apps'/>
    </ResourceInfo>
    I need if possible to get the name='Google Apps', which is inside the ObjectRef, so I guess its an attribute value of an object inside an object.

    If the ResourceInfo object is accessible in a variable, i.e. named "myResInfo", you just have to check the Java API and call the relevant method:
    <invoke name='getResourceName'>
      <ref>myResInfo</ref>
    </invoke>

  • How to get the values of the objects inside an object??

    Hi,
    I am trying to write code to display name and memory usage of all session attributes, in a recursive way.
    I suppose reflection is needed here, but I can’t figure out how to get the values of the objects inside an object...
    private void handleIt(String attributeName, Object attributeValue) {
         boolean isPrimitiveOrNull = ((null == attributeValue) ||
              (attributeValue.getClass().isPrimitive()));                                         
         if (isPrimitiveOrNull) {
              sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "}");
         } else {
              sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "{");               
              Field[] fields = attributeValue.getClass().getDeclaredFields();
              int lim = fields.length;
              String name;
              Object value = null;
              for (int i = 0; i < lim; i++) {
                   name = fields.getName();
                   //LOOK AT THIS LINE: !!!!!!!!!!!!!!!!!!!!!!!!!!!
                   value = fields[i].get(obj); //I don´t know what 'obj' should be??
                   handleIt(name, value);
              sb.append("}");               
    Any suggestions will be greatly appreciated...

    I realized that massive int objects called MAX_VALUE, MIN_VALUE and SIZE where causing the StackOverflow, so I removed them from the analysis.
    This is the resultant code. But I think it isn’t accurate in calculating the real size of objects being got using reflexion.
    Do you or somebody have any more suggestions?
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.ObjectOutputStream;
    import java.lang.reflect.Field;
    import java.util.Enumeration;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    public class SessionMeasurer extends HttpServlet {
         private static final long serialVersionUID = 1470488362727841992L;
         private StringBuilder sb = new StringBuilder();
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              performTask(request, response);
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              performTask(request, response);
         public void performTask(HttpServletRequest request, HttpServletResponse response) {
              HttpSession     session = request.getSession(false);     
              String attributeName = "";
              Object attributeValue = null;
              for (Enumeration<?> attributeNames = session.getAttributeNames(); attributeNames.hasMoreElements();) {
                   attributeName = (String)attributeNames.nextElement();
                   attributeValue = session.getAttribute(attributeName);
                   handleIt(attributeName, attributeValue);               
              System.out.println(sb.toString());
         private void handleIt(String attributeName, Object attributeValue) {           
              if (attributeValue != null) {          
                   boolean isPrimitive = attributeValue.getClass().isPrimitive();
                   if (isPrimitive) {
                        sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "}");
                   } else {
                        sb.append("{" + attributeName + ":" + sizeOf(attributeValue) + "{");               
                        Field[] fields = attributeValue.getClass().getDeclaredFields();
                        String name;
                        Object value = null;
                        int lim = fields.length;
                        for (int i = 0; i < lim; i++) {
                             name = fields.getName();                                                                                                         
                             if (!name.endsWith("_VALUE") && !name.equals("SIZE") && !name.equals("serialVersionUID")) {
                                  try {
                                       value = fields[i].get(attributeValue);
                                  } catch(Exception e) {
                                       //PENDIENTE: Tratamiento excepción
                                  handleIt(name, value);
                        sb.append("}");               
         private int sizeOf(Object obj) {
              //Valid only for Serializables
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              ObjectOutputStream oos = null;     
              byte[] bytes = null;               
              try {          
                   oos = new ObjectOutputStream(baos);
                   oos.writeObject(obj);
                   bytes = baos.toByteArray();
              } catch(Exception e) {               
                   //PENDIENTE: Tratamiento excepción
              } finally {
                   if (oos != null) {
                        try {
                             oos.close();
                        } catch(Exception e) {
                             //PENDIENTE: Tratamiento excepción                         
                   if (baos != null) {
                        try {
                             baos.close();
                        } catch(Exception e) {
                             //PENDIENTE: Tratamiento excepción                         
              int size = -1;
              if (bytes != null) {
                   size = bytes.length;
              return size;          

  • Help needed with finding node in JTree

    Hi,
    In my application i will be entering some string data in a text box for search criteria.
    When I click on search, I will get data from database which will be shown as a JTree.
    This Jtree will have some nodes in which, node with string entered in the search text box exists.
    I need to focus on this node and I have only a string to find this node.
    How can I do this?How can I find a node in JTree using string value?
    Is there any alternate option by which I can achive my need?
    Please suggest.
    Thanks.

    @OP: please assign your dukes.
    @Andre_Uhres: if you don't get rewarded in the next couple of days, please let me know here to get at least one duke for your effort.
    Bye.

  • Error while creating Info Object in Info object catelog

    Hi experts,
    I'm making few info object in info object catelog but while activating system giving error mesage as "Error when generating master data routines"
    can any one tell what's the problem and what needs to be done.
    Sumantra

    Hi
    let me know weather r u using any reference object which contain the routinee.
    regards,
    chandra.

  • Creation of object with sub-objects in ADF Faces

    I am trying to create an object that has associated sub-objects (header/detail) using ADF Faces. The user enters the header information in an ADF Form, then he creates detail data. Example: If the object is a PO, user creates the PO header info and, in an ADF table, he creates the PO lines.
    The problem is I am not able to figure how to bind the ADF table to the object that is being created. In a normal master-detail form, you drag the associated list from the Data Control palette and JDev automatically creates an accessor iterator that "feeds off" the master iterator. But, in this case, the associated list does not appear in the data control palette. Nor am I certain that is the right thing to do, anyway.
    Help! This seems like it would be a common pattern.
    Ara

    Sorry. Here is some more information:
    1. The project is for tracking duplication jobs requests.
    2. Data Model--DocumentTicket and JobDocument objects are EJB 3.0 JPA objects. DocumentTicket has a getter (getJobDocuments) to retrieve a List<JobDocument> of related job documents. JobTicketManager is the session bean that encapsulates most business methods.
    3. I am using ADF Faces bindings to "publish" the data model to the GUI.
    4. In the GUI, I dragged/dropped the DocumentTicket constructor from the data control palette to create the document ticket. This created the appropriate method action bindings, as well as the DocumentTicketIter iterator to iterate over the constructor result.
    5. Of course, the user also needs to specify the related job documents. In the GUI, I would like to have an ADF table that displays the current job documents, and a button labeled "Add Document" that is wired to a pop-up dialog. The idea is that the user clicks on the "Add Document" button, enters the information about the new JobDocument object. The object is then created and the table is updated with a new row. The table is also used to manipulate the list of job documents (chiefly, it allows the user to change their listed order).
    Step 5 is where I am having trouble. I can see how to create the pop-up dialog, how to wire it to the JobDocument constructor, how to update the data model. The problem is: I do not know to which object I should wire the JobDocument table. Logically, I should be able to wire it to the jobDocumentList property. However, that is not displayed in the data control palette under the constructor results (it is displayed elsewhere; for example, under the result of the findAllDocumentTickets method).
    I suppose I could create a separate finder method in the session bean, but then how do I connect it to the object being constructed (i.e., to the JobDocumentIter iterator)?
    Either I am missing something here or I am hitting some limitation of the ADF binding framework.
    Ara

Maybe you are looking for

  • How do i remove an iCloud account from a previous owner on my macbook

    PLEASE HELP.  I bought a used Macbook Air for my wife and it has the previous owner's iCloud information.  When I try to remove it, it requires his passwork which I obviously do not know.  I've tried resetting his password in hopes that it would emai

  • I get an error every time i start my muvo tx

    Because i didnt shut down the muvo tx fm mp3 player properly when i was done with writing music it started to turn off whenever i turned it on. I checked the manual and it said that i had to format it, but only format FAT files only. I accidentally d

  • CUCM 10.5: User Device Profiles provisioning possible?

    Recently we've Upgraded our CUCM Cluster from 8.6.2 to 10.5 to gain some new features. In the feature list there is a lot of stuff for provisioning and making admin things easier. Right now, if there is a new employee in our company, we manually crea

  • Clock-in & clock-out in cources

    hello I want to check clock-in and  clock-out pepole for each business event type how to check it?

  • More than one print program for one sap script

    Hi Experts, I have more than one print program which is attached to one sap script. There is standard text used in the script which has variable as date, i want that date to be converted into the previous date but only for one specific print program.