Iterating SortedSet

I am delving into the ins and outs of SortedSets, and I've encountered a problem.
At times, it is useful to know the index of the set, such as when manipulating an array, we might declare i as an index, and use that value for a whole bunch of reasons.
I've fudged something by converting my SortedSet to an Array, and manipulating the Array as usual. I've also fudged an index value to achieve the same thing.
I've noted that List has a .get() method which (appears) to take an int value just like an array index.
What I'd really like to do is be able to grap a specific element out of my SortedSet based on some index value. For example:
if s is a SortedSet...
for (int i = 0; i < s.size(); i++){
    // do some stuff based on "i" like get the i-th value in s
}I've been reading about wrappers, collections, and so on, but I can't figure out how to do this. Is it even possible?

If you're doing it in a loop from 0 to size(), then you should be using an Iterator. This is true for all collections.
for (Iterator iter = theSet.iter(); iter.hasNext(); ) {
    MyThingie thing = (MyThingie)iter.next();
    // do stuff with thing
or, using the enhanced for loop of 5.0: for (MyThingie thing : theSet) {
// do stuff with thing
If you just want to randomly access a one or a few of the elements, then the easiest thing to do would be to put the contents of the set into an array (using Set's toArray method) or into an ArrayList (using ArrayList c'tor that takes a Collection as an arg).
Sets don't have a get(i) method because unlike Lists, Sets to not have an inherent order. They're more like a box full of things. It seems like it would make sense for SortedSet to have get(i) though, since sorting implies an order. I don't know why it doesn't.

Similar Messages

  • Regarding Set and SortedSet

    In the collection API, SortedSet implements Collection and Set interfaces. Why does it implement Collection when Set is already a subclass of Collection ?

    in your first post, you said
    In the collection API, SortedSet implements Collection and Set interfaces. Why does it
    implement Collection when Set is already a subclass of Collection ?Set interface extends Collection...
    SortedSet interface extends Set and it is not implementing Collection.
    here is the title of the SoretedSet interface (javadoc 1.5):
    java.util
    Interface SortedSet<E>
    All Superinterfaces:
        Collection<E>, Iterable<E>, Set<E>
    All Known Implementing Classes:
        TreeSet SortedSet inherits Collection methods by Set interface...

  • SortedSet

    Hello.
    I need some help. I have to store some data (type : object) in sortedset, but I have no idea on how to implement it. In my object, it has a parameter unique ID in type double. and I would like it sorted based on this unique ID. Could anyone tell me how could I do this ? How to implement the comparable, compareTo, etc. I would be very happy also, if someone could provide some small example. Thank you very much.

    The example below demonstrates creating 10 objects of the type you describe, in any order, and using SortedSet to store them / retrieve them in order.
    import java.util.Iterator;
    import java.util.SortedSet;
    import java.util.TreeSet;
    public class MyComparable implements Comparable
            static java.util.Random ran = new java.util.Random();
            double d = ran.nextDouble();
            public int compareTo(Object o)
                    MyComparable other = (MyComparable) o;
                    if(d < other.d) return -1;
                    else if(d > other.d) return 1;
                    else return 0;
            public boolean equals(Object o)
                    return compareTo(o) == 0;
            public String toString()
                    StringBuffer sb = new StringBuffer();
                    sb.append("<MyComparable ");
                    sb.append(d);
                    sb.append(">");
                    return sb.toString();
            public static void main(String [] as)
                    SortedSet ss = new TreeSet();
                    for(int i=0; i<10; i++)
                            MyComparable myComp = new MyComparable();
                            System.out.println(" created " + myComp);
                            ss.add(myComp);
                    Iterator it = ss.iterator();
                    while(it.hasNext())
                            System.out.println(it.next());
    [D:/Skrabacz/Devel/try/forum] java MyComparable
    created <MyComparable 0.7677724511588107>
    created <MyComparable 0.46700033841632393>
    created <MyComparable 0.2133779399400303>
    created <MyComparable 0.9617326444195208>
    created <MyComparable 0.5790019143376731>
    created <MyComparable 0.8958425738672053>
    created <MyComparable 0.5299211773413368>
    created <MyComparable 0.7813779119080679>
    created <MyComparable 0.5814540188890048>
    created <MyComparable 0.4691780946123787>
    <MyComparable 0.2133779399400303>
    <MyComparable 0.46700033841632393>
    <MyComparable 0.4691780946123787>
    <MyComparable 0.5299211773413368>
    <MyComparable 0.5790019143376731>
    <MyComparable 0.5814540188890048>
    <MyComparable 0.7677724511588107>
    <MyComparable 0.7813779119080679>
    <MyComparable 0.8958425738672053>
    <MyComparable 0.9617326444195208>
    [D:/Skrabacz/Devel/try/forum]

  • Double Iteration selectManyCheckbox

    Hey,
    I've been searching for a while now.
    I have a class Locatie which consists out of an association with the class LocatieItem. Now I need to have a list with checkboxes for al the LocatieItem classes.
    Now I've got this iteration:
    <h:selectManyCheckbox value="#{basisOpties.locatieItemIds}" layout="pageDirection">
        <h:dataTable value="#{basisOpties.locatieLijst}" var="l">
            <h:column>
                <h:outputText value="#{l.naam}"/>
            </h:column>
            <h:column>                       
                <h:dataTable value="#{l.arrayListLocatieItems}" var="li">
                    <h:column>
                        <f:selectItem itemValue="#{li.id}" itemLabel="#{li.naam}"/>
                    </h:column>
                </h:dataTable>
            </h:column>
        </h:dataTable>
    </h:selectManyCheckbox>now I don't get any checkbox'es
    I also tried <h:selectBooleanCheckbox value="#{li.id}"/> but I got this error message
    sourceId=j_id_id47:j_id_id139:4:j_id_id148:2:j_id_id152[severity=(ERROR 2), summary=(j_id_id47:j_id_id139:4:j_id_id148:2:j_id_id152: An error occurred when processing your submitted information. ), detail=(j_id_id47:j_id_id139:4:j_id_id148:2:j_id_id152: An error occurred when processing your submitted information. )]

    thank you very much, but it seems that the semantics it's not the same as my goal.
    if we call P(I,J) the part where we //do something with I and J where I and J are two object of the collection,
    your code is doing P( L_1 , L_2) , P(L_2, L_3) , P(L_3, L_4) ,...
    wehre L_x = the x-th element returned by the iterator,
    but it is never doing P( L_1, L_4) for instance.
    I want to execute P( L_i , L_j ) forall i,j such i<j.
    I came about with this solutions, still have to test it thorughout.
    I am not sure about complexity:
            SortedSet idSet = (SortedSet) myCatalog.keySet();
            for (Iterator i = idSet.iterator(); i.hasNext(); ) {
                 String id1 = (String) i.next();
                 SortedSet remainingID = idSet.tailSet(id1);
                 for (Iterator j = remainingID.iterator(); j.hasNext(); ) {
                      String id2 = (String) j.next();
                          //do something with id1 and id2About this declaration:
      SortedSet idSet = (SortedSet) myCatalog.keySet(); when casting to a SortedSet, does the jvm look that the objects in keySet are actually String and so sort among String? or should I tell it somehow?

  • Remove and SortedSet

    Hi all,
    I'm just trying to remove the first item from a sorted set yet for some reason I'm having no luck. Here's the code
    public class Main
        static  private Comparator smallestDistanceo = new Comparator ()
            public int compare (Object v, Object u)
               return compare ((Integer) v, (Integer) u);
            public int compare (Integer v, Integer u)
                int results = v.intValue () -  u.intValue ();
                if(results == 0)
                    return -1;
                else
                    return results;
        static SortedSet test = new TreeSet (smallestDistanceo);
        public static void main (String[] args)
            test.add (new Integer(3));
            test.add (new Integer(1));
            test.add (new Integer(2));
            for(Iterator i = test.iterator (); i.hasNext ();)
                Integer curr=(Integer)i.next ();
                System.out.print (curr.intValue ());
            if(test.remove(first))
                System.out.print("\nRemoved\n");
            else
                System.out.print("\nNot Removed\n");
            for(Iterator i = test.iterator (); i.hasNext ();)
                Integer curr=(Integer)i.next ();
                System.out.print (curr.intValue ());
    }Yet for some reason the list just keeps coming back with nothing removed.
    I'm sure it just something simple but can't see it for the life of me. Any ideas?

    Yet for some reason the list just keeps coming back with nothing
    removed. I'm sure it just something simple but can't see it for the life
    of me. Any ideas?Your Comparator is broken: even if two objects are equal, you
    return -1 indicating that the left operand object is smaller than the right
    operand object, iow: your comparator never treats two objects as equal.
    Even more: if you populate your SortedSet with Integers, you
    don't need a user supplied Comparator at all; Integers know perfectly
    well how to compare themselves against other integers.
    The solution is simple: remove your Comparator and let the built-in
    Integer comparator do the rest together with the SortedSet.
    kind regards,
    Jos

  • Query update on each iteration problem (MS SQL Sever / ODBC / Native Driver

    Hello,
    I�ve been working to learn some Java and now JDBC over the past 10 or so months.
    I think I have a general understanding of how to perform queries and work with data using JDBC. However, I�ve run into a problem. I�m trying to do a query of a set of data in a database based on the value of a status column. I want to loop over the messages and perform various functions with the data then update their status in the database. It�s preferable to do these 250 to 1000 rows at a time, but no more and no less.
    I�m connecting to MS SQL Server 2000, currently with ODBC. I�ve also tried it with the Java SQL Server 2000 drivers provided by Microsoft with the same results.
    I�ve found that I can do a one table query and loop though it with a while (rs.next()) {�} and run an Update statement with executeUpdate on each iteration without any problems, no matter the number of rows returned in query.
    I have not been able to use the updateString and updateRow inside the while loop. I keep getting errors like this at the line with the updateRow():
    Exception in thread "main" java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Row update failed.
    This occurs no mater how many rows I select, 1 or more.
    The real problem I�ve been having is that the query I need to loop though joins across several tables and returns some rows from some of those tables. This only seems to work when I query for 38 or less selected rows and I use an Update statement with executeUpdate on each iteration. The updateString and updateRow methods never work. Any number of rows selected greater than 38 causes a deadlock where the Update is waiting for the select to compete on the server and the Update can�t proceed until the Select is complete.
    As I stated above I�ve tried both ODBC and the native SQL Server driver with the same results. I have not tried any other databases, but that�s moot as my data is already in MS SQL.
    Questions:
    How can I avoid or get around this 38 row limit without selecting each row, one at a time?
    What am I doing wrong with the updateString and updateRow?
    Is there a better approach that anyone can suggest?
    Here�s some sample code with the problem:
    import java.sql.*;
    public class db1{
         public static void main(String[] args) throws Exception{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              String url = "jdbc:odbc:eBrochure_live";
              Connection con = DriverManager.getConnection(url, "sa", "d3v3l0p");
              Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
              Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://dcm613u2\\dcm613u2_dev:1433", "sa", "d3v3l0p");
              Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
              Statement stmt2 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
              stmt.executeUpdate("USE [myDatabase]");
              stmt2.executeUpdate("USE [myDatabase]");
              String qGetMessages = "SELECT TOP 250 t1.messageUUID, t1.subjectHeader, t2.emailAddress as toAddress " +
              "FROM APP_Messages as t1 JOIN APP_addressBook_contacts as t2 " +
              "     On t1.toContactID = t2.contactID " +
              "WHERE t1.statusID = 'queued'";
              ResultSet rs = stmt.executeQuery(qGetMessages);
              while (rs.next()) {
                   String messageUUID = rs.getString("messageUUID");
                   String subjectHeader = rs.getString("subjectHeader");
                   System.out.println(messageUUID + " " + subjectHeader);
                   String updateString = "UPDATE APP_Messages " +
                        "SET statusID = 'sent' " +
                        "WHERE messageUUID = '" + messageUUID + "' ";
                   stmt2.executeUpdate(updateString);
              con.close();
    Thanks for the help,
    Doug Hughes

    // sorry, ps.close() should be outside of if condition
    String sql = "UPDATE APP_Messages SET statusID = 'sent' WHERE messageUUID = ?";
    Statement statement = con.createStatement();
    PreparedStatement ps = con.prepareStatement(sql);
    ResultSet rs = statement.executeQuery("your select SQL");
    if ( rs.next() )
    ps.clearParameters();
    ps.setString(1, rs.getString("your column name"));
    ps.executeUpdate();
    ps.close();
    rs.close();
    statement.close();

  • Not able to update data in iterator

    Our scenario is something like this:
    We do not directly bind UI components to VO, that is, for example we do not directly drag and drop a VO as a table. Instead we use POJO to exchange data between the UI and model layers.
    Our requirement is to show form with pagination. If there are 5 records we show each record in form layout with navigation keys to show next, previous, first and lat records.
    Since we do not bind the data directly to VO, the form data is coming from pojo. Our implementation is as below
    A java class named personPojo with fields
    fname
    lname
    code
    A method getAllPersons which queries all the person records from db table, populates it in a list<personPojo> and returns this list.
    We are using an iterator which is based on this List<personPojo> that is returned from the method. Inside this iterator we have a panelFormLlayout with input components mapped to the pojo fields as below
    <af:iterator value="sampleBackingBean.getAllPersons" var="row"
                   id="i4">
              <af:inputText value="#{row.fname}" id="it6">
    <af:inputText value="#{row.lname}" id="it7">
    <af:inputText value="#{row.code}" id="it8">
         </af:iterator>
    The problem we are facing is, when we update the fields in the form, the data is not getting stored in the field of the pojo. That is, if currently 3rd record/element is shown from the list and we update name to "John". Then click on next button to go to next record and update name to "Smith". Now on clicking previous, we should be able to see the name "John", instead in our case no data is shown. But, if we hard code the data in the list, then the list shows the data properly. The issue is when we update it does not show the updated value as it is not getting set in the pojo. We have made sure the pagination works fine, that is clicking next or previous is correctly showing the records
    Can you please let us know what we may be missing here or if you have any other suggestions to implement a form with pagination

    hi,
    Hope following useful
    http://docs.oracle.com/cd/E12839_01/apirefs.1111/e12419/tagdoc/af_iterator.html
    http://blogs.oracle.com/shay/entry/working_with_the_afiterator_co

  • What is difference between Iterator and Collection Wrapper?

    Hi all,
                  I dont understand the actual difference between Iterator and Collection Wrapper. I observed both are used for the same purpose. Could any one please let me know when to use Collection Wrapper and when to use Iterator??
    Thanks,
    Chinnu.

    L_Kiryl is right.
    Collections support global iteration (through collection->get_next( )) and local iteration (through iterator->get_next( )).
    Each collection has a focus object. Initially, the first object has the focus.
    Any global iteration moves the focus, which is published by the event FOCUS_CHANGED of the collection.
    If you want to iterate on the collection without moving the focus (and without triggering timeconsuming follow-up processes) you can use local iteration. To do so, request an iterator object from the collection and use this to iterate.
    And one more advantage of using iterator: it takes care of deleted entities. If you use global iteration then when you reach deleted entity it will be an exception. But there is no exception with iterator in the same situation.

  • InputText value is not getting updated in Iterator

    Hi All,
    We are using jdeveloper 11.1.1.5.
    I have having 2 bounded taskflows TF1 and TF2. In TF1 I am having Page1.jspx and in
    TF 2 I have Page2.jspx.
    I am having 1 page fragment Frag1.jsff inside that I am having 1 textbox and a button. Text box is binded to the iterator "iter1".
    In Page1.jspx I have added fragment as a region and also I have added the iterator "iter1" in the bindings of page1.jspx
    On page load I am getting the value in the text box after that I am updating the text
    box value and on click of button I am trying to get the text box value using
    following methods.
    (1) Finding the Iterator getting the row and then finding the value as
    Row.getAttribute("Name");
    DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("IName of the Iterator");
    Row row = dciter.getRowAtRangeIndex(0);
    row.getAttribute("Name of the attribute);
    (2) Finding the RichSelectOneChoice component and then getting value
    RichSelectOneChoice textbox= jsfUtils.findComponentInRoot("ID of the component");
    textbox.getValue();
    (3) Using the page definition attribute as :-
    +jsfUtils.resolveExpression("#{data.PageDefName.inputtextname.inputValue}");+
    Every time I am getting null value. Is there anything I am missing here.
    When I applied autosubmit="true" property on the textbox I am getting value from the
    1st method.
    *Question 1 : - Is it necessary to use autosubmit property on the text box for the values to get updated in Iterator ?*
    *Question 2 : - Why I am not able to find the value using 2nd method ?*
    *Question 3 : - Is there anything wrong in getting value from page definition using 3rd method?*
    Now When on click on button on page1 on some condition, I am navigating it to page2
    and there is a button on page2 which invokes the TaskFlow return activity and so
    returning back to TF1.
    Now again I am clicking on the button on page1 but this time again I am getting value
    of the textbox as null using all the methods :(
    I have checked various post and tried putting *changeEvent="ppr"* in ur pageDef
    against the respective VO entry but still after returning back from TF2 to TF1 values
    are lost in the Iterator.
    I tried sharing data control with calling taskflow but still I am not getting the
    updated values.
    Please suggest.
    Thanks in advance.
    --NavinK

    Hi Suresh,
    I already have autoSubmit=true for input text and partialSubmit=true for button but still getting the same error.
    --Navin K                                                                                                                                                                                                                                                                                       

  • Displaying the results of an iterator in JTextfields.

    Hi people,
    I have got two methods which basically iterate through statements (forward and back).
    However I have a separate class which is basically the GUI for my program. I want the user to be able to click the next button and it iterates through the list and displays the element in the list in the JTextField.
    The problem I am having is that it will not display the element in the predefined fields, does anyone know how I can go about this? My code for my two methods is below:
    public void MusicNext()
               try
               if(titerator==null)
                   titerator = iList.listIterator();
               if(titerator.hasNext())
                   System.out.println(titerator.next());//Just prints out the iterator atm.
               else
                  titerator = null;
                  MusicNext();
               catch(ConcurrentModificationException ex)
                  titerator = iList.listIterator();
                  System.out.println("Iterator has been reset.");
              public Music MusicNext(String pTitle)
                Music tTitle = null;
             boolean found = false;
                Iterator it = iList.iterator();
                if(it.hasNext() && !found)
              tTitle = (Music) it.next();
              found = tTitle.getTitle().equalsIgnoreCase(pTitle);
                return tTitle;
            public void MusicPrevious()
               try
               if(titerator==null)
                   titerator = iList.listIterator();
               if(titerator.hasPrevious())
                   System.out.println(titerator.previous());//Just prints out the iterator atm.
               else
                  titerator = null;
               catch(ConcurrentModificationException ex)
                  titerator = iList.listIterator();
                  System.out.println("Iterator has been reset.");
               catch(NoSuchElementException ex)
                  //titerator = iList.listIterator();
                  System.out.println("No such element.");
         }I am pretty sure they shouldn't be void but should return an element, but I am really not sure what to return.
    Many Thanks,
    Rob.
    (Sorry I posted this before but I left out alot of detail).

    Don't get or instantiate the iterator in often-called methods.
    It should be get or instantiated as a class global field once and for all.
    Your ListIterator is good for such treatment becuase it can be
    freely scanned backward, while Iterator can't.

  • How to pick max value from a column of a table using cursor and iteration

    Hello Everybody
    I have a table loan_detail
    and a column in it loan_amount
    now i want to pick values from this table using cursor and then by using iteration i want to pick max value from it using that cursor
    here is my table
    LOAN_AMOUNT
    100
    200
    300
    400
    500
    5600
    700i was able to do it using simple loop concepts but when i was trying to do this by using cursor i was not able to do it .
    Regards
    Peeyush

    SQL> SELECT MAX(sal) Highest_Sal,MIN(sal) Lowest_Sal FROM emp;
    HIGHEST_SAL LOWEST_SAL
           5000        800
    SQL> set serverout on
    SQL> DECLARE
      2    TYPE tmp_tbl IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
      3    sal_tbl tmp_tbl;
      4    CURSOR emp_sal IS
      5      SELECT sal FROM emp;
      6    counter INTEGER := 1;
      7  BEGIN
      8    FOR i IN emp_sal LOOP
      9      sal_tbl(i.sal) := counter;
    10      counter := counter + 1;
    11    END LOOP;
    12    DBMS_OUTPUT.put_line('Lowest SAL:' || sal_tbl.FIRST);
    13    DBMS_OUTPUT.put_line('Highest SAL:' || sal_tbl.LAST);
    14  END;
    15  /
    Lowest SAL:800
    Highest SAL:5000
    PL/SQL procedure successfully completed.
    SQL> Even smaller
    SQL> DECLARE
      2    TYPE tmp_tbl IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
      3    sal_tbl tmp_tbl;
      4    CURSOR emp_sal IS
      5      SELECT sal FROM emp;
      6    counter INTEGER := 1;
      7  BEGIN
      8    FOR i IN emp_sal LOOP
      9      sal_tbl(i.sal) := 1;
    10    END LOOP;
    11    DBMS_OUTPUT.put_line('Lowest SAL:' || sal_tbl.FIRST);
    12    DBMS_OUTPUT.put_line('Highest SAL:' || sal_tbl.LAST);
    13  END;
    14  /
    Lowest SAL:800
    Highest SAL:5000
    PL/SQL procedure successfully completed.
    SQL> Edited by: Saubhik on Jan 5, 2011 4:41 PM

  • Removing duplicate values from selectOneChoice bound to List Iterator

    I'm trying to remove duplicate values from a selectOneChoice that i have. The component binds back to a List Iterator on the pageDefinition.
    I have a table on a JSF page with 5 columns; the table is bound to a method iterator on the pageDef. Then above the table, there are 5 separate selectOneChoice components each one of which is bound to the result set of the table's iterator. So this means that each selectOneChoice only contains vales corresponding to the columns in the table which it represents.
    The selectOneChoice components are part of a search facility and allow the user to select values from them and restrict the results that are returned. The concept is fine and i works. However if i have repeating values in the selectOneChoice (which is inevitable given its bound to the table column result set), then i need to remove them. I can remove null values or empty strings using expression language in the rendered attribute as shown:
    <af:forEach var="item"
    items="#{bindings.XXXX.items}">
    <af:selectItem label="#{item.label}" value="#{item.label}"
    rendered="#{item.label != ''}"/>
    </af:forEach>
    But i dont know how i can remove duplicate values easily. I know i can programatically do it in a backing bean etc.... but i want to know if there is perhaps some EL that might do it or another setting that ADF gives which can overcome this.
    Any help would be appreciated.
    Kind Regards

    Hi,
    It'll be little difficult removing duplicates and keeping the context as it is with exixting standard functions. Removing duplicates irrespective of context changes, we can do with available functions. Please try with this UDF code which may help you...
    source>sort>UDF-->Target
    execution type of UDF is Allvalues of a context.
    public void UDF(String[] var1, ResultList result, Container container) throws StreamTransformationException{
    ArrayList aList = new ArrayList();
    aList.add(var1(0));
    result.addValue(var1(0));
    for(int i=1; i<var1.length; i++){
    if(aList.contains(var1(i)))
         continue;
    else{
    aList.add(var1(i));
    result.addValue(var1(i));
    Regards,
    Priyanka

  • Write to measurement file at every n iterations

    Hi guys,
    I would like some help with saving data in labview 2010 SP1 (base development system). I am using a "Write to measurement fil express VI" inside a while loop and the data out from the DAQmn Read is wired to the signal in of the "Write to measurement fil express VI".
    The way I have wired it is the VI saves the data as a text file after it has recorded 100 samples (the nuber of samples to read in this case was set to 100). I would like to know if there is a way to control the rate at which the express VI saves the data. As in, I want the express VI to save the data at specified time interval or at every nth iteration. I have attached the main VI and its 2 sub-VIs for reference. Please let know if anyone can help me resolve this issue. Thank you for your time and inputs in this regard.
    Raj

    Robert,
    First, you must understand that the above code resides inside a loop. The blue square i terminal is known as the iteration terminal. It provides the current loop iteration count, starting from zero.
    The first input (x) to the Quotient & Remainder Function comes from this iteration count (i) terminal of the loop.
    The second input (y) to the Quotient & Remainder Function comes from the control N.
    We wish to write to the measurement file every N iterations of the loop. If we take our current iteration count (i) and divide by our desired N, every Nth iteration of the loop, the remainder will be zero. For all other iterations, the remainder will be non-zero.
    That being said, we check the remainder and compare it to zero. If it is zero, we will send a True value to the Enable terminal on the Write To Measurement File Express VI. Any time a True value is sent, we will write to file. Anytime a False value is sent, nothing will be written to the file.
    The green new_file input on the Write To Measurement File Express VI is used when the "Save to series of files (multiple files)" radio button is selected in the Configure dialog box of this Express VI. When "Save to one file" is selected, this option does not apply, and so it is not included in the input list, which is why you are not seeing this.
    This new_file input is used to tell the Write To Measurement File Express VI when to start writing to a new file.
     

  • Af:iterator and getting values from a particular row

    Hi,
    I am using af:iterator to loop through a resultSet in a VO.
    <af:iterator binding="#{backingBeanScope.backing_subscribe.i1}"
    value="#{bindings.SubscriptionPublicView1.collectionModel}"
    var = "row"
    id="i1">
    For each iteration, I display a row of data from my VO in a panel box.
    Each panel box has a command Link.
    Usually, from my backing bean, I do something like this to get an attribute off of a view Iterator.
    Row currentRow = getIterator("SubscriptionPublicView1Iterator").getCurrentRow();
    int sid = (Integer)currentRow.getAttribute("Sid");
    However, in this case, I am always getting the 'sid' from the first record in the collectionModel, and not the 'sid' that corresponds to the commandLink that is selected by the user.
    What is the best way to do this when using an af:iterator?
    Thanks,
    Joel

    Hi,
    Timo - as usual - is correct. Using an iterator does not guarantee that selecting a row is set as current in the ADF binding. For this you need to use an action listener on the command component you click on. To get the rowKey of the selected row, you can use a setPropertyListener on the command link that writes the row key of the selected item into memory
    <af:setPropertyListener from="#{row.key} to="#{viewScope.key}" type="action"/>
    This value then can be looked up in the managed bean to set the row as current in the ADF binding
    Frank

  • How to get iterator values from a managed bean ?

    Due to a bug in selectOneChoice i'm not able to get the label list i want to display directly from an iterator when the value binding is a managed bean.
    To solve the problem i would like to create a managed bean that contains that list and use it as the selectItems to display.
    I would like that the values in that managed bean loaded from the a data control iterator.
    My question is :
    1) is it possible to access the iterator values from a managed bean, i mean without any reference to a page definition
    2) how to do ? is it documented somewhere ? any example ?
    Thank you

    I got it also with this code:
    package view.managedBeans;
    import classification.bean.ClassificationDocument;
    import classification.castor.ClassificationLanguage;
    import java.io.FileNotFoundException;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Hashtable;
    import java.util.List;
    import java.util.Locale;
    import javax.faces.context.FacesContext;
    import javax.faces.el.ValueBinding;
    import javax.faces.model.SelectItem;
    import oracle.adf.model.generic.DCGenericDataControl;
    import org.exolab.castor.xml.MarshalException;
    import org.exolab.castor.xml.ValidationException;
    public class ClassificationLanguageList {
    private java.util.List<SelectItem> supportedLanguages = new ArrayList();
    public ClassificationLanguageList() throws FileNotFoundException,
    MarshalException,
    ValidationException {
    FacesContext ctx = FacesContext.getCurrentInstance();
    ValueBinding vb = ctx.getApplication().createValueBinding("#{data.ClassificationDocumentDataControl}");
    DCGenericDataControl classificationDocumentDataControl = (DCGenericDataControl)vb.getValue(ctx);
    ClassificationDocument classificationDocument = (ClassificationDocument)classificationDocumentDataControl.getDataProvider();
    ClassificationLanguage[] classificationLanguage = classificationDocument.getClassification().getClassificationLanguageList().getClassificationLanguage();
    for (int counter = 1; counter < classificationLanguage.length; counter++) {
    SelectItem language = new SelectItem();
    language.setValue(classificationLanguage[counter].getClassificationLanguageCode());
    language.setLabel(classificationLanguage[counter].getClassificationLanguageLabel());
    supportedLanguages.add(language);
    public void setSupportedLanguages(java.util.List<SelectItem> supportedLanguages) {
    this.supportedLanguages = supportedLanguages;
    public java.util.List<SelectItem> getSupportedLanguages() {
    return supportedLanguages;
    }

Maybe you are looking for

  • How to get which query is using by reports using OEM

    Hi, can any one help me how to get the queries whcih are used by reports by clent by using OEM. Its same like using profiler in sql server Thanks in advance Edited by: user8884944 on Nov 6, 2010 2:18 AM

  • 1KEK posting the reversal documents to dummy profit centre.

    Hi expertise, First let me explain the scenario. Through FB60, I posted a document as per the below: Doc date : 23.07.2007, Period: 8, Posting date : 17.08.2007, Doc type : KR. PK    Account            Profit Centre       Amount 31    14898 - Vendor 

  • My I-phone 4 is using too much memory storage.  Data

    My I-Phone 4 is using too much memory.  It shows Apps at 1.44 and Data & Documents at 1.68, not to mention "other" using up more memory.  I have tried eliminating apps but nothing changes.  How does one get rid of some of this "stuff" that is using u

  • BAPI_TRANSACTION_COMMIT is releasing all the locks which aren't intended to

    Hi All, I have created a GR using BAPI "BAPI_GOODSMVT_CREATE"  and then the changes are commited using BAPI_TRANSACTION_COMMIT. And this is releasing all the locks which were not intended to GR. Please help me how to retain the locks. regards, Prasad

  • Keyboard Shortcuts - Bridge CS3

    Hello, I am trying to figure out what my keyboard shortcuts are for Bridge CS3 on a Windows machine.  That is the set up I am working on currently for a contract job. Primarily, I am trying to find a quick way to navigate and modify multiple file nam