RE: How do I iterate thru a hashtable using iterate tag?
If the objects I am storing in my hashtable are of a bean type how would I access the properties of the bean in iterate? e.g., if the bean has get methods for properties Code, name, countryName, etc. I want to display these thru iterate tag on my JSP. -Nimmi -Original Message- From: Pope, Tracy [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 28, 2001 8:41 AM To: '[EMAIL PROTECTED]' Subject: RE: How do I iterate thru a hashtable using iterate tag? Craig answered a similar question on Sunday. I think it might help you, there he stated: When you iterate over a Hashtable (or any other Map), the elements of the iteration are of class "Map.Entry", which has two properties -- "key" and "value". The other posting did not appear to need a Hashtable and he further suggested the possible use of an ArrayList, etc. If that would work in your situation it might simplify your problem. Tracy -Original Message- From: Shamdasani Nimmi-ANS004 [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 27, 2001 2:34 PM To: '[EMAIL PROTECTED]' Subject: How do I iterate thru a hashtable using iterate tag? Hi, Could someone please tell me what I am doing wrong below: user is a bean in session scope in my JSP and its getSuppliers() method returns a hashtable where keys are Suppliers Ids and elements are Supplier beans. logic:iterate collection="%= user.getSuppliers() %" id="supplier" type="com.motorola.mms.msqc.beans.SupplierBean" TR TDbean:write name="supplier" property="seq_nbr" scope="page" //TD TDbean:write name="supplier" property="name" scope="page" //TD TDbean:write name="supplier" property="country_name" scope="page" //TD /TR /logic:iterate -- I had the following code earlier and that was working. % Hashtable hashTable = (Hashtable) user.getSuppliers(); for (Enumeration e = hashTable.elements(); e.hasMoreElements(); ) { SupplierBean supplier = (SupplierBean) e.nextElement(); % TR TD%= supplier.getCode() %/FONT/TD TD%= supplier.getName() %/TD TD%= supplier.getCountryName() %/FONT/TD /TR % } % Thanks in advance. -Nimmi
Re: How do I iterate thru a hashtable using iterate tag?
Nimmi, Check the properties names. In the working variant they are: code, name, countryName. In the 2nd (not working variant) they are: seq_nbr, name, country_name. The second, maybe underscore sign is not allowed. Maya Shamdasani Nimmi-ANS004 wrote: Hi, Could someone please tell me what I am doing wrong below: user is a bean in session scope in my JSP and its getSuppliers() method returns a hashtable where keys are Suppliers Ids and elements are Supplier beans. logic:iterate collection="%= user.getSuppliers() %" id="supplier" type="com.motorola.mms.msqc.beans.SupplierBean" TR TDbean:write name="supplier" property="seq_nbr" scope="page" //TD TDbean:write name="supplier" property="name" scope="page" //TD TDbean:write name="supplier" property="country_name" scope="page" //TD /TR /logic:iterate -- I had the following code earlier and that was working. % Hashtable hashTable = (Hashtable) user.getSuppliers(); for (Enumeration e = hashTable.elements(); e.hasMoreElements(); ) { SupplierBean supplier = (SupplierBean) e.nextElement(); % TR TD%= supplier.getCode() %/FONT/TD TD%= supplier.getName() %/TD TD%= supplier.getCountryName() %/FONT/TD /TR % } % Thanks in advance. -Nimmi
RE: How do I iterate thru a hashtable using iterate tag?
No, the typo was on my email not in the code. -Nimmi -Original Message- From: Maya Muchnik [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 27, 2001 2:51 PM To: [EMAIL PROTECTED] Subject: Re: How do I iterate thru a hashtable using iterate tag? Nimmi, Check the properties names. In the working variant they are: code, name, countryName. In the 2nd (not working variant) they are: seq_nbr, name, country_name. The second, maybe underscore sign is not allowed. Maya Shamdasani Nimmi-ANS004 wrote: Hi, Could someone please tell me what I am doing wrong below: user is a bean in session scope in my JSP and its getSuppliers() method returns a hashtable where keys are Suppliers Ids and elements are Supplier beans. logic:iterate collection="%= user.getSuppliers() %" id="supplier" type="com.motorola.mms.msqc.beans.SupplierBean" TR TDbean:write name="supplier" property="seq_nbr" scope="page" //TD TDbean:write name="supplier" property="name" scope="page" //TD TDbean:write name="supplier" property="country_name" scope="page" //TD /TR /logic:iterate -- I had the following code earlier and that was working. % Hashtable hashTable = (Hashtable) user.getSuppliers(); for (Enumeration e = hashTable.elements(); e.hasMoreElements(); ) { SupplierBean supplier = (SupplierBean) e.nextElement(); % TR TD%= supplier.getCode() %/FONT/TD TD%= supplier.getName() %/TD TD%= supplier.getCountryName() %/FONT/TD /TR % } % Thanks in advance. -Nimmi