ArrayList nested iterators

How do I clone an Iterator so that I can use a nested iterator over an ArrayList?
The problem with the code sample below is the inner iterator (Iter2)
advances the outer iterator (iter) so that the outer iterator only examines the first cell in the ArrayList.
thanks,
greg
import java.util.ArrayList;
import java.util.Iterator;
public class CellGroup extends ArrayList<Cell> {
public boolean checkForBlanksOrDuplicates()
Iterator<Cell> itr = this.iterator();
while (itr.hasNext()) {
Cell cell = itr.next();
if ( cell.getSymbol().equals(" "))
return false;
String s = cell.getSymbol();
Iterator<Cell> itr2 = itr;
while (itr2.hasNext()) {
Cell cell2 = itr2.next();
if ( cell2.getSymbol().equals(s) )
return false;
return true;
}

At the initialization of the second iterator you could get an iterator starting from the position in the array list of the last "cell" checked.
Code look like:
Iterator<Cell> itr2 = listIterator(indexOf(cell));Note the methods listIterator and indexOf are inherited from ArrayList class. They returns respectively an iterator starting from a given position
and the position of a given object.

Similar Messages

  • Rendering Tree Structure from nested Iterators

    I am attempting to create a master-detail tree structure using nested iterators using JDeveloper 11.1.1.6.0. I have my data control set up and the master - child relation is set up using a view link.
    The intent is to be able to have a form that results in the following basic design:
    ------------------|
    parent 1 details
    -child 1 details and operations
    -child 2 details and operations
    ------------------|
    parent 2 details
    -child 3 details and operations
    ------------------|
    Thus far when I've tried nested iterators using the data control, I instead get the following:
    ------------------|
    parent 1 details
    -child 1 details and operations
    -child 2 details and operations
    -child 3 details and operations
    ------------------|
    parent 2 details
    ------------------|
    -child 1 details and operations
    -child 2 details and operations
    -child 3 details and operations
    ------------------|
    I've attempted to get this to work by using two completely seperate binding iterators, each tied to a different af:iterator in the following structure:
    <af:iterator id="i1" value="#{bindings.parent.collectionModel} var="row" rows="#{bindings.parentIterator.rangeSize}">
      <af:panelBox text="#{row.bindings.detail.inputValue}">
        <af:iterator id="i2" value="#{bindings.child.collectionModel}" var="row2" rows="#{bindings.childIterator.rangeSize}">
          <af:outputText value="#{row2.bindings.detail.inputValue}"/>
        </af:iterator>
      </af:panelBox>
    </af:iterator>However, this renders the above situation. I have not been ablue to figure out how to have the second iterator's values be dependant on the current row of the first iterator. I can get the organizational structure to work using an af:tree element and my data control. However, I cannot modify the look of the af:tree elements to match what is required by the customer, nor do I beleive that I could create the required functionality using it. Does anyone have any suggestions on how to get this to work?
    Thank you
    Edited by: user13468716 on May 15, 2012 6:23 AM

    You can't use collectionModel for both the iterators. You will either need to create a treeBinding with a tree level rule and refer the first one as +#{bindings.<TreeBindingName>.treeModel}+ name it as row
    and refer to the next iterator as #{row.<TreeLevelRuleName>}.
    This will atleast create the stamping of the rows properly.Something like this -
    <af:iterator id="i1" value="#{bindings.parent.treeModel} var="row" rows="#{bindings.parentIterator.rangeSize}">
      <af:panelBox text="#{row.bindings.detail.inputValue}">
        <af:iterator id="i2" value="#{row.child}" var="row2" rows="#{bindings.childIterator.rangeSize}">
          <af:outputText value="#{row2.bindings.detail.inputValue}"/>
        </af:iterator>
      </af:panelBox>
    </af:iterator>where +parent+ is a treeBinding having +child+ as a tree level rule
    Edited by: Sudipto Desmukh on May 15, 2012 6:57 PM

  • Table in nested Iterators-Tree Level Rules for ViewInstances using same VL

    Hi All ,
    Jdev 11.1.1.6 , ADF BC , WLS 10.3.5.
    I have a use case wherein I need to show a table nested at 3rd level within 2 af:iterators like -
    <af:iterator id="i1" value="#{bindings.Location.collectionModel}"
                   var="locRow" varStatus="varStatus">
    <af:iterator id="i2" var="deptRow" value="#{locRow.children}"
    varStatus="varStat">
    <af:table value="#{deptRow.Employees}" //using child View Link accessor Attribute directly can use deptrow.children too
                          var="row">
    <af:column>
    <af:inputText value="#{row.EmployeeName}">
    </af:column>
    </af:table>
    </af:iterator>
    </af:iterator>I need to display a table of Employees for each manager ... like ManagerId=100 in one table and others in a separate one (I know weird requirement but thats how it is :( )
    So basically in my AM Data Model I have shuttled two view instances of Employee and filtered them using ViewCriterias accordingly like ->
    OrgAM
    -Location
    Department
    ---Employees //(WithManager100)
    ---EmployeesWithManageNot100
    Now since there is just one ViewLink between Department & Employees .. I am able to add "*EmployeesWithManageNot100*" as a child ViewLink accessor attribute , only Employees is available.
    Is there any way we can show separate child ViewInstances in a treeModel with only one ViewLink ?

    Thanks for your reply Frank.
    important: 11.1.1.6 , ADF BC , WLS 10.3.5. is not correct - it should be WLS 10.3.6AFAIK , 11.1.1.6 is compatible with both WLS 10.3.5 and 10.3.6 WLS and comes out of the box with WLS 10.3..5 which I am using for the Integrated Server.
    So while there is a way to have two child node collections, its not from view object instances you define and configure using view criteriaThe link you posted above is simialr to another link I bumped into yesterday -
    "How to filter tree node child data" , Pg 12 @ http://www.oracle.com/technetwork/developer-tools/adf/learnmore/feb2011-otn-harvest-328207.pdf written by you.
    But my requirement is showing instances of the same EmployeeVO as two tables inside the Department Iterator. But I am not able to do that since there is only one ViewLink accessor for the EmployeeView.
    Is that even possible without using 2 explicit physical View Links ?

  • Jave Help pls I am really confused

    Hi, Im new to Java and I would really appreciate some help with some concepts.
    For example, an assignment I am currently doing utilizes Arraylists and Iterators, as well as an Input reader that has already been written for me.
    Here it is:
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    public class InputReader
    private BufferedReader reader;
    public InputReader()
    reader = new BufferedReader(new InputStreamReader(System.in));;
    public String getInput()
    System.out.print("> "); // print prompt
    String inputLine = readInputLine();
    return inputLine;
    private String readInputLine()
    String line = "";
    try {
    line = reader.readLine();
    catch(java.io.IOException exc) {
    System.out.println ("Read error: " + exc.getMessage());
    return line;
    I am confused as to how to initalize my project with InputReader. I also do not know how to correctly cast so that when the user types a command, he/she will get the information regarding the object. Essentially my project is about a library, where by executing commands (such as findBookByName) and (findPatronByID) the compuer will return all information about that book/patron. Thanks alot.

    you start with a class
    class Book
      String title;
      String author;
      String ISBN; //just use 3 figure ISBN's here
      public Book(String t,String a, String i)
        title = t;auther = a; ISBN = i;
    }now, when you get user input, you can get it all in one line, fields separated
    by (eg) a comma. you then parse the line into the 3 fields and create a new book
    new Book(data1,data2,data3);
    you need something to store and retrieve the book data. A HashMap is an
    ideal candidate - you retrieve the book object by getting the key (ISBN)
    Look up HashMap in the docs, and have a go at it.

  • Synchronized in Iterator..??

    I have some problem with handling Vector.
    I use Vector because of multi-thread - that is to say, to use synchronized in Vector.
    As you know, Vector can produce Iterators. But the Iterators seems to not synchronized.
    Suppose the case when two thread do with two Iterators from a Vector. If thread 1 iterates its element while thread 2 removes them, what happen??
    How can I synchronize the array shared with the Vector & two of Iterators??

    How can I synchronize the array shared with the
    Vector & two of Iterators??Since you're going to have to do synchronization beyond what the Vector provides, using the Vector class isn't a good idea, because now you're synchronizing twice. I'd use ArrayList, and then pick an object (perhaps create a class that holds the array, ArrayList, and iterators) and synchronize once on that object.

  • DISTINCTCOUNT combined with ADDCOLUMNS + FILTER

    Hello,
    I've been going nuts trying to optimize fhe following expression in PowerPivot :
    CALCULATE(DISTINCTCOUNT([Identifiant Personne Physique]);(FILTER(
    ADDCOLUMNS(
    'Contrats';"Nb Contrats P-1 T";
    SUMX(DISTINCT(Contrats[Identifiant Personne Physique]);
    SUMX('Contrats';VALUE(Contrats[Base dénombrement P-1])))
    );[Nb Contrats P-1 T] = 0 && [Base dénombrement Flux Entrée] = "1")))
    The idea is to count distinctly the persons (without removing the context filters) whose SUM([Nb Contrats P-1 T]) is equal to 0 and flag [Base dénombrement Flux Entrée] = 1.
    It does the job but I have 2 issues :
    1. It is extremly slow when I change the values of the slicers (20 millions rows in the model). Does anyone know who to improve the performances of that query ?
    2. The measure returns a NULL values when the field [Identifiant Personne Physique] is not used as a dimension in my Pivot tables. What did I miss to make it possible ?
    Thanks a lot for any help,
    Fred

    The slowness you are seeing is due to your trebly nested iterators.
    FILTER() and SUMX() both iterate over rows one by one. Further, FILTER() is forced to single-threaded mode no matter what, and I cannot recall right now if SUMX() does the same.
    Working from the inside out, SUMX('Contrats'....) is being evaluated for every single row in DISTINCT(Contrats[Identifiant Personne Physique]), which in turn is being evaluated for every row in 'Contrats'. This whole expression is then fed to FILTER() which
    means that we step row by row through Contrats and perform the test you have defined.
    Without knowing more about your model, it will be difficult to help tune this measure. If you have a sample data set you can share, with the working measure included, that would be very helpful.
    As a first pass, it seems you may be able to remove the innermost SUMX() and replace it with a simple SUM() (it may have to be wrapped in a CALCULATE(). This would look like:
    SUMX(
    DISTINCT( Contrats[Identifiant Personne Physique] )
    ; CALCULATE( SUM( Contrats[Base denombrement P-1] ) )
    I suggest this because SUMX( <table>; VALUE( <column> ) ) is telling the engine to step row by row through <table> and add the number on the current row in <column> to a running total and then return the total.
    Again, based on my naive first impression, looking at this it seems it may be possible to simply remove the outer SUMX() as well leaving you with just the CALCULATE( SUM( ... ) ) from above.
    Again, this is based on a naive first look, and I expect you have a good reason to have eliminated the suggestions above.
    I don't think anyone (I know I, at least) will be able to provide much help without a sample as I expressed above.

  • Accessing element in a nested arraylist

    Hi,
    I have a LinkedHashMap that contains ArrayLists. Something like this:
    {color:#3366ff}
    ArrayList list = new ArrayList();
    ArrayList list2 = new ArrayList();
    LinkedHashMap<Integer, ArrayList> map = new LinkedHashMap<Integer, ArrayList>();
    list.add(0, "list1 row1");
    list.add(1, "list1 row2");
    list.add(2, "list1 row3");
    list2.add(0, "list2 row1");
    list2.add(1, "list2 row2");
    list2.add(2, "list2 row3");
    map.put(0, list);
    map.put(1, list2);{color}
    How can I iterate over the elements in the arrays in the map in a JSP page?
    Do I need to use the nested tag? Can anyone show me an example of how to print out e.g. "list1 row1"?
    Thanks.

    If you're using JSP 2.0, you can interate over nested lists using nested <c:forEach ....> tags.
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ page import="java.util.*" %>
    <% // ugly scriptlet code that belongs somewhere else.
       // used here for demonstration purposes only.
      List rows = new ArrayList();
      request.setAttribute("rows", rows);
      for(int i = 1; i <=12; i++){
        List cols = new ArrayList();
        for(int j = 1; j <=12; j++){
          cols.add(String.valueOf(i * j));
        rows.add(cols);
    %>
    <html>
      <head>
        <title>nested forEach tags</title>
      </head>
      <body>
        <table border="1">
          <c:forEach var="row" items="${rows}">
            <tr>
              <c:forEach var="col" items="${row}">
                <td>${col}</td>
              </c:forEach>
            </tr>
          </c:forEach>
        </table>
      </body>
    </html>Edited by: ben_souther on Sep 13, 2007 2:57 PM

  • How to creat extractor for element of an object nested within an ArrayList

    I have the following issue I want to create an extractor for property of a object that is contained within an ArrayList. I am using JAXB to marshal/unmarshal XML into java objects such that the following XML Code below results in the repeating <system> elements to be rolled up into an ArrayList. The issue is that for each object that Coherence returns to my class that implements the ValueExtractor interface (which is represented by the XML snippet below) I can only return one of the values represented by the multiple <system> elements. Is there a way to do this?
    <?xml version="1.0" encoding="UTF-8"?>
    <sc:scorecard xmlns:sc="http://dtds.pearsoncmg.com/ctg/Scorecard/data/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://dtds.pearsoncmg.com/ctg/Scorecard/data/v1 Scorecard.xsd ">
    <sc:transactionId>1234567890-03072012</sc:transactionId>
    <sc:recipients>
    <sc:system>
    <sc:providerName>portal</sc:providerName>
    <sc:status>processing</sc:status>
    <sc:responseCode></sc:responseCode>
    <sc:flowTrace>
    <sc:flowLocation>
    <sc:serviceName>doReg</sc:serviceName>
    <sc:operationName>RegABC</sc:operationName>
    </sc:flowLocation>
    <sc:updateDate>2012-03-01T12:03:00.003</sc:updateDate>
    </sc:flowTrace>
    <sc:flowTrace>
    <sc:flowLocation>
    <sc:serviceName>doReg</sc:serviceName>
    <sc:operationName>RegXYZ</sc:operationName>
    </sc:flowLocation>
    <sc:updateDate>2012-03-01T12:03:05.016</sc:updateDate>
    </sc:flowTrace>
    </sc:system>
    <sc:system>
    <sc:providerName>gradebook</sc:providerName>
    <sc:status>dispatched</sc:status>
    <sc:responseCode></sc:responseCode>
    <sc:flowTrace>
    <sc:flowLocation>
    <sc:serviceName>getRegDetails</sc:serviceName>
    <sc:operationName>processABC</sc:operationName>
    </sc:flowLocation>
    <sc:updateDate>2012-03-01T12:03:00.051</sc:updateDate>
    </sc:flowTrace>
    </sc:system>
    <sc:system>
    <sc:providerName>sms</sc:providerName>
    <sc:status>NA</sc:status>
    <sc:responseCode></sc:responseCode>
    </sc:system>
    </sc:recipients>
    </sc:scorecard>
    Edited by: user7953523 on Apr 27, 2012 11:00 AM

    Hi
    I posted something on this a long time ago here POF Extractor and Collections (review my code)
    The code could probably be made a bit more efficient but it should give you a starting point
    JK

  • Using ArrayList to store Lines in a text File

    Hey Guys,
    I have the following program that I am using to read a text file and store each word in each line in an ArrayList. But I am getting the following error;
    Exception in thread "main" java.util.ConcurrentModificationException
         at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:449)
         at java.util.AbstractList$Itr.next(AbstractList.java:420)
         at bus.OrderReader.parseLine(OrderReader.java:50)
         at bus.OrderReader.main(OrderReader.java:32) The code is as follows;
    package bus;
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.util.Scanner;
    import java.util.Collection;
    import java.util.ArrayList;
    import java.util.Iterator;
    public class OrderReader {
        static Collection bread = new ArrayList();
        static Collection filling = new ArrayList();
        static Iterator iter1 = filling.iterator();
        static Iterator iter2 = bread.iterator();
         private static int counter;
    public static void main(String args[]){
        Scanner s = null;
        try {
            s = new Scanner(new BufferedReader(new FileReader("/Users/admin/Documents/workspace2/OBS/WebContent/WriteMe.txt")));
            s.useDelimiter("\r");
            while(s.hasNext()) {
                parseLine(s.next());
                counter++;
            s.close();
        catch(FileNotFoundException e) {
            System.out.println("cannot find the file");
            //ignore for now
        public static void parseLine(String line) {
            Scanner lineScanner = new Scanner(line);
            lineScanner.useDelimiter("#");
                bread.add(lineScanner.next());
                filling.add(lineScanner.next());
                System.out.println(iter1.next());
                System.out.println(iter2.next());
    }I do not understand why this does not work. Can someone please point me in the right direction?
    Thank You
    Jaz

    Instead of doing this:
    bread.add(lineScanner.next());
    filling.add(lineScanner.next());
    System.out.println(iter1.next());
    System.out.println(iter2.next());where presumably you're just printing what you just
    barely added, do this:
    Object breadObject = lineScanner.next();
    Object fillingObject = lineScanner.next();
    bread.add(breadObject);
    filling.add(fillingObject);
    System.out.println(breadObject);
    System.out.println(fillingObject);
    And get rid of the now unused iterators.Im not sure I understand quiet what is happening here. Are you creating a primitive data type of type Object and then storing all the values in that variable?
    why would I do this when this only allows me to view the very last element that was added to the list? I want to view the entire list.
    Thanks
    Jaz
    Message was edited by:
    DontKnowJack

  • NotSerializable error while trying to write arraylist

    I am getting a NotSerializable error while trying to write an arraylist to a file.
    Here's the part of the code causing problem
    File temp = fileOpenerAndSaver.getSelectedFile(); // fileOpenerAndSaver is a JFileChooser object which has been created and initialized and was already used to select a file with
    currentWorkingFile = new File (temp.getAbsolutePath() + ".gd");      // currentWorking file is a file object
    try
         ObjectOutput output = new ObjectOutputStream (new BufferedOutputStream(new FileOutputStream(currentWorkingFile)));
         output.writeObject(nodeList); // <-- This is the line causing problem (it is line 1475 on which exception is thrown)
         output.writeObject(edgeList);
         output.writeObject(nodesWithSelfLoop);
         output.writeObject(nextId);
         output.writeUTF(currentMessage);
         output.close();
    catch (Exception e2)
         JOptionPane.showMessageDialog (graphDrawer, "Unknown error writing.", "Error", JOptionPane.ERROR_MESSAGE);
         e2.printStackTrace();
    } As far as what nodeList is -- it's an arraylist of my own class Node which has been serialized and any object used inside the class has been serialized as well.
    Here is the declaration of nodeList:
         private ArrayList <Node> nodeList; // ArrayList to hold a list all the nodesLet me show you whats inside the node class:
    private class Node implements Serializable
         private static final long serialVersionUID = -4625153386839971250L;
         /*  edgeForThisNodeList holds all the edges that are between this node and another node
          *  nodesConnected holds all the nodes that are connected (adjacent) to this node
          *  p holds the top left corner coordinate of this node.  The centre. of this node is at (p.x + 5, p.y + 5)
          *  hasSelfLoop holds whether this node has a self loop.
          *  **NOTE**: ONLY ONE SELF LOOP IS ALLOWED FOR A NODE.
         ArrayList <Edge> edgeForThisNodeList = new ArrayList <Edge> ();
         ArrayList <Node> nodesConnected = new ArrayList <Node> ();
         Point p;
         boolean hasSelfLoop = false;
         int index = -1;
         BigInteger id;
                     ... some methods following this....
    }Here is the edge class
    private class Edge implements Serializable
         private static final long serialVersionUID = -72868914829743947L;
         Node p1, p2; // The two nodes
         Line2D line;
          * Constructor:
          * Assigns nodes provided as appropriate.
          * Also calls the addEdge method on each of the two nodes, and passes
          * "this" edge and the other node to the nodes, so that
          * this edge and the other node can be added to the
          * data of the node.
         public Edge (Node p1, Node p2)
              this.p1 = p1;
              this.p2 = p2;
              line = new Line2D.Float(p1.p.x+5,p1.p.y+5,p2.p.x+5,p2.p.y+5);
              p1.addEdge(this, p2, true);
              p2.addEdge(this, p1, false);
         }Here is the error I am getting:
    java.io.NotSerializableException: javax.swing.plaf.metal.MetalFileChooserUI
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
         at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
         at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.writeObject(Unknown Source)
         at MyPanel.save(MyPanel.java:1475)
         at GraphDrawer.actionPerformed(GraphDrawer.java:243)
         I inentionally did not write the whole error stack because it was way too long and I ran out of characters. But line 1475 is where I do the writeObject call. I also goet some weird not serialized exceptions before on some other classes that are not being written to the file or are not part of the object that I am writing. I serialized those classes and now it's this unknown object that's causing problems.
    Edit: The problem may be due to the JFileChooser I am using to select the file as it is a non-serializable object. But I am not trying to write it to the file and in fact am just writing the arrayLists and BigInteger as objects to the file.
    Edited by: Cricket_struck on Dec 21, 2009 1:25 PM
    Edited by: Cricket_struck on Dec 21, 2009 1:32 PM
    Edited by: Cricket_struck on Dec 21, 2009 2:16 PM

    java.io.NotSerializableException: javax.swing.plaf.metal.MetalFileChooserUIThat's a Swing component and it is clearly related to the JFileChooser.
    I also get some weird not serialized exceptions before on some other classes that are not being written to the file or are not part of the object that I am writing.That's a contradiction in terms. If you get NotSerialzableException it means the objects are being written. So they are reachable from the objects you're writing.
    Edit: The problem may be due to the JFileChooser I am using to select the file as it is a non-serializable object.JFileChooser implements Serializable, but you're right, you shouldn't try to serialize it. But clearly this is the current problem. Somewhere you have a reference to it reachable via the object(s) you are serializing.
    I suspect that Node and Edge inner classes and that you aren't aware that inner classes contain a hidden reference to their containing class. The solution for serializaition purposes is to make them static nested classes, or outer classes.

  • Flex RPC mapping Java nested classes to ActionScript classes

    We are calling a Java method in our project using
    RemoteObject the value returned by the java method is a ArrayList
    containing instances of a class say ParentClass with some nested
    classes.
    The structure of ParentClass(Java) is something like this
    class ParentClass {
    //some primitives
    private ChildClassA childAInstance;
    private ChildClassB childBInstance;
    //getters setters
    We have created similar class structure on the ActionScript
    side, the ActionScript classes(ParentClass,ChildClassA
    ,ChildClassB) have been properly annotated with the [RemoteClass]
    metadata tag,
    The problem is that though i'm getting the primitive data
    members of the ParentClass through RPC in my corresponding AS
    ParentClass class i'm getting an runtime exception trying to access
    ChildClassA,ChildClassB members.
    Am i missing something, exactly the same scenario is
    mentioned in this article
    http://www.adobe.com/devnet/flex/articles/complex_data.html
    But the Object.registerClass method mentioned in the tutorial
    is giving me compilation error, the sample code attached with the
    article is corrupt zip too.
    Please help me out on this

    JAXB will create classes from an XML schema, SAX is a parser library and JAXP is a library of XML a bunch of XML tools.
    I don't care for JAXB too much. I would skip it and go right to the JAX-RPC spec (WebServices).

  • [Solved] Nested setActionListener not working correctly.

    Hi,
    I'm having a situation where I have to load some xml and display the values on the screen. The results can be filtered by selecting a value in a selectOneChoice component. Please consider the example below, which is a reproducible scenario, just to show the 'wrong' (?) behavior.
    The ValueChange bean initialize some lists and handles the selection change of the selectOneChoice component on the .jspx page. The onValueChange method will 'filter' the data everytime a selection change. The filterItems method will clear the personItems list and add a new object to the list, depending on the selected value:
    public class ValueChange {
        private List someSelectItems;
        private String selectedValue;
        private List personItems;
        private Person person1 = new Person("1", "Larry", "Ellison");
        private Person person2 = new Person("2", "Bill", "Gates");
        private Person person3 = new Person("3", "Steve", "Jobs");
        public ValueChange() {
         System.out.println(this.getClass() + " Init");
         this.someSelectItems = new ArrayList();
         someSelectItems.add(new SelectItem("1", "Oracle"));
         someSelectItems.add(new SelectItem("2", "MicroSoft"));
         someSelectItems.add(new SelectItem("3", "Apple"));
         this.personItems = new ArrayList();
         this.personItems.add(person1);
        public List getSomeSelectItems() {
         // Fill this list.
         return someSelectItems;
        public void onValueChange(ValueChangeEvent valueChangeEvent) {
         System.out.println("Current Class: ValueChange - Current Method: onDocumentLanguageValueChange");
         if (valueChangeEvent != null) {
             String vValue = valueChangeEvent.getNewValue().toString();
             filterItems(vValue);
        public void setSelectedValue(String selectedValue) {
         this.selectedValue = selectedValue;
        public String getSelectedValue() {
         return selectedValue;
        private void filterItems(String pValue) {
         this.personItems.clear();
         if (pValue.equals("1")) {
             this.personItems.add(person1);
         } else if (pValue.equals("2")) {
             this.personItems.add(person2);
         } else if (pValue.equals("3")) {
             this.personItems.add(person3);
        public void setPersonItems(List personItems) {
         this.personItems = personItems;
        public List getPersonItems() {
         return personItems;
    }The person class is just a simple bean containing some attributes + getters and setters:
    public class Person {
        private String id;
        private String firstname;
        private String lastname;
        public Person(String pId, String pFirstname, String pLastname) {
         this.id = pId;
         this.firstname = pFirstname;
         this.lastname = pLastname;
        public void setId(String id) {
         this.id = id;
        public String getId() {
         return id;
        public void setFirstname(String firstname) {
         this.firstname = firstname;
        public String getFirstname() {
         return firstname;
        public void setLastname(String lastname) {
         this.lastname = lastname;
        public String getLastname() {
         return lastname;
    }On the start page of the example, the selectOneChoice will be rendered + the data matching to the selected item. I'm using a commandLink to open a detail page. The commandLink contains a nested af:setActionListener which should set the whole current person instance to a sessionScope variable. (But his seems to fail.]
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:af="http://xmlns.oracle.com/adf/faces"
              xmlns:afh="http://xmlns.oracle.com/adf/faces/html">
      <jsp:output omit-xml-declaration="true" doctype-root-element="HTML"
                  doctype-system="http://www.w3.org/TR/html4/loose.dtd"
                  doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>
      <jsp:directive.page contentType="text/html;charset=windows-1252"/>
      <f:view>
        <afh:html>
          <afh:head title="myPage">
            <meta http-equiv="Content-Type"
                  content="text/html; charset=windows-1252"/>
          </afh:head>
          <afh:body>
            <h:form id="myPageForm">
              <h:panelGrid>
                <af:selectOneChoice id="selectValue" autoSubmit="true" value="1"
                                    valueChangeListener="#{valueChange.onValueChange}">
                  <f:selectItems value="#{valueChange.someSelectItems}"/>
                </af:selectOneChoice>
                <af:panelList partialTriggers="selectValue">
                  <af:forEach items="#{valueChange.personItems}" var="person">
                    <af:commandLink text="#{person.firstname} (#{person.id})"
                                    action="showdetail">
                      <af:setActionListener from="#{person}"
                                            to="#{sessionScope.person}"/>
                    </af:commandLink>
                  </af:forEach>
                </af:panelList>
              </h:panelGrid>
            </h:form>
          </afh:body>
        </afh:html>
      </f:view>
    </jsp:root>The detail page should just read the firstname of the person instance on sessionScope, but it always shows the same name.
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:af="http://xmlns.oracle.com/adf/faces"
              xmlns:afh="http://xmlns.oracle.com/adf/faces/html">
      <jsp:output omit-xml-declaration="true" doctype-root-element="HTML"
                  doctype-system="http://www.w3.org/TR/html4/loose.dtd"
                  doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>
      <jsp:directive.page contentType="text/html;charset=windows-1252"/>
      <f:view>
        <afh:html>
          <afh:head title="myDetailPage">
            <meta http-equiv="Content-Type"
                  content="text/html; charset=windows-1252"/>
          </afh:head>
          <afh:body>
            <h:form>
              <af:panelForm maxColumns="1">
                <af:outputText value="#{sessionScope.person.firstname}"/>
                <af:commandLink text="Back" action="back"/>
              </af:panelForm>
            </h:form>
          </afh:body>
        </afh:html>
      </f:view>
    </jsp:root>
    <?xml version="1.0" encoding="windows-1252"?>
    <!DOCTYPE faces-config PUBLIC
      "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
      "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config xmlns="http://java.sun.com/JSF/Configuration">
      <managed-bean>
        <managed-bean-name>valueChange</managed-bean-name>
        <managed-bean-class>be.contribute.valuechange.view.beans.ValueChange</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
      </managed-bean>
      <application>
        <default-render-kit-id>oracle.adf.core</default-render-kit-id>
      </application>
      <navigation-rule>
        <from-view-id>/myPage.jspx</from-view-id>
        <navigation-case>
          <from-outcome>showdetail</from-outcome>
          <to-view-id>/myDetailPage.jspx</to-view-id>
        </navigation-case>
      </navigation-rule>
      <navigation-rule>
        <from-view-id>/myDetailPage.jspx</from-view-id>
        <navigation-case>
          <from-outcome>back</from-outcome>
          <to-view-id>/myPage.jspx</to-view-id>
        </navigation-case>
      </navigation-rule>
    </faces-config>I can always send this sample application by mail, just drop a reply or send me a message (koen [dot] verhulst [at] contribute [dot] be )
    JDeveloper 10.1.3.3
    Thanks in advance,
    Koen Verhulst

    It seems that it has something to do with the fact that I set the value of the selectOneChoice to 1.
    <af:selectOneChoice id="selectValue" autoSubmit="true" value="1"
                                    valueChangeListener="#{valueChange.onValueChange}">
                  <f:selectItems value="#{valueChange.someSelectItems}"/>
    </af:selectOneChoice>I modified the value attribute to:
    value="#{valueChange.selectedValue}"Where selectedValue is an attribute in my ValueChange class, containing a default value. Getters and setters are also generated.
    private String selectedValue = "1"When I run the application again, after making these changes, I'm able to pass the correct data to the detail page. But: as soons as I select the 'default value' in the selectOneChoice, no valueChange is detected and thus my data does not gets filtered.
    Since the valueChange instance is a request-scoped bean, a value change is not detected because the current value equals the default value (question: am I right here?).
    Setting the bean to session scope let the example fully works.
    Although it works, I think it should be better to let the bean on request scope and stored a 'selected' value attribute on the sessionScope.
    Thanks,
    Koen Verhulst

  • DataScroller nested facets disappear

    I've managed to get a Tomahawk dataTable working with sorting. I've also added two dataScroller tags (as shown in the example wars).
    The dataTable uses an ArrayList in a backing bean, configured as a session-scoped managed bean.
    The paginator works fine; i.e. I can go from one "scroller page" to another using the "paginator numbers" (the 1, 2, 3, etc. generated) in the middle, however the nested facets in the first dataScroller (the first, previous, next, last, etc. links) disappear as soon as a new request is sent, e.g. when clicking a paginator page link or changing the sort column.
    How's that possible, knowing that the actual pagination works fine? Is there any problem with my facets?
              <t:dataScroller
                        id="scroll_1"
                        for="tradeTable"
                        paginator="true"
                        fastStep="10"
                        paginatorMaxPages="10"
                        paginatorActiveColumnStyle="font-weight:bold;">
                        <f:facet name="first">
                             <h:outputText value="|<" />
                        </f:facet>
                        <f:facet name="previous">
                             <h:outputText value="<" />
                        </f:facet>
                        <f:facet name="next">
                             <h:outputText value=">" />
                        </f:facet>
                        <f:facet name="last">
                             <h:outputText value=">|" />
                        </f:facet>
                        <f:facet name="fastforward">
                             <h:outputText value=">>" />
                        </f:facet>
                        <f:facet name="fastrewind">
                             <h:outputText value="<<"/>
                        </f:facet>
                   </t:dataScroller>* I've tried changing the <h:outputText> to <t:outputText> or using images as in the examples [<t:graphicImage>] but that doesn't seem to help.
    * I've also given every element on the page an id.

    Might have been a while ago. I am / was using <t:dataTable> at that time. I still haven't found a solution to this problem.
    What I have noticed though is when I startup my Tomcat, 2 or more sets of similar components (myfaces / sun) seem to be merged. But not sure if the behaviour of the dataTable is effected by this.
    Any feedback wecome.
    18:31:29,206  WARN Digester:120 - [ComponentRule]{faces-config/component} Merge(org.apache.myfaces.HtmlCommandButton)
    18:31:29,221  WARN Digester:120 - [ComponentRule]{faces-config/component} Merge(org.apache.myfaces.HtmlCommandLink)
    18:31:29,221  WARN Digester:120 - [ComponentRule]{faces-config/component} Merge(org.apache.myfaces.HtmlDataTable)

  • Urgent! Nested If- Else statements.Help me

    Please help me, I gt a problem using a nested if else statements.I have 3 objects called bpdu objects. These 3 bpdu objects need to be compared with each other based on their Priority and Mac Address.The program below shows the program that have been done and I wish to know how do I compare the Mac address continuing from the Piority.
    I also want to know if the Priority comparison is in the correct sequence
    Here is the code.
    import java.util.*;
    import java.sql.*;
    import java.io.*;
    import java.net.*;
    import java.lang.*;
    public class RootBridgeApp
         RootBridge root= new RootBridge();
         ArrayList dataList=root.retrieveAll(compName);
         BPDU bpdu=dataList.get(0);
         BPDU bpdu2=dataList.get(1);
         BPDU bpdu3=dataList.get(2);
    //COMPARE ON PRIORITY
         if(bpdu.getBridgeIDPriority()<bpdu2.getBridgeIDPriority())
         {   //comparing bpdu with bpdu3
              if(bpdu.getBridgeIDPriority()<bpdu3.getBridgeIDPriority())
                   System.out.println(bpdu.getComputerName + "is Root Bridge!");
              //comparing bpdu3 with bpdu2
              else if(bpdu3.getBridgeIDPriority()<bpdu2.getBridgeIDPriority())
                   System.out.println(bpdu3.getComputerName + "is Root Bridge!");
              else
                   System.out.println(bpdu2.getComputerName + "is Root Bridge!");
         //comparing bpdu2 with bpdu3
         else if(bpdu2.getBridgeIDPriority()<bpdu3.getBridgeIDPriority())
              System.out.println(bpdu2.getComputerName + "is Root Bridge!");
         else
              System.out.println(bpdu3.getComputerName + "is Root Bridge!");
         //IF SAME THEN COMPARE BY MAC
    // COMPARE BY MAC  ... how do i continue form here?
         if(bpdu.getBridgeIDMac()<bpdu2.getBridgeIDMac())
         {   //comparing bpdu with bpdu3
              if(bpdu.getBridgeIDMac()<bpdu3.getBridgeIDMac())
                   System.out.println(bpdu.getComputerName + "is Root Bridge!");
              //comparing bpdu3 with bpdu2
              else if(bpdu3.getBridgeIDMac()<bpdu2.getBridgeIDMac())
                   System.out.println(bpdu3.getComputerName + "is Root Bridge!");
              else
                   System.out.println(bpdu2.getComputerName + "is Root Bridge!");
         //comparing bpdu2 with bpdu3
         else if(bpdu2.getBridgeIDMac()<bpdu3.getBridgeIDMac())
              System.out.println(bpdu2.getComputerName + "is Root Bridge!");
         else
              System.out.println(bpdu3.getComputerName + "is Root Bridge!");
         }

    if (bdpu < bdpu2)
    if (dbpu < bdpu3)
    { dbpu is min. }
    else { bdpu3 is min. }
    else if (bdpu2 < bdpu3)
    { bdpu2 is min. }
    else if (bdpu3 < bdpu2)
    { bdpu3 is min. }
    else [there are two the same]
    {  compare by mac here..
    }If bdpu = bdpu3, and both are less than bdpu2, this will erroneously say that bdpu3 is min (line 4) and never check the macs.
    This type of logic checking could get hairy as the number of items to compare increases beyond 3. Could you store the values in the list as something Comparable (like Strings) and sort them by priority, then mac?

  • Problem in calling arraylist from client

    Hi
    I am trying to execute a webservice program and facing some problems in the
    client side ,am trying to pass arraylist from client in weblogic8.1
    this is my client code and the error i am getting on the serverside all the files
    are getting generated properly,am i missing something.
    i have webserviceclient.jar in the classpath also,
    package examples.webservices.basic.statelessSession;
    import weblogic.utils.Debug;
    import java.util.ArrayList;
    import java.util.Collection;
    import javax.xml.soap.SOAPConstants;
    import javax.xml.namespace.QName;
    import javax.xml.rpc.Service;
    import javax.xml.rpc.encoding.TypeMapping;
    import javax.xml.rpc.encoding.TypeMappingRegistry;
    import weblogic.xml.schema.binding.internal.builtin.JavaUtilArrayListCodec;
    import weblogic.xml.schema.binding.internal.builtin.JavaUtilCollectionCodec;
    public final class Client {
    private final static boolean debug = true;
    private final static boolean verbose = true;
    public Client() {}
    public static void main(String[] argv)
    throws Exception
    HelloWorldEJB_Impl ws = new HelloWorldEJB_Impl(argv[0]);
    HelloWorldEJBPort port = ws.getHelloWorldEJBPort();
    TypeMappingRegistry registry = ((Service)port).getTypeMappingRegistry();
    TypeMapping mapping = registry.getTypeMapping(SOAPConstants.URI_NS_SOAP_ENCODING
    mapping.register(
    ArrayList.class,
    new QName("java:language_builtins.util", "ArrayList"),
    new JavaUtilArrayListCodec(),
    new JavaUtilArrayListCodec()
    mapping.register(
    Collection.class,
    new QName("java:language_builtins.util", "Collection"),
    new JavaUtilCollectionCodec(),
    new JavaUtilCollectionCodec()
    ArrayList arrList = new ArrayList(1);
    arrList.add("ccc");
    arrList.add("bbb");
    port.sayHelloList(arrList);
    The error i am getting while compiling with ant is
    [javac] C:\bea\weblogic81\samples\server\examples\src\examples\webservices\b
    asic\statelessSession\Client.java:92: sayHelloList(java.lang.Object[]) in exampl
    es.webservices.basic.statelessSession.HelloWorldEJBPort cannot be applied to (ja
    va.util.ArrayList)
    [javac] port.sayHelloList(arrList);
    [javac] ^
    [javac] 1 error
    Kindly reply at the soonest
    Sindhu

    Hi
    I tried object[] that was working fine but the requirement for the project
    is that we should use arraylists.i found a solution like i overwrote the xml in
    client.jar but again looks like i have to regenrate the stubs.
    Is there any way to regenerate except using the clientgen
    this time i got
    run:
    [java] java.rmi.RemoteException: null; nested exception is:
    [java] java.lang.ClassCastException
    [java] at examples.webservices.basic.statelessSession.HelloWorldEJBPort
    Stub.sayHelloList(HelloWorldEJBPortStub.java:32)
    [java] at examples.webservices.basic.statelessSession.Client.main(Clien
    t.java:75)
    [java] Caused by: java.lang.ClassCastException
    [java] at weblogic.xml.schema.binding.internal.builtin.JavaUtilCollecti
    onCodec.serializeOneDimArray(JavaUtilCollectionCodec.java:90)
    [java] at weblogic.xml.schema.binding.SoapArrayCodecBase.gatherContents
    (SoapArrayCodecBase.java:442)
    [java] at weblogic.xml.schema.binding.CodecBase.serializeFill(CodecBase
    .java:279)
    [java] at weblogic.xml.schema.binding.CodecBase.serialize_internal(Code
    cBase.java:216)
    [java] at weblogic.xml.schema.binding.CodecBase.serialize(CodecBase.jav
    a:178)
    [java] at weblogic.xml.schema.binding.RuntimeUtils.invoke_serializer(Ru
    ntimeUtils.java:188)
    [java] at weblogic.xml.schema.binding.RuntimeUtils.invoke_serializer(Ru
    ntimeUtils.java:174)
    [java] at weblogic.webservice.core.DefaultPart.invokeSerializer(Default
    Part.java:324)
    [java] at weblogic.webservice.core.DefaultPart.toXML(DefaultPart.java:2
    97)
    [java] at weblogic.webservice.core.DefaultMessage.toXML(DefaultMessage.
    java:619)
    [java] at weblogic.webservice.core.ClientDispatcher.send(ClientDispatch
    er.java:206)
    [java] at weblogic.webservice.core.ClientDispatcher.dispatch(ClientDisp
    atcher.java:143)
    [java] at weblogic.webservice.core.DefaultOperation.invoke(DefaultOpera
    tion.java:444)
    [java] at weblogic.webservice.core.DefaultOperation.invoke(DefaultOpera
    tion.java:430)
    [java] at weblogic.webservice.core.rpc.StubImpl._invoke(StubImpl.java:2
    70)
    [java] at examples.webservices.basic.statelessSession.HelloWorldEJBPort
    Stub.sayHelloList(HelloWorldEJBPortStub.java:26)
    and my xml i changed this way
    <wsdd:type-mapping xmlns:wsdd="http://www.bea.com/servers/wls70"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
    <wsdd:type-mapping-entry xmlns:p1="java:language_builtins.util"
    type="p1:ArrayList"
    class-name="java.util.ArrayList"
    serializer="weblogic.xml.schema.binding.internal.builtin.JavaUtilArrayListCodec"
    deserializer="weblogic.xml.schema.binding.internal.builtin.JavaUtilArrayListCodec">
    </wsdd:type-mapping-entry>
    </wsdd:type-mapping>
    Sindhu
    "jas" <[email protected]> wrote:
    >
    If you haven't already ... please see the thread below .. This might
    be of sokme
    use
    http://newsgroups.bea.com/cgi-bin/dnewsweb?cmd=article&group=weblogic.developer.interest.webservices&item=4378&utag=
    cheers
    jas
    "sindhu" <[email protected]> wrote:
    Hi
    I am trying to execute a webservice program and facing some problems
    in the
    client side ,am trying to pass arraylist from client in weblogic8.1
    this is my client code and the error i am getting on the serversideall
    the files
    are getting generated properly,am i missing something.
    i have webserviceclient.jar in the classpath also,
    package examples.webservices.basic.statelessSession;
    import weblogic.utils.Debug;
    import java.util.ArrayList;
    import java.util.Collection;
    import javax.xml.soap.SOAPConstants;
    import javax.xml.namespace.QName;
    import javax.xml.rpc.Service;
    import javax.xml.rpc.encoding.TypeMapping;
    import javax.xml.rpc.encoding.TypeMappingRegistry;
    import weblogic.xml.schema.binding.internal.builtin.JavaUtilArrayListCodec;
    import weblogic.xml.schema.binding.internal.builtin.JavaUtilCollectionCodec;
    public final class Client {
    private final static boolean debug = true;
    private final static boolean verbose = true;
    public Client() {}
    public static void main(String[] argv)
    throws Exception
    HelloWorldEJB_Impl ws = new HelloWorldEJB_Impl(argv[0]);
    HelloWorldEJBPort port = ws.getHelloWorldEJBPort();
    TypeMappingRegistry registry = ((Service)port).getTypeMappingRegistry();
    TypeMapping mapping = registry.getTypeMapping(SOAPConstants.URI_NS_SOAP_ENCODING
    mapping.register(
    ArrayList.class,
    new QName("java:language_builtins.util", "ArrayList"),
    new JavaUtilArrayListCodec(),
    new JavaUtilArrayListCodec()
    mapping.register(
    Collection.class,
    new QName("java:language_builtins.util", "Collection"),
    new JavaUtilCollectionCodec(),
    new JavaUtilCollectionCodec()
    ArrayList arrList = new ArrayList(1);
    arrList.add("ccc");
    arrList.add("bbb");
    port.sayHelloList(arrList);
    The error i am getting while compiling with ant is
    [javac] C:\bea\weblogic81\samples\server\examples\src\examples\webservices\b
    asic\statelessSession\Client.java:92: sayHelloList(java.lang.Object[])
    in exampl
    es.webservices.basic.statelessSession.HelloWorldEJBPort cannot be applied
    to (ja
    va.util.ArrayList)
    [javac] port.sayHelloList(arrList);
    [javac] ^
    [javac] 1 error
    Kindly reply at the soonest
    Sindhu

Maybe you are looking for

  • How to send E-mails using JSP

    I developed a system where users can login and check for updated information and documents. But the changes are made once or twice in a year. I want to send email after changing the documents. I stored email addresses in the DB. Now the question is h

  • Credit Note for Item Category ERLA

    Hi, We have a scenario wherein a Customer is to be issued a Credit Note for Price Difference. The material has Item Category ERLA. Excise Duties & VAT is also there. Kindly suggest a solution on this. Thanks & Regards, Khushal Agrawal

  • Webservice deployed on Sun Java System Application Server PE 8.2 (b06-fcs)

    I have deployed a simple web service on Sun One AS PE 8.2 (Can see the WSDL file on URL invocation). I am getting the following server side runtime exception when a standalone client tries to invoke the web service endpoint. A similar exception is re

  • Transfer iMovie 08 Project from one computer to another

    I created an iMovie 08 project on my macbook pro. The footage came from a digital still camera on video mode as opposed to a video recorder. I then attempted to transfer the iMovie project to my iMac which I use to sync with my Apple TV. I transferre

  • Broken arrow but no errors?

    I have a VI that has a broken run arrow but displays no errors when I clicked the broken arrow. I can find no obvious errors on the diagram. It was working fine and then I added another control to a cluster and it started giving me the broken arrow.