RE: Question about iterate tag
Craig, I did try this way but it still does not work. Since supplier.value is of type SupplierBean, do I have to specify that anywhere? -- jsp:useBean id="user" scope="session" type="com.motorola.mms.msqc.beans.UserBean"/ TABLE logic:iterate id="supplier" name="user" property="suppliers" TR TDbean:write name="supplier" property="value.seq_nbr" scope="page"//TD TDbean:write name="supplier" property="value.name" scope="page"//TD TDbean:write name="supplier" property="value.countryName" scope="page"//TD /TR /logic:iterate /TABLE - but this code which I am trying to replace with tags works: jsp:useBean id="user" scope="session" type="com.motorola.mms.msqc.beans.UserBean"/ TABLE % Hashtable hashTable = (Hashtable) user.getSuppliers(); for (Enumeration e = hashTable.elements(); e.hasMoreElements(); ) { SupplierBean supplier = (SupplierBean) e.nextElement(); % TR TDFONT face = "Arial"supplier.getCode() %/FONT/TD TDFONT face = "Arial"%= supplier.getName() %/FONT/TD/FONT/TD TDFONT face = "Arial"%= supplier.getCountryName() %/FONT/TD /TR % } % /TABLE -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 28, 2001 11:30 PM To: [EMAIL PROTECTED] Subject: Re: Question about iterate tag 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 When you iterate over a Hashtable (or any other implementation of the Map interface), the object get for the "id" variable is actually an implementation of the "Map.Entry" class, not the class of the value of the bean. From this "Map.Entry" instance, however, you can easily get to the real information: bean:write name="supplier" property="value.seq_nbr" scope="page"/ This works because a MapEntry has two properties -- key and value -- so we are using the nested property syntax to effectively call getValue().getSeq_nbr(). Thanks in advance. -Nimmi Craig
RE: Question about iterate tag
I did try this way but it still does not work. Since supplier.value is of type SupplierBean, do I have to specify that anywhere? I believe you want the bean to be SupplierBean rather than Supplier. Your request bean:write name="supplier" property="value.seq_nbr" scope="page"/ seems like it would get translated into out.print( String.valueOf(supplier.getValue().seq_nbr) ); or something akin to that which is Not At All what you're looking for. M -- jsp:useBean id="user" scope="session" type="com.motorola.mms.msqc.beans.UserBean"/ TABLE logic:iterate id="supplier" name="user" property="suppliers" TR TDbean:write name="supplier" property="value.seq_nbr" scope="page"//TD TDbean:write name="supplier" property="value.name" scope="page"//TD TDbean:write name="supplier" property="value.countryName" scope="page"//TD /TR /logic:iterate /TABLE - but this code which I am trying to replace with tags works: jsp:useBean id="user" scope="session" type="com.motorola.mms.msqc.beans.UserBean"/ TABLE % Hashtable hashTable = (Hashtable) user.getSuppliers(); for (Enumeration e = hashTable.elements(); e.hasMoreElements(); ) { SupplierBean supplier = (SupplierBean) e.nextElement(); % TR TDFONT face = "Arial"supplier.getCode() %/FONT/TD TDFONT face = "Arial"%= supplier.getName() %/FONT/TD/FONT/TD TDFONT face = "Arial"%= supplier.getCountryName() %/FONT/TD /TR % } % /TABLE -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 28, 2001 11:30 PM To: [EMAIL PROTECTED] Subject: Re: Question about iterate tag 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 When you iterate over a Hashtable (or any other implementation of the Map interface), the object get for the "id" variable is actually an implementation of the "Map.Entry" class, not the class of the value of the bean. From this "Map.Entry" instance, however, you can easily get to the real information: bean:write name="supplier" property="value.seq_nbr" scope="page"/ This works because a MapEntry has two properties -- key and value -- so we are using the nested property syntax to effectively call getValue().getSeq_nbr(). Thanks in advance. -Nimmi Craig
RE: Question about iterate tag
Craig had suggested that I use: bean:write name="supplier" property="value.seq_nbr" scope="page"/ but unfortunately it is not working. -Original Message- From: Matt Ho [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 01, 2001 12:27 PM To: [EMAIL PROTECTED] Subject: RE: Question about iterate tag I did try this way but it still does not work. Since supplier.value is of type SupplierBean, do I have to specify that anywhere? I believe you want the bean to be SupplierBean rather than Supplier. Your request bean:write name="supplier" property="value.seq_nbr" scope="page"/ seems like it would get translated into out.print( String.valueOf(supplier.getValue().seq_nbr) ); or something akin to that which is Not At All what you're looking for. M -- jsp:useBean id="user" scope="session" type="com.motorola.mms.msqc.beans.UserBean"/ TABLE logic:iterate id="supplier" name="user" property="suppliers" TR TDbean:write name="supplier" property="value.seq_nbr" scope="page"//TD TDbean:write name="supplier" property="value.name" scope="page"//TD TDbean:write name="supplier" property="value.countryName" scope="page"//TD /TR /logic:iterate /TABLE - but this code which I am trying to replace with tags works: jsp:useBean id="user" scope="session" type="com.motorola.mms.msqc.beans.UserBean"/ TABLE % Hashtable hashTable = (Hashtable) user.getSuppliers(); for (Enumeration e = hashTable.elements(); e.hasMoreElements(); ) { SupplierBean supplier = (SupplierBean) e.nextElement(); % TR TDFONT face = "Arial"supplier.getCode() %/FONT/TD TDFONT face = "Arial"%= supplier.getName() %/FONT/TD/FONT/TD TDFONT face = "Arial"%= supplier.getCountryName() %/FONT/TD /TR % } % /TABLE -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 28, 2001 11:30 PM To: [EMAIL PROTECTED] Subject: Re: Question about iterate tag 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 When you iterate over a Hashtable (or any other implementation of the Map interface), the object get for the "id" variable is actually an implementation of the "Map.Entry" class, not the class of the value of the bean. From this "Map.Entry" instance, however, you can easily get to the real information: bean:write name="supplier" property="value.seq_nbr" scope="page"/ This works because a MapEntry has two properties -- key and value -- so we are using the nested property syntax to effectively call getValue().getSeq_nbr(). Thanks in advance. -Nimmi Craig
Re: Question about iterate tag
Shamdasani Nimmi-ANS004 wrote: Craig, I did try this way but it still does not work. What does "does not work" mean? What error messages or stack traces are you getting? Since supplier.value is of type SupplierBean, do I have to specify that anywhere? No ... bean introspection does not care what the class is ... only whether there is a property of the matching name. Craig
RE: Question about iterate tag
IT IS UNBELIEVABLE! I have wasted so much time trying to get this to work and all that was missing in my JSP was this line: %@ taglib uri="/Web-inf/struts-logic.tld" prefix="logic" % The strange part is that I was not getting any error in the log files saying undefined tag or anything. I appreciate all the help I received :) -Nimmi -Original Message- From: Shamdasani Nimmi-ANS004 [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 01, 2001 11:04 AM To: '[EMAIL PROTECTED]' Subject: RE: Question about iterate tag Craig, I did try this way but it still does not work. Since supplier.value is of type SupplierBean, do I have to specify that anywhere? -- jsp:useBean id="user" scope="session" type="com.motorola.mms.msqc.beans.UserBean"/ TABLE logic:iterate id="supplier" name="user" property="suppliers" TR TDbean:write name="supplier" property="value.seq_nbr" scope="page"//TD TDbean:write name="supplier" property="value.name" scope="page"//TD TDbean:write name="supplier" property="value.countryName" scope="page"//TD /TR /logic:iterate /TABLE - but this code which I am trying to replace with tags works: jsp:useBean id="user" scope="session" type="com.motorola.mms.msqc.beans.UserBean"/ TABLE % Hashtable hashTable = (Hashtable) user.getSuppliers(); for (Enumeration e = hashTable.elements(); e.hasMoreElements(); ) { SupplierBean supplier = (SupplierBean) e.nextElement(); % TR TDFONT face = "Arial"supplier.getCode() %/FONT/TD TDFONT face = "Arial"%= supplier.getName() %/FONT/TD/FONT/TD TDFONT face = "Arial"%= supplier.getCountryName() %/FONT/TD /TR % } % /TABLE -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 28, 2001 11:30 PM To: [EMAIL PROTECTED] Subject: Re: Question about iterate tag 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 When you iterate over a Hashtable (or any other implementation of the Map interface), the object get for the "id" variable is actually an implementation of the "Map.Entry" class, not the class of the value of the bean. From this "Map.Entry" instance, however, you can easily get to the real information: bean:write name="supplier" property="value.seq_nbr" scope="page"/ This works because a MapEntry has two properties -- key and value -- so we are using the nested property syntax to effectively call getValue().getSeq_nbr(). Thanks in advance. -Nimmi Craig
Re: Question about iterate tag
Shamdasani Nimmi-ANS004 wrote: IT IS UNBELIEVABLE! I have wasted so much time trying to get this to work and all that was missing in my JSP was this line: %@ taglib uri="/Web-inf/struts-logic.tld" prefix="logic" % The strange part is that I was not getting any error in the log files saying undefined tag or anything. nope, not that strange. if you viewed the source of your page, you should be able to see your logic tags, still sitting there, unprocessed as text. The container will only complain about undefined tags if there is a .tld defined with a prefix at the top of the page (ie the struts-logic tags). Otherwise it treats everything else as plain text. Cheers, Nick I appreciate all the help I received :) -Nimmi -Original Message- From: Shamdasani Nimmi-ANS004 [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 01, 2001 11:04 AM To: '[EMAIL PROTECTED]' Subject: RE: Question about iterate tag Craig, I did try this way but it still does not work. Since supplier.value is of type SupplierBean, do I have to specify that anywhere? -- jsp:useBean id="user" scope="session" type="com.motorola.mms.msqc.beans.UserBean"/ TABLE logic:iterate id="supplier" name="user" property="suppliers" TR TDbean:write name="supplier" property="value.seq_nbr" scope="page"//TD TDbean:write name="supplier" property="value.name" scope="page"//TD TDbean:write name="supplier" property="value.countryName" scope="page"//TD /TR /logic:iterate /TABLE - but this code which I am trying to replace with tags works: jsp:useBean id="user" scope="session" type="com.motorola.mms.msqc.beans.UserBean"/ TABLE % Hashtable hashTable = (Hashtable) user.getSuppliers(); for (Enumeration e = hashTable.elements(); e.hasMoreElements(); ) { SupplierBean supplier = (SupplierBean) e.nextElement(); % TR TDFONT face = "Arial"supplier.getCode() %/FONT/TD TDFONT face = "Arial"%= supplier.getName() %/FONT/TD/FONT/TD TDFONT face = "Arial"%= supplier.getCountryName() %/FONT/TD /TR % } % /TABLE -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 28, 2001 11:30 PM To: [EMAIL PROTECTED] Subject: Re: Question about iterate tag 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 When you iterate over a Hashtable (or any other implementation of the Map interface), the object get for the "id" variable is actually an implementation of the "Map.Entry" class, not the class of the value of the bean. From this "Map.Entry" instance, however, you can easily get to the real information: bean:write name="supplier" property="value.seq_nbr" scope="page"/ This works because a MapEntry has two properties -- key and value -- so we are using the nested property syntax to effectively call getValue().getSeq_nbr(). Thanks in advance. -Nimmi Craig
Re: Question about iterate tag
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 When you iterate over a Hashtable (or any other implementation of the Map interface), the object get for the "id" variable is actually an implementation of the "Map.Entry" class, not the class of the value of the bean. From this "Map.Entry" instance, however, you can easily get to the real information: bean:write name="supplier" property="value.seq_nbr" scope="page"/ This works because a MapEntry has two properties -- key and value -- so we are using the nested property syntax to effectively call getValue().getSeq_nbr(). Thanks in advance. -Nimmi Craig