Iterator class

hi
I have created a program which uses a table view and iteratorclass to diaplay a table .but  my program is not able to identify the iterator class ,i have created an iterator instance in my model class attributes ...am not getting any error but its just displaying the table ...here is the code........if its not correct please help me out with the write code..
<htmlb:tableView id            = "tc"
                 design              = "ALTERNATING"
                 headerText          = "Header Text"
                 onNavigate          = "onMyNavigate"
                 selectionMode       = "SINGLESELECT"
                 onRowSelection      = "onMyRowSelection"
                 table               = "<%=model->ITAB1%>"
                 iterator            = "<%=model->my_iterator%>"
                 visibleRowCount     = "15"   />
interface implementation.......
if_htmlb_tableview_iterator~get_column_definitions..............
field-symbols: <def> like line of p_column_definitions.
append initial line to p_column_definitions assigning <def>.
  <def>-columnname = 'ebeln'.
  <def>-title      = 'PO_NUMBER'.
  append initial line to p_column_definitions assigning <def>.
  <def>-columnname = 'EBELP'.
  <def>-title      = 'PO_LINE_ITEM_NUMBER'.
  append initial line to p_column_definitions assigning <def>.
  <def>-columnname = 'matnr'.
  <def>-title      = 'material_number'.
  append initial line to p_column_definitions assigning <def>.
  <def>-columnname = 'menge'.
  <def>-title      ='quantity'.
  <def>-edit = 'X'.
  append initial line to p_column_definitions assigning <def>.
  <def>-columnname = 'gewei'.
  <def>-title      ='Unit Of Measurement'
  <def>-edit = 'X'.
method if_htmlb_tableview_iterator~render_row_start .
  m_row_ref ?= p_row_data_ref.
endmethod.
method if_htmlb_tableview_iterator~render_cell_start .
  data :itab type zmy_tt.
  field-symbols: <q> type itab ,
  <v2> type i .
  data: var2 type string .
  assign p_row_data_ref->* to <q>.
  case p_column_key.
    when 'quantity'.
      assign component p_column_key of structure <q> to <v2>.
      if <v2> is assigned .
        var2 = <v2> .
      endif .
      if var2  gt 100.
        p_replacement_bee = cl_htmlb_inputfield=>factory(
                                 id        = p_cell_id
                                 disabled = 'true' ).
      endif.
  endcase.
endmethod.
Thanks ,
Raju

my_iterator instancevariable  public type ref to zcl_it_details.
do u mean the itab1 thats passed to table view ?
it has values ,i have checked it in debugging mode.
in this method
if_htmlb_tableview_iterator~render_row_start
how the m_row_ref must be declared ? is it the structure type of itab1?
Message was edited by:
        raju msm

