JSF List implementation

I have one managed bean A which has as it's member variables ArrayList B, ArrayList C, and ArrayList D. I have methods within the managed bean A that performs operations on the three separate lists. Say for instance, whenever I want to reference the size of any of the lists from a view, I have methods within A that return the size.
I am assuming with JSF that this type of behavior can be defined some way in the faces_config.xml without actually having to define the lists and their types within the managed bean itself, but I haven't quite figured out how. I am assuming that you would define a managed bean for B, C, and D, and having A defined with lists with those types repsectively, but I'm at a loss as how. Any ideas?

Firstably what does this have to do with Java Studio Enterprise? This question is more suited for JSF forum. Anyway...
There is nothing magical about JSF and in my view it is just another way to put together servlets, JSP, taglibs and JavaBeans. In other words it does not do anything the others cannot do. You still have to load the bean using the classloader and then refer to it from the JSP page. Where you specify what bean to load, when and how is the question for the JSF forum though.
Regards jP

Similar Messages

  • Kernel list implementation

    Hi,
    Does the Solaris kernel (9 and 10) provide any sort of general list implementation that can be used for driver development? I've looked at "Writing Device Drivers", and unless I missed it, I can't find anything about such an interface in there.
    Thanks,
    Andrew

    There isn't one in the DDI. Solaris 10 has one in sys/list.h but we have not yet made it
    part of the DDI.
    -Mike

  • List implementation where remove(Object) is fast?

    Does anyone know of an implementation of the java.util.List interface where the the method boolean remove(Object o) is much faster than traversing through the list until it finds the right one? Perhaps something that takes advantage of the hash code of the object being removed?
    Thanks

    So you want a List that acts like a Map?
    Couldn't you just use a Map?
    Explain your problem domain better and we shall help
    you see the light.
    Well no - I would simply like a List that acts like a List, and whose remove(Object) method is faster than just scanning through each element.
    I only mentioned use of the hash code as one way this could be implemented. To expand on that: Currently the LinkedList class internally maintains a list of Entry objects. Each of these objects has a reference to the previous and next Entry and the 'current' list element object. The problem is that the remove(Object) method has to go through each Entry one by one, searching for a list element that equals the object to be removed. To fix this problem the list implementation could also maintain a HashMap whose 'keys' are the list elements and whose 'values' are a (secondary) list of Entry objects associated with that key. Now the remove(Object) method could use the object to be removed to look up the 'list of associated Entry objects'. The first Entry in this (secondary) list is the one that needs to be removed.
    But perhaps it's best if I describe the overlying problem: I want to write a program that randomly generates integers at the rate of about 10 per second. For each integer the program should calculate how many times in the past hour that number has been generated. What's the fastest way to calculate this?

  • Problems with List Implementation

    I have a list implementation that is like a linked list but contains 'n' elements in each node, set to 8 by default.
    The list has a head node, and a tail node.
    This is a revisit on an assignment, I'm trying to fix it.
    The problem is when a number of elements have been added and then deleted from the end of the list. Then more elements are added.
    I'm using a JUnit test case to test this, and what happens is about 25 elements are added and removed, but when it gets to adding a new elements after recently deleting some items towards the end of the list. My list fails because, I am unable to assign value to my tail from within my iterator.
    The compiletime error I get is:
    Type mismatch: cannot convert from chunklist.ChunkList<T>.Chunk<T> to chunklist.ChunkList<T>.Chunk<T>
    I need to assign my tail to the previous Chunk (node), because in my iterator when I delete a Chunk the tail doesn't get automatically assigned to the previous.
    Anyone know how I can get around this retarded error? or what I can do to solve my problem?
    Edit: casting to Chunk<T> doesn't work either it's the same compiletime error
    I have deleted all irrelevant methods and comments from this: The error is in the deleteChunk() method. I need to point tail back to the previous node there.
    package chunklist;
    import java.util.AbstractCollection;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.NoSuchElementException;
    public class ChunkList<T> extends AbstractCollection<T>
        @SuppressWarnings({ "unchecked", "hiding" })
        private class Chunk<T>
            private T[] data;
            private Chunk<T> next;
            private int chunkSize;
            public Chunk()
                this.data = (T[])new Object[ARRAY_SIZE];
                this.next = null;
                this.chunkSize = 0;
            public boolean equalsChunk(Chunk<T> c)
                if (c == null)
                    return false;
                else if (this.chunkSize != c.chunkSize)
                    return false;
                else if (this.next != c.next)
                    return false;
                else
                    for(int i=0; i<this.chunkSize; ++i)
                        if (!(this.data.equals(c.data[i])))
    return false;
    return true;
    }// end of Chunk<T>
    @SuppressWarnings({ "hiding", "unchecked" })
    private class ChunkItr<T> implements Iterator<T>
    private Chunk<T> currentChunk;
    private Chunk<T> previousChunk;
    private Chunk<T> nextChunk;
    private int currentElement;
    public ChunkItr()
    currentChunk = (Chunk<T>) head;
    previousChunk = null;
    nextChunk = (Chunk<T>) head.next;
    currentElement = 0;
    @Override
    public boolean hasNext()
    if (currentChunk == null)
    return false;
    else
    if (currentElement < currentChunk.chunkSize)
    return true;
    return (currentChunk.next != null);
    @Override
    public T next()
    if (!hasNext())
    throw new NoSuchElementException();
    T elementToReturn = null;
    while (elementToReturn == null)
    if ((currentElement == ARRAY_SIZE) ||
    (currentElement == currentChunk.chunkSize))
    previousChunk = currentChunk;
    currentChunk = currentChunk.next;
    currentElement = 0;
    if (nextChunk != null)
    nextChunk = currentChunk.next;
    if (currentChunk.data[currentElement] != null)
    elementToReturn = (T) currentChunk.data[currentElement];
    ++currentElement;
    return elementToReturn;
    @Override
    public void remove()
    if (currentChunk == null)
    throw new IllegalStateException();
    else
    for (int i=currentElement-1;i<currentChunk.chunkSize;++i)
    { // shift everything down
    if ( (i != 7) && (i >= 0) )
    currentChunk.data[i] = currentChunk.data[i+1];
    else if (i==7)
    break;
    currentChunk.data[currentChunk.chunkSize-1] = null;
    --currentChunk.chunkSize;
    --numOfElements;
    --currentElement;
    if (currentElement < 0)
    currentElement = 0;
    if (currentChunk.chunkSize <= 0)
    deleteChunk();
    public void deleteChunk()
    if (previousChunk == null) //* @head *//
    if (head.next != null)
    head = head.next;
    currentChunk = (Chunk<T>) head;
    nextChunk = currentChunk.next;
    currentElement = 0;
    else currentElement=0;
    else if (nextChunk == null) //* @tail *//
    currentChunk = previousChunk;
    currentChunk.next = null;
    nextChunk = currentChunk.next;
    currentElement = currentChunk.chunkSize;
    tail = currentChunk; // THIS DOESN'T WORK, << ERROR HERE
    else //* @middle *//
    currentChunk = currentChunk.next;
    previousChunk.next = currentChunk;
    nextChunk = currentChunk.next;
    currentElement = 0;
    // back @ head? (just deleted Chunk before head)
    if (currentChunk.equalsChunk((Chunk<T>) head))
    previousChunk = null;
    } // end ChunkItr
    private static final int ARRAY_SIZE = 8;
    private Chunk<T> head;
    private Chunk<T> tail;
    private int numOfElements;
    public ChunkList()
    head = null;
    tail = null;
    numOfElements = 0;
    public void addNewChunk()
    if (head == null)
    head = new Chunk<T>();
    tail = head;
    else
    tail.next = new Chunk<T>();
    tail = tail.next;
    @Override
    public boolean add(T t)
    if (t == null)
    throw new IllegalArgumentException();
    if (head == null)
    addNewChunk();
    if (tail.chunkSize == ARRAY_SIZE)
    addNewChunk();
    tail.data[tail.chunkSize] = t;
    numOfElements++;
    tail.chunkSize++;
    return true;
    @Override
    public Iterator<T> iterator()
    return new ChunkItr<T>();
    @Override
    public boolean remove(Object o)
    // creates iterator and calls iterators remove method when it finds o.
    Edited by: G-Unit on Nov 14, 2010 5:07 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    YoungWinston wrote:
    Possibly, but I suspect you'll need to be prepared to defend your design choice with more than just test results. Why did you choose this pattern? Because it's an assignment. I will do some reading when I get around it to it. But for now I don't have time, and don't care to make time. This assignment was annoying as... So many fiddly little errors that took me too long to figure out. For now I hate Lists, I'm happy using the default ones.
    1. Introduction
    This document is the Project Specification for a ChunkList class to be developed by DBSD202 students this semester.
    2. What you must do
    The requirements specifications are detailed below:
    ChunkList
    In this first part of the assignment we will create a data structure called a ChunkList. The ChunkList class implements the Collection interface and >>serves a replacement for ArrayList or LinkedList. A ChunkList is like a regular linked list, except each node contains a little fixed size array of elements >>instead of just a single element. Each node also contains its own "size" int to know how full it is.
    The ChunkList will have the following features...
    The ChunkList object contains a head pointer to the first chunk, a tail pointer to the last chunk, and an int to track the logical size of the whole >>collection. When the size of the list is 0, the head and tail pointers are null.
    Each chunk contains a fixed size T[] array, an int to track how full the chunk is, and a next pointer. The constant ARRAY_SIZE = 8; in the chunk >>class defines the fixed size of the array. Elements should be added to the array starting at its 0 index. The elements in each little array should be >>kept in a contiguous block starting at 0 (this will require shifting elements around in the little array at times). (You may want to do some testing >>with ARRAY_SIZE set to smaller values, but turn it in set to 8.)
    ChunkList should be a subclass of AbstractCollection which provides some basic facilities built on top of your add(), iterator(), size() etc. primitives. >>Chunk should be an inner class defined inside of ChunkList. Only ChunkList will see or use the Chunk class directly. It's stylistically ok if ChunkList >>accesses the state (.next, .data, ...) of the Chunk objects, since Chunk essentially is just an integrated part of ChunkList. Add utility methods to >>Chunk where it helps to keep things receiver-
    relative (remove for example). ChunkIterator should be a private inner class as in the lecture example.
    ChunkList must support the messages: constructor, add(), size(), and iterator(). The iterator must support hasNext(), next(), and remove(). It's >>valid for the client to add "null" as an element, so you cannot use null as some sort of special marker in the array -- use your size int in each chuck. >>Make sure that size() and hasNext() are consistent about the size of the collection.
    The empty collection should be implemented as null head and tail pointers. Only allocate chunks when actually needed.
    The add() operation should add new elements at the end of the overall collection -- i.e. new elements should always go into the tail chunk. If the >>tail chunk is full, a new chunk should be added and become the new tail. We are not going to trouble ourselves shifting things around to use >>empty space in chunks in the middle of the list. We'll only look at the tail chunk.
    Do not use a dummy node because (a) it does not help the code much, and (b) dummy nodes are lame.
    Keep a single "size" variable for the whole list that stores the total number of client data elements stored in the list, so you can respond to size() in >>constant time. Similarly, keep a separate size in each chunk to know how full it is. Likewise, add(), hasNext(), next(), and remove() should all run in >>O(1) constant time (they may do computations proportional to ARRAY_SIZE, but not proportional to the overall collection length).
    When using iterator.remove() to remove an element from a Chunk, overwrite the pointer to that element with a null to help the garbage >>collector. This is not a requirement, but it's a nice touch.
    When an iterator.remove() operation causes a chunk to contain zero elements, that chunk should be removed from the list immediately. The code >>for deletion is quite tricky. You may store a "previous" pointer in each chunk if you wish. It is possible to code it without previous pointers by >>keeping extra pointers in the iterator to remember the two previously seen chunks during iteration. Chunk deletion will need to work for many >>boundary cases -- the first chunk, the last chunk, and so on. This is probably the trickiest part of the whole thing.
    When called with correct inputs, ChunkList should return the correct result. However, when called with incorrect inputs -- e.g. iterator.remove() >>without first calling next() -- ChunkList does not need to do anything in particular. It's fine if
    your code just gives the wrong output or throws a null pointer or other exception. This is a slight relaxation of the formal Collection interface which >>guarantees to throw particular exceptions for particular errors.
    ChunkList Advice — Tight Code
    The ChunkIterator is a tricky bit of code. There are about 4 different cases to get right, depending on if the removed chunk was first or last in the >>list. Don't have a separate copy of the remove code for each special case. If you find yourself copying and pasting code, you're doing it wrong. >>Clean up the solution so there is one copy of the remove code and then a few lines to deal with the special cases. This is just general coding style >>advice – avoid proliferating copies of the code for slightly different cases. Try to factor the code down so one copy of the code deals with many >>cases. The remove() method should be about 15 lines long.
    Testing
    The ChunkList is extremely well suited to unit-testing. This is good, since the ChunkList has such a large number of tricky little boundary cases >>where it can go awry. We will unit-test the ChunkList aggressively, since it's the best way to get the code right.
    1. ChunkList Basic Testing
    To get started, write some basic unit tests that build up a ChunkList of Strings with add(), and then iterate over it and remove a few elements, >>checking that the list look right before and after the removes. These tests will get the most basic add()/iterator()/remove() code working.
    2. ChunkList Super Test
    I will provide code for an extremely aggressive test on the ChunkList. Only try this after your basic tests are working. Because the ArrayList (known >>to be correct) and the ChunkList both implement the Collection interface, we can use a unit-test strategy where we do the same operation on >>both an ArrayList and ChunkList, and then verify that they get the same output after each operation.
    The SuperTest creates both an ArrayList and a ChunkList. We'll call an "operation" either a single addition or an iteration down the collection doing >>a few random removes. Do the same random operation to both the ArrayList and ChunkList, and then check that the two look the same, element >>by element. Then loop around and do that 4999 more times, checking the two again after each random operation. We want to push on the >>ChunkList
    to get every weird combination of list length and this or that chunk being full or empty at the time of add or series of removes in some position.
    When you get it take a look at the SuperTest code. It creates a Random(1) for its random number generation, object passing 1 as the seed. In >>this way, the series of "random" operations is the same every time the test is run.
    3. ChunkList SpeedTest
    The unit-tests should work on the correctness of the ChunkList, and that's the most important thing. Look at the source of the provided >>ChunkSpeed class and try running it. It runs a timing test on the ArrayList, LinkedList, and ChunkList classes. The test is a crude simulation of >>collection add/remove/iterate use. ChunkSpeed prints the milliseconds required to do the following representative mix of operations...
    - Use add() to build a 50,000 element collection
    - Create an iterator to iterate halfway through the collection
    - Use the iterator to remove 10,000 elements at that point
    - Creates and runs iterators to run over the whole collection 5 times
    The speeds seen depend on many factors, including the ARRAY_SIZE, the specific hardware, the system load, JVM version, etc., and some runs >>will be way off because the GC thread runs during part of the test. Broadly speaking, on average the ChunkList should be roughly as fast or faster >>than the LinkedList, and a lot faster (a factor of 10 or so) than the ArrayList. The speed numbers have a lot of noise in them, so don't worry about >>a single run. The ChunkList might be slower than the LinkedList on occasion. However, if your ChunkList is consistently slower than the Linked List >>or ArrayList, there is probably something wrong with your ChunkList algorithm -- some operation that is supposed to be O(1) is O(n). The most >>important methods to be fast are hasNext() and next(), since they are the most commonly called by the client.Edited by: G-Unit on Nov 15, 2010 7:31 AM
    Edited by: G-Unit on Nov 15, 2010 7:44 AM

  • Tree2 in Tomahawk  and JSF Tiles Implementation

    hi All,
    right now i mfacing one problem. which arise due to tiles implementation in JSF with Tree2 component of Tomahawk. i had created one tree menu using Tree2.
    its working fine, but i was not able to highlight selected child node of tree menu as i m using tiles implementation so all pages gets reloaded on every click on jsp. thus color of that selected node becomes as it is.
    please note that i m using myfaces implementation.
    what i have written is as below:
    <t:tree2 id="wrapTree" value="#{frontPage.catTree}" var="node" clientSideToggle="true"
                             showRootNode="false" varNodeToggler="t">
                                  <f:facet name="parent-one">
                                  <h:panelGrid id="parentOne" columns="1" cellpadding="0" cellspacing="0" border="0">
                                            <h:commandLink styleClass="textorg" immediate="true" action="#{categoryListBean.showCategoryDetail}">
                                  <h:outputText escape="false" value="#{node.description} "/>
                                       <f:param name="categoreId" value="#{node.identifier}"/>
                             </h:commandLink>
                                  </h:panelGrid>
                   </f:facet>
                   <f:facet name="top-parent">
                   <h:panelGrid id="topParent" columns="1" cellpadding="2" cellspacing="0" border="0" align="left">
                   <h:commandLink styleClass="txtbold" immediate="true" action="#{categoryListBean.showCategoryDetail}">
                   <h:outputText escape="false" value="#{node.description} "/>
                   <f:param name="categoreId" value="#{node.identifier}"/>
                   </h:commandLink>
                   </h:panelGrid>
                   </f:facet>
                   <f:facet name="child">
                   <h:panelGroup id="Child">
                             <h:commandLink styleClass="#{t.nodeSelected ? 'headerRedText':'txt1'}" actionListener="#{t.setNodeSelected}" immediate="true">
                   <h:outputText value="#{node.description}"/>
                        <f:param name="categoreId" value="#{node.identifier}"/>
                   </h:commandLink>
                   </h:panelGroup>
                   </f:facet>
                             </t:tree2>
    please help me if u have solution of this problem.
    thank you.

    hi,
    in MyFaces there is an example using JSF and Tiles.
    MyFaces provides a custom ViewHandler faciltity.
    see http://sourceforge.net/projects/myfaces
    hope that helps.
    Regards,
    Matthias

  • Synchronized method's block list implementation

    In an object with synchronized methods, the OS maintains the list of blocked objects waiting to enter synchronzied methods. For this reason, I'm guesing, the Java spec seems to state the selection of these blocked objects as "arbitrary."
    I am trying to determine that there is no risk of stavation in this blocked pool of threads. For example, a FIFO implementation of the blocked-object list would guarantee that all objects eventually entered their appropriate synchronized method.
    Does anyone know for certain what blocked object selection algorithm is present on a JVM running on a Win32 platform? On SunOS 5.6? I believe the former uses a priority-based, preemptive thread scheduling with a round-robin-style time quantum to prevent starvation. Not sure what the latter uses.
    Any ideas? Thanks!
    -Jeff Ishaq

    In an object with synchronized methods, the OS
    maintains the list of blocked objects waiting to enter
    synchronzied methods. For this reason, I'm guesing,
    the Java spec seems to state the selection of these
    blocked objects as "arbitrary."
    As a general rule, you can never depend on the underlying threading model. The trend is to use the native threading model but that is not guaranteed by the specification.
    I am trying to determine that there is no risk of
    stavation in this blocked pool of threads. For
    example, a FIFO implementation of the blocked-object
    list would guarantee that all objects eventually
    entered their appropriate synchronized method.
    When a thread attempts to acquire a lock, it only checks to see if another thread already holds the lock, and not if another thread is already waiting for the lock. Therefore you should always consider the possibility that starvation can occur.
    Does anyone know for certain what blocked object
    selection algorithm is present on a JVM running on a
    Win32 platform? On SunOS 5.6? I believe the former
    uses a priority-based, preemptive thread scheduling
    with a round-robin-style time quantum to prevent
    starvation. Not sure what the latter uses.
    Again, you should avoid depending on the native threading model because the specification does not guarantee that the java threading model is going to behave the same way.
    To guarantee that each thread can acquire the lock you will need to develop a lock that has a queue associated with it. When a thread attempts to acquire the lock it is placed in a queue waiting until it is the first element in the queue. When the thread releases the lock it removes itself from the queue and notifies the other threads that are waiting.
    When using a queued lock you will not necessarily need to use the synchronized keyword on the method or block since the lock will take care of synchronization when a thread attempts to acquire the lock.

  • AJAX Select list implementation

    Hi,
    I'm trying to implement the AJAX Code Generator from Scott ( http://htmldb.oracle.com/pls/otn/f?p=33867:2 ) using dept no select list and dept name text field. When I change the Dept# selection from the options, all I get is a huge chunk of html code in my dept name text field and it doesn't contain the result.
    Can any one help me out with what i'm doing wrong?
    Thanks.
    - Richard

    Carl,
    Thanks for helping me out.
    Important thing I missed to mention in my original post.... I'm using HTMLDB ver 1.6 copied the js files needed, from htmldb.oracle.com
    Here is the url for the page I created in htmldb.oracle.com. But, when I recreated it, the onchange gets me "null" in department name field instead of huge chunk of HTML code.
    http://htmldb.oracle.com/pls/otn/f?p=19793:24:

  • Adjacency List implementation of a graph

    Hey everyone,
    I'm starting to code a directed graph using an adjacency list and I'm running into a little trouble. I understand the concepts of the adjacency list structure, but I cant write seem to figure out how to code one. So far I'm using two doubly linked lists for storing the vertices and edges, and each is in its own class (I thought this would come in handy when later coding traversals in the graph). In the graph class, I'm thinking that an array list would work to store the adjacent vertices (each value in the array storing a list of vertices which are adjacent). However, if this is right then I'm not sure what to do with the edges, and how to make each edge know which vertices it is connecting.. In general, I'm looking for comments/advice on this type of graph implementation. Anything will help. Thanks a lot.

    import java.util.*;
    public class AdjacencyListNode
        private Set<Node> successors = new HashSet<Node>();
        public void addSuccessor(Node n) { ... }
        public boolean predecessorOf(Node n) { ... }
    }Of course, if you want multiple edges between nodes or weighted edges then it'll need modifying. You may also want to be able to apply a visitor to the successors.

  • List Implementation

    I have an application in which different kinds of messages are sent to the User..i.e.
    I have a base abstract MESSAGE class , with certain attributes and abstract methods.
    Now I have sub classes : MESSAGE1 , MESSAGE2 ...so on, with each class having differnt attributes
    Now I have a MessageBean class. This class has to store the different kinds of Messages.
    It will store an ArrayList of Message1 , Message2 and so on (ArrayList - Since every user can have several Message1 kind of messages to be sent)
    In the MessageBean class I have a method to formatMessage(). This function takes each Message ArrayList (defined as aattributes of the MessageBean class) and iterates over each object and format the message.
    This is how I have designed it.
    the ugliness in my lies in having to iterate over each MessageList one after another in the formatMessage() method.
    I was thinking on the lines of having a MessageList class itself, which will iterate over the messages.
    I need suggestions to know what is a suitable design
    public class MessageBean {
         ArrayList Message1List, Message2List, Message3List, Message4List, Message5List;
         public void addMessage1(){
              if(Message1List == null)
                   Message1List = new ArrayList();                    
         public void addMessage1(Collection messages){
              if(Message1List == null)
                   Message1List = new ArrayList();
              Message1List.addAll(messages);
         public void addMessage2(Collection messages){
              if(Message2List == null)
                   Message2List = new ArrayList();
              Message2List.addAll(messages);
         public void formatAllMessages(){
              Iterator messageItr = null;
              StringBuffer sb = new StringBuffer();
              if(Message1List != null
                        && Message1List.size() > 0){
                   messageItr = Message1List.iterator();
                   Message1 m1 = null;
                   sb.append("This is Message 1");
                   while(messageItr.hasNext()){
                        m1 = (Message1)messageItr.next();
                        m1.format();
                   sb.append("This is End of Message 1");
              if(Message2List != null
                        && Message2List.size() > 0){
                   messageItr = Message2List.iterator();
                   Message2 m2 = null;
                   sb.append("This is Message 2");
                   while(messageItr.hasNext()){
                        m2 = (Message1)messageItr.next();
                        m2.format();
                   sb.append("This is End of Message 2");
              so.on..for each Message List.
    }

    Designs support the business model. A design that is appropriate for one business model is inappropriate for another.
    If it was me, given only the requirements you mentioned, I would generate all of the code.
    If there are additional requirements then a metadata model might be better. That would give only one object and would store the different attributes in that object as a hash.

  • What can be the error in this simple Linked List Implementation

    i have a linked list code that wont compile successfully. The code is
    //Lets try the Linked List 
    import java.util.*;
    class LinkedListDemo {
    public static void main ( String args[]){
         LinkedList l1=new LinkedList();
         l1.add( "A");
         l1.add(2);
         l1.add(3);
         l1.add(4);
         l1.add(5);
         l1.addFirst(6);
         l1.add(7);
         l1.add(8);
         l1.add(9);
         //Lets check what does the Linked List hold at this time
         System.out.println("Prsently the linked lis is having:  "+l1);
    }Problem is with the add method . Compiler error is that it doesnt recognize the symbol ie add method.

    i m sorry , java version is 1.4In that case, read up on the link jverd posted on AutoBoxing. You can only add Objects to a List. An int is a primitive, not an Object. You can try something like this:
    l1.add(new Integer(2));

  • Linked List implementation

    I am working on a ListNode and I need to provide implementation for a garbageCollection() method.
    What the method needs to do is
    // recalculate start address for each node in alloclist
    // delete all but the first node in freelist,
    // update start address and size of this single free block
    Any ideas of how I can do this.

    I am working on a ListNode and I need to provide
    implementation for a garbageCollection() method. You're probably in a class discussing memory allocation. It's quite easy actually but it requires some insight. Good luck -:)

  • T-List implementation

    I am having a problem getting my t-list to populate with values from a database table. I have a table that has one column of data that I wish to display in a t-list. The elements in the column will change so I want to populate the t-list dynamically. The book "Oracle Developer Advanced Forms & Reports" has a recipe for doing so but the preparation step does not detail what the procedure called f_item.setup_list should contain nor where it needs to be called from.
    Thanks!

    For T-list, you need to create a Record Group.
    Step 1.
    Create a record group say the record group's name is'record_grp'..type in the query..
    Select col1, col2
    FROM schema.table
    Where...
    Step 2
    If col1 and col2 is not varchar2, double click on the record group item, click 'Column Specifications', change both col1 and col2 to varchar2 (THOSE HAVE TO BE VARCHAR2,OTHERWISE, IT WILL NOT WORK)
    NOTE: col1 is for label which is display on list item, col2 is the value of that list item.
    step 3.
    You need to use the folling built-ins for your trigger (e.g. When-New-Form-Instance)
    In the trigger..put the folling codes
    -- first populate the group
    IF Populate_Group('grp_name') = 0 THEN
    Populate_List('list_name','grp_name');
    END IF;
    Hope it helps you.

  • How  to Implement a Chained Hash Table with Linked Lists

    I'm making a migration from C/C++ to Java, and my task is to implement a Chained Hash Table with a Linked List. My problem is to put the strings(in this case names) hashed by the table using de Division Metod (H(k)= k mod N) in to a Linked list that is handling the colisions. My table has an interface implemented(public boolean insert(), public boolean findItem(), public void remove()). Any Help is needed. Thanks for everyone in advance.

    OK. you have your hash table. What you want it to do is keep key/value pairs in linked lists, so that when there is a collision, you add the key/value pair to the linked list rather than searching for free space on the table.
    This means that whenever you add an item, you hash it out, check to see if there is already a linked list and if not, create one and put it in that slot. Then in either case you add the key/value pair to the linked list if the key is not already on the linked list. If it is there you have to decide whether your requirements are to give an error or allow duplicate keys or just keep or modify one or the other (old/new).
    When you are searching for a key, you hash it out once again and check to see if there is a linked list at that slot. If there is one, look for the key and if it's there, return it and if not, or if there was no linked list at that slot, return an error.
    You aren't clear on whether you can simply use the provided linked-list implementations in the Java Collections or whether you have to cobble the linked list yourself. In any case, it's up to you.
    Is this what you're asking?
    Doug

  • Has anyone successfully implemented the JSF Viewer with Facelets?

    We have recently started integrating Crystal into one of our web apps that is using JSF + Facelets + Seam.
    I've built a taglib for the jsf viewer and configured it in web.xml and faces-config. I'm pulling an IReportSource from a backing bean using com.crystaldecisions.reports.sdk.ReportClientDocument  and that is using a .rpt file stored on a directory. This all seems to be working, as I can step through the code and see the IReportSource being generated.
    However, when the page loads, I am seeing the crystal javascript being converted in the page source, but nothing is loading on the page. 
    Has anyone seen an issue similar to this tied to Facelets? I've seen numerous documentation on Crystal and JSP, but very little on JSF  or Facelets.
    Has anyone been able to get a setup like this or similar to work properly?
    I've also noticed an error when adding the viewer:
    java.io.IOException: Recover report client document state failed.
    at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.readExternal(SourceFile:1492)
    at com.crystaldecisions.sdk.occa.report.application.AdvancedReportSource.readExternal(SourceFile:131)
    at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1792)
    I believe this to be related to me switching over to the serializable ReportClientDocument: com.crystaldecisions.sdk.occa.report.application.ReportClientDocument  versus using the nonserializable version.
    When using the non-serializable version, I am seeing a constructor issue with the JPEReportSource
    Exception: java.io.InvalidClassException: com.crystaldecisions.reports.reportengineinterface.JPEReportSource; no valid constructor
    Has anyone seen this issue before or able to offer any suggestions?

    Well, according to the tutorials I have seen on the internet, I believe CrystalReport was successfully implemented and tested with jsp, to have it working with Facelets, we need to do a little bit of work around. We need to make a new JSF custom component and assign it to an external renderer. then we can use it to view the report
    please follow these and it should work after then,
    1- bring the following jars into your libs
    commons-configuration-1.2.jar
    Concurrent.jar
    CrystalCommon.jar
    CrystalContentModels.jar
    CrystalDatabaseConnectors.jar
    CrystalFormulas.jar
    CrystalQueryEngine.jar
    CrystalReportEngine.jar
    CrystalReportingCommon.jar
    icu4j.jar
    jrcadapter.jar
    jrcerom.jar
    keycodeDecoder.jar
    MetafileRenderer.jar
    rasapp.jar
    rascore.jar
    rpoifs.jar
    serialization.jar
    URIUtil.jar
    webreporting.jar
    webreporting-jsf.jar
    xercesImpl.jar
    xml-apis.jar
    2- bring the folder "crystalreportviewers115" right under the "WebContent".
    3- implement the custom FacesComponent and make it extend the "UIReportPageViewer" as follows;
    import packagename.CustomReportRenderer;
    @FacesComponent ("packagename.newReportViewer")
    public class UIReportViewer extends com.crystaldecisions.report.web.jsf.UIReportPageViewer implements Serializable{
        public UIReportViewer () {
            this.setRendererType("packagename.CustomReportRenderer");
    4- implement the renderer and make it extend the "ViewerHtmlRenderer" as follows;
    @FacesRenderer(componentFamily="CrystalReports.DHTMLViewer", rendererType="packagename.CustomReportRenderer")
    public class CustomReportRenderer extends com.crystaldecisions.report.web.jsf.ViewerHtmlRenderer implements Serializable {
    5- make a new tag library xml file next to the web.xml so the application can find the tag configurations. name it "taglib.xml" and add the following inside it;
    <facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee"
        version="2.0">
        <namespace>http://new-jsf-custom-components/</namespace>
        <tag>
            <tag-name>ReportViewer</tag-name>
            <component>
                <component-type>packagename.newReportViewer</component-type>
                <renderer-type>packagename.CustomReportRenderer</renderer-type>
            </component>
        </tag>
    </facelet-taglib>
    6- configure the web.xml with the following
      <context-param>
            <description>
            State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
            <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
            <param-value>server</param-value>
        </context-param>
        <context-param>
              <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
            <param-value>/WEB-INF/taglib.xml</param-value>
        </context-param>
        <context-param>
            <param-name>crystal_image_uri</param-name>
            <param-value>../../crystalreportviewers115</param-value>
        </context-param>
    7- implement the reportViewer.xhtml and make sure you have the following;
    - in the tag libraries add the namespace schema xmlns:crystalnmcps="http://new-jsf-custom-components/"
    - add the new reportViewer component
    <crystalnmcps:ReportViewer reportSource="#{youController.reportSource}"  displayToolbarLogo="false" parameterFields="#{youController.parameterFields}"  allowParameterPrompting="false" />
    Now run your app.
    I hope this helps. good luck

  • What JSF Implementation to choose??

    Hi everyone,
    I�m looking to JSF for 6 months and decided to use JSF in a new project, but after this 6 months of learning JSF I continue im doubt about what Implementation is better to use.
    For example, I started with SUN�s RI, but at a certain moment i see that the myfaces implementation has better components and the releases are more frequently. I look at the IBM implementation on WSAD 5.1.2 too (It�s the IDE that I prefer), but the main doubt is WHAT IS THE BETTER IMPLEMENTATION TO CHOOSE??? Does the Sun correct any bug that the myfaces or IBM or others don�t or vice-versa??
    I think this is a critical point to all users of JSF because we have many implementations and the teams envolved seems to be working on different products.
    My conclusion at this moment is to use the Sun RI with custom components of other implementations (MyFaces for instance), but DON�T change the implementation considerating that the Sun RI will be the recommended source of bug fixes and performance improviment.
    Does my decision is correct??? I�m in the right way??
    Thanks for the comments
    Rogerio Saulo

    You have not yet understood my posting on "you have to live with what comes with the application server" correctly: What I described is that J2EE 1.5 will make application servers to come with some JSF compliant implementation, so you don't need to bring your own with when deploying. Then, there is no more need to include myfaces or Sun RI in your WAR file. What I meant with "you have to live with" is that certainly every J2EE 1.5 compliant server comes with some 100% JSF compliant implementation, but since any software has bugs, that servers will have bugs too. Sure your WAR will run on ANY J2EE 1.5 compliant server without any adaptions or adjustments. That's the idea behind J2EE in core, and JSF in detail. But beeing compliant doesn't mean beeing bug free. Since you found out that Sun RI also myfaces both have bugs which you need to work around, this fact will not change with the movement of JSF from your WAR to the appserver: The problem of bugs will remain. You (as the application provider) cannot solve this. Sure you can try bringing your own JSF implementation with your WAR, but that idea means, to bring your own JDBC, JMS, JTA, EJB... implementations with your WAR, too. So that's why I wrote "you have to live with bugs".

Maybe you are looking for

  • Space requirements for Time Machine?

    Greetings, I have recently bought an iMac (last week) and awaiting my update to Leopard. One of the novelties that interests me most about Leopard is the Time Machine, but I was wondering how much disk space it would require on my external drive. I k

  • Can't sent mail. connection to server on port 25 timed out.

    Can't send mail. Connection to the server on port 25 timed out. I keep getting this error when sending mail. I can receive mail but just can't send. When I connect directly to the cable modem, thus removing the Airport from the set up, the mail sends

  • Critical Q:Moving whole portal from UAT enviroment to PRODUCTION enviroment

    Greeting all, after few months of upgrade implementation from DEV > TRN > UAT now, we are planning to move everything to PROduction enviroment. But i have a serious concern. This is not a fresh implementation but an upgrade project (which mean there

  • Choose a valid JDK location

    Hi everyone, I need help ! I got an error when I installed Livecycle ES trial version. The machine is windows 2003 SP2 with tomcat 5.5.27 and jdk is 1.5.0_17. The path and JAVA_HOME variables are correctly set. I don't how to solve this problem becau

  • Is ios7 some kind of +^ ¥ joke?

    So if I want to now phone someone from an SMS conversation. I have to press 3 buttons as opposed to 1?   What compelled me to write this though was having just been on an Internet page, I was wanting to flick to another page I had open. I had to tap