Possible to iterate through a java.util.Set using Struts 1?
Hi everyone! I've just started learning Struts (1) and this is my current problem: I have a java.util.Set which is saved in the current session and I'm trying to use Struts for checking if it's not empty and in that case iterating through it (from a JSP). This is the beginning of that code: When I try stepping through the code, the logic:notEmpty tag is handled just fine, but when I get to the logic:iterate tag I get this exception: javax.servlet.jsp.JspException: Cannot create iterator for this collection Does anyone know if it's possible to iterate through a Set using Struts (1 and not 2) in any way? I could always make it work by writing a scriptlet and iterate through it the regular Java way, but I'm trying to use as much Struts as possible since I'm doing a thesis where one of the issues is what the benefits of Struts are. (And besides, I've read that using scriptlets is "bad style" nowadays.) So if anybody knows a Struts solution to this, I'd be very grateful! Thanks in advance! /Ylva -- View this message in context: http://www.nabble.com/Possible-to-iterate-through-a-java.util.Set-using-Struts-1--tp18718294p18718294.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Possible to iterate through a java.util.Set using Struts 1?
Any reason you can't transform the Set into a List at the back end, and then iterate over the List? jk On Tue, Jul 29, 2008 at 2:16 PM, Ylva D <[EMAIL PROTECTED]> wrote: > > Hi everyone! > > I've just started learning Struts (1) and this is my current problem: > I have a java.util.Set which is saved in the current session and I'm trying > to use Struts for checking if it's not empty and in that case iterating > through it (from a JSP). This is the beginning of that code: > > > = "session"> > > When I try stepping through the code, the logic:notEmpty tag is handled > just > fine, but when I get to the logic:iterate tag I get this exception: > > javax.servlet.jsp.JspException: Cannot create iterator for this collection > > Does anyone know if it's possible to iterate through a Set using Struts (1 > and not 2) in any way? > > I could always make it work by writing a scriptlet and iterate through it > the regular Java way, but I'm trying to use as much Struts as possible > since > I'm doing a thesis where one of the issues is what the benefits of Struts > are. (And besides, I've read that using scriptlets is "bad style" > nowadays.) > > So if anybody knows a Struts solution to this, I'd be very grateful! > > Thanks in advance! > > /Ylva > -- > View this message in context: > http://www.nabble.com/Possible-to-iterate-through-a-java.util.Set-using-Struts-1--tp18718294p18718294.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Jim Kiley Technical Consultant | Summa [p] 412.258.3346 [m] 412.445.1729 http://www.summa-tech.com
Re: Possible to iterate through a java.util.Set using Struts 1?
Yes, I suppose I could do that but then I consider that a drawback of Struts. Is there no other way? If there isn't, I think I'd rather use a scriptlet no matter how bad it looks.. (It's also because I'm doing this "Struts project" like a new version of a project where I didn't use Struts and in that project I didn't have to transform my Sets.) /Ylva Jim Kiley wrote: > > Any reason you can't transform the Set into a List at the back end, and > then > iterate over the List? > > jk > > On Tue, Jul 29, 2008 at 2:16 PM, Ylva D <[EMAIL PROTECTED]> wrote: > >> >> Hi everyone! >> >> I've just started learning Struts (1) and this is my current problem: >> I have a java.util.Set which is saved in the current session and I'm >> trying >> to use Struts for checking if it's not empty and in that case iterating >> through it (from a JSP). This is the beginning of that code: >> >> >>> scope >> = "session"> >> >> When I try stepping through the code, the logic:notEmpty tag is handled >> just >> fine, but when I get to the logic:iterate tag I get this exception: >> >> javax.servlet.jsp.JspException: Cannot create iterator for this >> collection >> >> Does anyone know if it's possible to iterate through a Set using Struts >> (1 >> and not 2) in any way? >> >> I could always make it work by writing a scriptlet and iterate through it >> the regular Java way, but I'm trying to use as much Struts as possible >> since >> I'm doing a thesis where one of the issues is what the benefits of Struts >> are. (And besides, I've read that using scriptlets is "bad style" >> nowadays.) >> >> So if anybody knows a Struts solution to this, I'd be very grateful! >> >> Thanks in advance! >> >> /Ylva >> -- >> View this message in context: >> http://www.nabble.com/Possible-to-iterate-through-a-java.util.Set-using-Struts-1--tp18718294p18718294.html >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> --------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > -- > Jim Kiley > Technical Consultant | Summa > [p] 412.258.3346 [m] 412.445.1729 > http://www.summa-tech.com > > -- View this message in context: http://www.nabble.com/Possible-to-iterate-through-a-java.util.Set-using-Struts-1--tp18718294p18718883.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Possible to iterate through a java.util.Set using Struts 1?
If this is new development, I don't understand why you would deliberately choose Struts 1 over Struts 2. Unless your goal is to prove that Struts has too many drawbacks to use. jk On Tue, Jul 29, 2008 at 2:50 PM, Ylva D <[EMAIL PROTECTED]> wrote: > > Yes, I suppose I could do that but then I consider that a drawback of > Struts. > Is there no other way? > If there isn't, I think I'd rather use a scriptlet no matter how bad it > looks.. (It's also because I'm doing this "Struts project" like a new > version of a project where I didn't use Struts and in that project I didn't > have to transform my Sets.) > > /Ylva > > > Jim Kiley wrote: > > > > Any reason you can't transform the Set into a List at the back end, and > > then > > iterate over the List? > > > > jk > > > > On Tue, Jul 29, 2008 at 2:16 PM, Ylva D <[EMAIL PROTECTED]> > wrote: > > > >> > >> Hi everyone! > >> > >> I've just started learning Struts (1) and this is my current problem: > >> I have a java.util.Set which is saved in the current session and I'm > >> trying > >> to use Struts for checking if it's not empty and in that case iterating > >> through it (from a JSP). This is the beginning of that code: > >> > >> > >> >> scope > >> = "session"> > >> > >> When I try stepping through the code, the logic:notEmpty tag is handled > >> just > >> fine, but when I get to the logic:iterate tag I get this exception: > >> > >> javax.servlet.jsp.JspException: Cannot create iterator for this > >> collection > >> > >> Does anyone know if it's possible to iterate through a Set using Struts > >> (1 > >> and not 2) in any way? > >> > >> I could always make it work by writing a scriptlet and iterate through > it > >> the regular Java way, but I'm trying to use as much Struts as possible > >> since > >> I'm doing a thesis where one of the issues is what the benefits of > Struts > >> are. (And besides, I've read that using scriptlets is "bad style" > >> nowadays.) > >> > >> So if anybody knows a Struts solution to this, I'd be very grateful! > >> > >> Thanks in advance! > >> > >> /Ylva > >> -- > >> View this message in context: > >> > http://www.nabble.com/Possible-to-iterate-through-a-java.util.Set-using-Struts-1--tp18718294p18718294.html > >> Sent from the Struts - User mailing list archive at Nabble.com. > >> > >> > >> - > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > > -- > > Jim Kiley > > Technical Consultant | Summa > > [p] 412.258.3346 [m] 412.445.1729 > > http://www.summa-tech.com > > > > > > -- > View this message in context: > http://www.nabble.com/Possible-to-iterate-through-a-java.util.Set-using-Struts-1--tp18718294p18718883.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Jim Kiley Technical Consultant | Summa [p] 412.258.3346 [m] 412.445.1729 http://www.summa-tech.com
RE: Possible to iterate through a java.util.Set using Struts 1?
If you want to go that way but Set extends Collection http://publib.boulder.ibm.com/infocenter/wsadhelp/v5r1m2/index.jsp?topic=/com.sun.api.doc/java/util/Set.html Collection supports iterator() method which returns an iterator() Iterator iterator()which you can use to iterate thru the collection Iterator iterator = MySet.iterator() http://publib.boulder.ibm.com/infocenter/wsadhelp/v5r1m2/index.jsp?topic=/com.sun.api.doc/java/util/Set.html e.g. while (iterator.hasNext()) { Object obj = iterator.next(); } ? Martin __ Disclaimer and confidentiality note Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. > Date: Tue, 29 Jul 2008 11:50:53 -0700 > From: [EMAIL PROTECTED] > To: user@struts.apache.org > Subject: Re: Possible to iterate through a java.util.Set using Struts 1? > > > Yes, I suppose I could do that but then I consider that a drawback of Struts. > Is there no other way? > If there isn't, I think I'd rather use a scriptlet no matter how bad it > looks.. (It's also because I'm doing this "Struts project" like a new > version of a project where I didn't use Struts and in that project I didn't > have to transform my Sets.) > > /Ylva > > > Jim Kiley wrote: > > > > Any reason you can't transform the Set into a List at the back end, and > > then > > iterate over the List? > > > > jk > > > > On Tue, Jul 29, 2008 at 2:16 PM, Ylva D <[EMAIL PROTECTED]> wrote: > > > >> > >> Hi everyone! > >> > >> I've just started learning Struts (1) and this is my current problem: > >> I have a java.util.Set which is saved in the current session and I'm > >> trying > >> to use Struts for checking if it's not empty and in that case iterating > >> through it (from a JSP). This is the beginning of that code: > >> > >> > >> >> scope > >> = "session"> > >> > >> When I try stepping through the code, the logic:notEmpty tag is handled > >> just > >> fine, but when I get to the logic:iterate tag I get this exception: > >> > >> javax.servlet.jsp.JspException: Cannot create iterator for this > >> collection > >> > >> Does anyone know if it's possible to iterate through a Set using Struts > >> (1 > >> and not 2) in any way? > >> > >> I could always make it work by writing a scriptlet and iterate through it > >> the regular Java way, but I'm trying to use as much Struts as possible > >> since > >> I'm doing a thesis where one of the issues is what the benefits of Struts > >> are. (And besides, I've read that using scriptlets is "bad style" > >> nowadays.) > >> > >> So if anybody knows a Struts solution to this, I'd be very grateful! > >> > >> Thanks in advance! > >> > >> /Ylva > >> -- > >> View this message in context: > >> http://www.nabble.com/Possible-to-iterate-through-a-java.util.Set-using-Struts-1--tp18718294p18718294.html > >> Sent from the Struts - User mailing list archive at Nabble.com. > >> > >> > >> - > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > > -- > > Jim Kiley > > Technical Consultant | Summa > > [p] 412.258.3346 [m] 412.445.1729 > > http://www.summa-tech.com > > > > > > -- > View this message in context: > http://www.nabble.com/Possible-to-iterate-through-a-java.util.Set-using-Struts-1--tp18718294p18718883.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > _ Keep your kids safer online with Windows Live Family Safety. http://www.windowslive.com/family_safety/overview.html?ocid=TXT_TAGLM_WL_family_safety_072008
Re: Possible to iterate through a java.util.Set using Struts 1?
It's actually a thesis which I've been working on for more than 6 months (and I am trying to finish it now as soon as possible). When the specification for it was written Struts 1 was more accurate, I suppose, but that wasn't my decision. /Ylva Jim Kiley wrote: > > If this is new development, I don't understand why you would deliberately > choose Struts 1 over Struts 2. Unless your goal is to prove that Struts > has > too many drawbacks to use. > > jk > > On Tue, Jul 29, 2008 at 2:50 PM, Ylva D <[EMAIL PROTECTED]> wrote: > >> >> Yes, I suppose I could do that but then I consider that a drawback of >> Struts. >> Is there no other way? >> If there isn't, I think I'd rather use a scriptlet no matter how bad it >> looks.. (It's also because I'm doing this "Struts project" like a new >> version of a project where I didn't use Struts and in that project I >> didn't >> have to transform my Sets.) >> >> /Ylva >> >> >> Jim Kiley wrote: >> > >> > Any reason you can't transform the Set into a List at the back end, and >> > then >> > iterate over the List? >> > >> > jk >> > >> > On Tue, Jul 29, 2008 at 2:16 PM, Ylva D <[EMAIL PROTECTED]> >> wrote: >> > >> >> >> >> Hi everyone! >> >> >> >> I've just started learning Struts (1) and this is my current problem: >> >> I have a java.util.Set which is saved in the current session and I'm >> >> trying >> >> to use Struts for checking if it's not empty and in that case >> iterating >> >> through it (from a JSP). This is the beginning of that code: >> >> >> >> >> >>> >> scope >> >> = "session"> >> >> >> >> When I try stepping through the code, the logic:notEmpty tag is >> handled >> >> just >> >> fine, but when I get to the logic:iterate tag I get this exception: >> >> >> >> javax.servlet.jsp.JspException: Cannot create iterator for this >> >> collection >> >> >> >> Does anyone know if it's possible to iterate through a Set using >> Struts >> >> (1 >> >> and not 2) in any way? >> >> >> >> I could always make it work by writing a scriptlet and iterate through >> it >> >> the regular Java way, but I'm trying to use as much Struts as possible >> >> since >> >> I'm doing a thesis where one of the issues is what the benefits of >> Struts >> >> are. (And besides, I've read that using scriptlets is "bad style" >> >> nowadays.) >> >> >> >> So if anybody knows a Struts solution to this, I'd be very grateful! >> >> >> >> Thanks in advance! >> >> >> >> /Ylva >> >> -- >> >> View this message in context: >> >> >> http://www.nabble.com/Possible-to-iterate-through-a-java.util.Set-using-Struts-1--tp18718294p18718294.html >> >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> >> >> >> --------------------- >> >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> >> > >> > >> > -- >> > Jim Kiley >> > Technical Consultant | Summa >> > [p] 412.258.3346 [m] 412.445.1729 >> > http://www.summa-tech.com >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/Possible-to-iterate-through-a-java.util.Set-using-Struts-1--tp18718294p18718883.html >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > -- > Jim Kiley > Technical Consultant | Summa > [p] 412.258.3346 [m] 412.445.1729 > http://www.summa-tech.com > > -- View this message in context: http://www.nabble.com/Possible-to-iterate-through-a-java.util.Set-using-Struts-1--tp18718294p18719429.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Possible to iterate through a java.util.Set using Struts 1?
If you're using Struts 2 use the webwork Iteration tags Iterates over a collection. Generates iterators. Appends several iterators. Gets a subset of an iterator. Merges several iterators into one. Sorts an iterator http://cwiki.apache.org/WW/tutoriallesson04-01.html ? Martin - Original Message - From: "Ylva D" <[EMAIL PROTECTED]> To: Sent: Tuesday, July 29, 2008 2:16 PM Subject: Possible to iterate through a java.util.Set using Struts 1? > > Hi everyone! > > I've just started learning Struts (1) and this is my current problem: > I have a java.util.Set which is saved in the current session and I'm trying > to use Struts for checking if it's not empty and in that case iterating > through it (from a JSP). This is the beginning of that code: > > > = "session"> > > When I try stepping through the code, the logic:notEmpty tag is handled just > fine, but when I get to the logic:iterate tag I get this exception: > > javax.servlet.jsp.JspException: Cannot create iterator for this collection > > Does anyone know if it's possible to iterate through a Set using Struts (1 > and not 2) in any way? > > I could always make it work by writing a scriptlet and iterate through it > the regular Java way, but I'm trying to use as much Struts as possible since > I'm doing a thesis where one of the issues is what the benefits of Struts > are. (And besides, I've read that using scriptlets is "bad style" nowadays.) > > So if anybody knows a Struts solution to this, I'd be very grateful! > > Thanks in advance! > > /Ylva > -- > View this message in context: > http://www.nabble.com/Possible-to-iterate-through-a-java.util.Set-using-Struts-1--tp18718294p18718294.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: Possible to iterate through a java.util.Set using Struts 1?
--- On Tue, 7/29/08, Martin <[EMAIL PROTECTED]> wrote: > If you're using Struts 2 use the webwork Iteration tags > Iterates over a collection. > Generates iterators. > Appends several iterators. > Gets a subset of an iterator. > Merges several iterators into one. > Sorts an iterator Or use the S2 tags, which actually makes sense. They're the same names, but with a prefix used in essentially all S2 example code and documentation. Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]