Similar Messages

  • Is Iterator class really necessary for our lifes?

    I'm reading about Iterator class and how to use it, but a doubt arrise. Is it really necessary?
    Take a look at my code bellow:
    import java.util.*;
    public class Main {
        public static void main(String[] args) {
            ArrayList ar = new ArrayList();
            for (int i=0;i<20;i++)
                ar.add(i);
            //Method 1
             for(int i=0;i<ar.size();i++)
                if (((Integer)ar.get(i) % 2) != 0)
                    ar.remove(i);
            //Method 2
            Iterator it = ar.iterator();
            while(it.hasNext())
                if (((Integer)it.next() % 2) != 0)
                    it.remove();
            System.out.println("The even numbers are: ");
            for(int i=0;i<ar.size();i++)
                System.out.println((Integer)ar.get(i));
    }In the code above, we have two ways to do the same thing, both works fine, but using the Method 2 I needed to code one line more instancing a new class Iterator.
    Can anyone tell me in which circuntances I really need to use a Iterator and why?
    Thanks

    Additionally, Iterator works on all Collections. For Sets, there is no get(i). If you have a method that returns a Collection, and that Collection might be a LinkedList or an ArrayList or a HashSet or something else, the Iterator is the gauranteed way to walk through it, regardless of what class it is. And with enhanced for loop, it's quite clean and simple.
    Collection<Thing> things = thingFetcher.fetchACollectionOfThings(); // LinkedList? HashSet? We don't know and don't care
    for (Thing thing : things) {
      thing.doStuff();
    }

  • Urgent!!!How to add a Dropdown in a Table View Iterator CLass?

    Hi All,
    I want to add a Drop Down List in the Table View Iterator Class. I am not able to do that.
    If any of you have done please reply, as it is very urgent.
    Please give the code extract possible (with data defination too)
    Regards,
    Dhaval
    Points will be given
    Mark this as Urgent

    Hi
    You need to modify RENDER_CELL_START method of your iterator class and you use the p_replacement_bee attribute to output the drop down
    The example below outputs the units of measure for a material
    data:
            col_dropdown   TYPE REF TO CL_HTMLB_DROPDOWNLISTBOX,
            col_listitem   TYPE REF TO CL_HTMLB_LISTBOXITEM,
            table_bee      TYPE REF TO cl_bsp_bee_table,
    CASE p_column_key.
        WHEN 'Column Name'.
    needs to change.  way too slow to select each time.
            prod_id = <current_line>-matnr.
            CALL FUNCTION 'Z_GET_UOM'
              EXPORTING
                PRODUCT_ID = prod_id
              IMPORTING
                UOMLIST    = uom_list.
            clear uom_line.   append uom_line to uom_list.
            CREATE OBJECT table_bee.
            CREATE OBJECT col_dropdown.
            rowidx = p_row_index.
            shift rowidx left deleting leading space.
            concatenate p_column_key rowidx into  col_dropdown->id.
            col_dropdown->width     = '100%'.
            col_dropdown->selection = <current_line>-zieme.
            table_bee->add( level = 1 element = col_dropdown    ).
            loop at uom_list into uom_line.
              CREATE OBJECT col_listitem.
              col_listitem->key    = uom_line-name.
              col_listitem->value  = uom_line-value.
              table_bee->add( level = 2 element = col_listitem    ).
            endloop.
            p_replacement_bee     = table_bee.

  • My implementation of an iterator class

    I implement my own iterator class, which provides a few methods for the user to get data, and once the end of the iterator is reached, I can release the memory. How does it look?
    import java.util.LinkedList;
    public class MyIterator {
        private Object[] list;
        private int size;
        private int cursor;
        public MyIterator(LinkedList inList) {
            size = inList.size();
            list = Object[size];
            for(int i=0;i<size;i++){
                list[i] = (Object) inList.removeFirst();
            cursor = 0;
    //check how many more items are available
        public int max_left() {
            return size - cursor;
    //get the next n
        public Object[] next_n(int how_many) {
            if( cursor == size ){
                return null;
            Object[] newList = Object[how_many];
            int temp = cursor;
            for(int i=0;i<how_many;i++){
                if( cursor < size ){
                    newList[i] = list[cursor++];
            checkCursor();
            return newList;
    //get the next one
        public boolean next_one() {
            if( cursor < size ){
                next.value = list[cursor++];
                checkCursor();
                return true;
            return false;
        //  if the cursor has already reached the end of the list, release the list memory
        public void checkCursor(){
            if( cursor == size ){
                list = null;
    }

    Hi,
    It looks very strange. I didn't look at the whole code, but why do you want an iterator that removes all elements from the original list when you create the iterator?
    list[i] = (Object) inList.removeFirst();/Kaj

  • Cannot Debug Iterator Class

    Hi,
    I am getting error "type of termination: RABAX_STATE " when running a BSP page with TableView Iterator
    I want to debug the iterator local class that I have created. However The control does not stop in the methods of this iterator class when I set a breakpint.
    Can't we debug the iterator class ? how ?
    Thanks
    Anand

    You must set an external/HTTP breakpoint in the class, and then the debugger should stop. Do not confuse it with internal breakpoints. Usually you should also activate system debugging. Check the documentation for details.

  • SLIN issues error for jvascript code in iterator class.

    Hi All,
    concatenate '<input o n Change=checkValidity(this.value,"' p_cell_id '");' into replace .
    If i check the iterator classes in SLIN Extended syntax check it throws error
       Program:  ZCL_SRM_OCI_ITERATOR==========CP  Include:  ZCL_SRM_OCI_ITERATOR==========CM002  Row:     99  [Prio 3]
    Char. strings w/o text elements will not be translated:
    '<center>End Date</center>'
    The message can be hidden with "#EC NOTEXT)
    But even after giving "#EC NOTEXT after the specified line in iterator class code I get the same error in SLIN.
    Kindly suggest how to hide this error.
    Regards,
    Anubhav

    This frankly is terrible, terrrible, terrible advice.If it wasn't obvious, and probably it wasn't obvious to the adviser: granting all permissions grants all permissions to all applets. So once you do that, any applet you download from any site has permission to do anything it likes on your system.
    It might be worthwhile for some spammer or malware writer to write an applet that looks for stupid people who have done this to their systems.
    And here's another reason why it's terrible advice: it only solves the problem for one computer. If somebody else wants to run your applet off your website then you have to give them the same advice, and now you move from stupidity to criminal negligence.
    And if you only ever plan to run it on your own computer, there was no point in writing an applet in the first place. Java applications don't have to deal with the security issues.

  • No-arg constructor for SQJL iterator class

    I'm to use SQLJ with EJB:
    I used SQLJ to define a public DeptRecs:
    #sql public iterator DeptRecs implements java.io.Serializable
    ( int deptNo, String dName, String loc );
    I wish to pass the iterator out of EJB:
    DeptRecs departments = deptEJB.getDepartments();
    As EJB communication is based on object serialization /
    deserialization, it is critical to provide a no-arg constructor
    for all the classes passed. But the SQLJ iterator has only one
    constructor:
    public DeptRecs(sqlj.runtime.profile.RTResultSet resultSet)
    How can I have a no-arg constructor for the iterator class?
    Or if this is a wrong way to have SQLJ work with EJB, could
    anybody tip me the correct structure?

    You may want to look at the following SQLJ demo file:
    sqlj/demo/SubclassIterDemo.sqlj
    This demonstrates the following:
    - a class Emp to hold the values of the rows
    - a subclass EmpColl of the iterator to read the rows into Emp
    objects.
    The EmpColl class has a getEmpVector() method that returns a Java
    vector with Emp objects as elements. Such a vector would be
    serializable and can be passed around. However, you are likely
    not able to pass the original iterator or its EmpColl subclass
    around.

  • Regarding instantiation of Iterator Class BSP MVC

    Hi Friends,
    I am trying out the MVC based BSP application using tableview iterator. I read the blog by Brain and went through the forums and tried to implement in MVC pattern.  wrt to Iterator part I did the following things...
    1. I created a ZClass and implemented IF_HTMLB_TABLEVIEW_ITERATOR Interface
    2. I created a variable in Controller Attributes TV_ITERATOR type ref to Zclass (Interface implemented)
    3. In the layout I have used the iterator attribute of Tableview assiging to TV_ITERATOR.
    4. I have defined the method Column_definitions....
    and in Do Handle Event I created a object for iterator "Create object tv_iterator".( i created a separate class for interface and thought would instantiate in Controller Class)
    I am not getting the desired output. Hope I am clear with this....
    I am just a beginer in BSP so sorry if its a silly question...
    Thanks

    Hi Mark,
    Thanks for your reply. I tried that in DO_INIT and in DO_REQUEST as well. I started of this application well with the values selecting from Dropdown and then rendering the table columns. But now I have commented everything and just trying to render one column of the table....
    I have one concern.
    I have declared like this
    tv_iterator type ref to ZITERATOR.
    and in DO_INIT I have instantiated. Create Object tv_iterator.
    If you have any suggestions please let me know....
    Thanks

  • Passing Parameters to tableview iterator class

    Hi all,
    I have a tableview with 2 fields say A and B.
    When i click any of the field(row) i want to open a new page with the parameters A and B.
    I have used iterator and able to get the value for either  field-A or field-B..How to get both field values in
    IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START
    This my code,
    *Oncreate*
    create object tv_iterator type ycl_salary_review.
    method if_htmlb_tableview_iterator~render_cell_start .
        data: wf_text type string,
            wf_url type string,
            test type char1.
      data: htmlstring type string ,
      rono type string .
      field-symbols: <fs> type any ,
                       <l_a> type any,
                     <l_b> type any.
      assign p_row_data_ref->* to <fs>.
      case p_column_key.
        when 'A'.
          assign component p_column_key of structure <fs> to <l_a>.
          wf_text = <l_a> .
        concatenate 'page2.htm?field_a=' wf_text into
          wf_url.
          call method cl_htmlb_link=>factory
            exporting
              id        = p_cell_id
              reference = wf_url
              target    = '_self'
              text      = wf_text
            receiving
              element   = p_replacement_bee.
      endcase.
    Rgds,
    Venkonk

    Hi Ven,
    pls Go thro this step-by-step creation of Tableview with iterator...
    /people/brian.mckellar/blog/2003/10/31/bsp-programming-htmlb-tableview-iterator
    Look at the Standard BSP Application BSP_MODEL --> Page Name:- table.htm
    *pls assign points,if link is useful*
    Regards
    CSM reddy

  • For loop vs Iterator

    I'm writing an application in which performance will be quite important and was looking into my collection classes. I recently saw the move towards using Iterator instead of for loops, while loops to retrieve objects from a List. I wanted to test to see which performed better and I saw that for about 1,000,000 Integer objects, an Iterator was 100ms slower in time in both Vector and ArrayList than a for loop using gets.
    1) Is the main cost the creation of the Iterator object?
    2) If I'm not worried about manipulation of my List while I'm retrieving objects and I will always be using a List in which I can always pull indexes (instead of say using HashSet)... is there any reason to use Iterator instead of a for loop?
    -- I read the recent tech tip on this and was just wondering if anyone had any other ideas of why to choose Iterator over for/while loops.
    Thanks.

    The purpose of Iterator
    The purpose of the Iterator pattern is to handle the traversal of a collection of objects.
    The advantages of Iterator has over other straightforward ways
    The direct access methods provided by some collection classes may not be as efficient or simple as using iterator pattern. And because the iterator keeps its own state, multiple traversals can be performed on a single collection simultaneously.
    An iterator hides the internal representation of the collection from the classes that need to access the contents of these collections.
    An Iterator pattern provides a consistent and sometimes efficient way to access the objects or values in some collections.
    What problems can arise if collection is changing?
    While using iterator, the changes of a collection such as that adding new elements or deleting old elements can result in inconsistency of the data, for example some objects may be missed or accessed more than once.
    How can they be avoided?
    A simple way is to make a copy of the collection and work on this copy but this can be very costly in terms of memory and time.
    Design a method that notifies the iterator whenever the collection is changed, and as soon as the change happens the iterator class throws an exception or restart whichever appropriate.
    A better way would be implements methods that monitor the changes and adjust the iterator and the results so they are consistent to the contents of the collection at any time.
    There are no general solutions to this problem and under different circumstance the proper solutions vary, however it is a good practice to taking possible changes of the source collections into account while designing the iterator, and it may be worth to let the user aware of the occurrence of any changes.

  • Generics and inner classes?

    How can I say my inner class uses the same type as it's genericised host class?
    Should I just not declare a "generic" type in the inner class?
    The code
    public class LinkedList<E> implements java.util.List<E>
      ... code omitted for brevity ...
       * An internal implementation of java.util.Iterator.
      private class Iterator<E> implements java.util.Iterator<E> {
        protected Node<E> current;
        public Iterator() {
          this.current = head; // error here
      ... code omitted for brevity ...
    produces the compiler error
    C:\Java\home\src\linkedlist\LinkedList.java:59: incompatible types
    found   : linkedlist.LinkedList.Node<E>
    required: linkedlist.LinkedList.Node<E>
          this.current = head;
                         ^I understand the meaning of the compiler error... it's effectively saying that "E" is not the same type within in the Iterator class as it is in the parent LinkedList class... What I don't understand is how to make E the same type within the Iterator... if I just leave the <E> off of Iterator<E> then it throws "unchecked operation" warnings... do I just have to put up with these warnings... but no that can't be right because java.util.LinkedList has an iterator and it's not throwing unchecked operation compiler warnings... so there has to be a way...
    Thanx all. Keith.

    One more dumbshit question...
    Is there a way to do this without the warnings OR the @SuppressWarnings({"unchecked"})
       * Returns the index of the last occurrence of the specified element in this
       * list, or -1 if this list does not contain the element.
      //@SuppressWarnings({"unchecked"})
      public int lastIndexOf(Object object) {
        int i = 0;
        int last = -1;
        for(Node<E> node=this.head.next; node!=null; node=node.next) {
          if (node.item.equals((E) object)) {
            last = i;
          i++;
        return(last);
    produces the warning
    C:\Java\home\src\linkedlist\LinkedList.java:313: warning: [unchecked] unchecked cast
    found   : java.lang.Object
    required: E
          if (node.item.equals((E) object)) {
                                   ^... remembering that List specifies +public int lastIndexOf(Object object);+ as taking a raw Object, not E element, as I would have expected.
    Thanx all. Keith.

  • Java 1.4.2: Iterator cannot be resolved...  Why??????

    Hello fellow java developers!
    I'm using java 1.4.2 - a requirement for this project.
    The issue that I'm running into is when I declare an Iterator for use in the program.
    The code is simple, but fails miserably.
    Iterator itRows = hsSheet.rowIterator(); // this is a function from apache POI that is supposed to return an iterator
    The issue is clear enough. "Iterator cannot be resolved to a type". But seems strange. If I try to declare the iterator type like this:
    Iterator<HSSFRow> itRows = hsSheet.rowIterator(); // this tells me that "paramaterized types are only available if the source is 5.0 or above - 1.4.2 is required.
    Any ideas???

    An SSCCE may be hard to produce if the problem is due to the Apache library or his use of the library. :(
    Is there some ambiguity as to what iterator you are using due to another library containing an Iterator class being added in your imports? Have you tried specifying the full class name?
    java.util.Iterator itRows = hsSheet.rowIterator();Also, when posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?
    To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.
    Another way to do this is to manually place the tags into your code by placing the tag [cod&#101;] above your pasted code and the tag [cod&#101;] below your pasted code like so:
    [cod&#101;]
      // your code goes here
      // notice how the top and bottom tags are different
    [/cod&#101;]Luck!

  • How to write remote iterator

    Hi,
    I am hoping there are some sample code that I can refer to for
    writing a remote iterator. What I am looking for is to return a list
    of Object. Since the list of object could be large, from what I
    understand is that we can limit to return 50 elements at a time and asks for the next 50 if any.
    Can someone provide some insights?
    Thanks,
    Pin

    You will have some interesting coding to do a remote iterator.
    It's easy enough to simply define an iterator class that uses RMI to access a remote server, getting back 50 Objects at a time. Just hide the fact that there is a remote call, and that it hands back 50 - or fewer - objects to the iterator. Return the individual objects one at a time as the user requests them from the iterator.
    The real challenge will be to figure out a way to answer the query hasNext();

  • Help! Inaccessible iterator when using dynamic query

    Hi!
    I have a problem retreiving results from a dynamic query into sqlj iterator.
    I consulted the Oracle App Dev Guide and Oracle SQLJ Dev Guide and wrote the following code:
    <PRE>
    package pmServer;
    #sql iterator LocIterator (int id, String name);
    public class pmRISDImpl
    public int GetLocations(...)
    LocIterator locIt;
    String q = "select ID, NAME from PMADM.LOCATIONS";
    #sql
    BEGIN
    open :OUT locIt for :q;
    END;
    </PRE>
    When I try to compile it using tools provided by JDeveloper ver 3.2.2.(Build 915) for JDK 1.2.2 I get error for #sql statement:
    Inaccessible Java type for host item locIt (at position #1): pmServer.LocIterator
    and warning:
    Type pmServer.LocIterator of host item locIt (at position #1) is not permitted in JDBC. This will not be portable.
    Althow the code is identcal to those demonstrated in Oracle document "Oracle8 i
    SQLJ Developers Guide and Reference
    Release 3 (8.1.7)
    July 2000
    Part No. A83723-01" pp 12-67 (PL/SQL in SQLJ for Dynamic SQLDynamicDemo.sqlj). There it looks like
    <PRE>
    private static void dynamicSelectMany(String what_cond)
    throws SQLException {
    System.out.println("dynamic multi-row query on table emp");
    Employees empIter;
    // table/column names cannot be bind args in dynamic PL/SQL, so
    // build up query as Java string
    String query = "select ename, sal from emp " +
    (((what_cond == null) &#0124; &#0124; (what_cond.equals(""))) ? "" :
    (" where " + what_cond)) +
    "order by ename";
    #sql {
    begin
    open :OUT empIter for -- opening ref cursor with dynamic query
    :query;
    -- can have USING clause here if needed
    end;
    while (empIter.next()) {
    System.out.println("Employee " + empIter.ename() +
    " has salary " + empIter.sal() );
    empIter.close();
    </PRE>
    Please guide me what should I do to get it working.
    null

    In the CAST statement the SQLJ runtime must be able to produce an instance of you SQLJ iterator using Java reflection.
    This necessitates that the iterator class must be accessible by public.
    You have two options:
    (1) Declare the iterator public. This requires that you put it in its own file LocIterator.sqlj:
    #sql public iterator LocIterator (int id, String name);
    (2) Declare the iterator as an inner class. In this case you want to make it public static (that is it does not require an instance of the outer class in scope). You might write the following.
    package pmServer;
    public class pmRISDImpl
    #sql public static iterator LocIterator (int id, String name);
    (3) If you are using Oracle 9i you have another option. You can embed dynamic SQL fragments directly in your SQLJ code and do not need to use the CAST:
    public int GetLocations(...)
    LocIterator locIt;
    String q = "PMADM.LOCATIONS";
    #sql locIt = { select ID, NAME from :{q} }; // Note new syntax :{q} for embedding SQL source code
    }

  • Issues in TableView Iterator

    Hi,
       We have two tableviews on a page and we created two different table view iterator classes for those two table views to make some columns of those table views editable. I am able to get the editable columns in the first table view and some how the second table view is not enabling the editable columns. Can anybody know why this problem is occuring? Is there any limitation on using multiple iterators in a single page. Thanks in advance.

    Hi,
         I created two Iterator classes with column definitions and other methods.
    In the page of BSP application, in onCreate event I am using the following code.
    <b>CREATE OBJECT lv_iterator TYPE Z_MM_ITERATOR1.
    CREATE OBJECT lv_iterator1 TYPE Z_MM_ITERATOR2.</b>
    In the Layout....
    <b>      <htmlb:tableView id              = "LVMVOL"
                           selectionMode   = "none"
                           filter          = "server"
                           iterator        = "<%=lv_iterator%>"
                           table           = "<%= IT_TABLE1 %>"
                           >
          </htmlb:tableView>
          <BR>
          <BR>
          <htmlb:tableView id              = "LVMVOL1"
                           selectionMode   = "none"
                           filter          = "server"
                           iterator        = "<%=LV_iterator1 %>"
                           table           = "<%= IT_TABLE2 %>"
                            >
          </htmlb:tableView></b>
    In the page attributes...
    <b>lv_iterator TYPE REF TO IF_HTMLB_TABLEVIEW_ITERATOR
    lv_iterator1  TYPE REF TO IF_HTMLB_TABLEVIEW_ITERATOR</b>

Maybe you are looking for