RE: logic:iterate question
hi otto, that solution didnt work - it wouldn't recognise bar as a variable in the %= %. this solution does work for me: bean:size id=size name=articles scope=session / ... logic:iterate id=article name=articles scope=session indexId=index ... logic:equal value=%= String.valueOf(size.intValue()-1) % name=index ... /logic:equal ... /logic:iterate the value parameter must be a string, so i used the String.valueOf method. however this isnt very clean - are there better solutions? Ben -Original Message- From: Otto, Frank [mailto:[EMAIL PROTECTED] Sent: vrijdag, februari 06, 2004 10:46 To: 'Struts Users Mailing List' Subject: AW: logic:iterate question Sorry, I mean: foo.length-1 instead bar.length-1 -Ursprüngliche Nachricht- Von: Otto, Frank [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 6. Februar 2004 10:41 An: 'Struts Users Mailing List' Betreff: AW: logic:iterate question Hello Ben, you can do this in this way: logic:iterate id=foo name=bar scope=session indexId=index ... logic:equal value=%=bar.length-1% name=index ... /logic:equal /logic:iterate Regards, Frank -Ursprüngliche Nachricht- Von: Turner Benjamin [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 6. Februar 2004 09:08 An: [EMAIL PROTECTED] Betreff: logic:iterate question hello, i have a question about the logic:iterate tag. My tag iterates over an ArrayList which contains an amount of beans. However, in the last iteration i want to perform some special action. My current code looks something like this: logic:iterate id=foo name=bar scope=session indexId=index ... logic:equal value=... name=index ... /logic:equal /logic:iterate However, i have no idea what to fill in in the dots (should be something like bar.length-1), or whether this kind of construction is even supposed to work. As far as i can make up out of the docs, logic:equal is only for constant comparison. any hints on how to do this? ty, Ben - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: logic:iterate question
i have a question about the logic:iterate tag. My tag iterates over an ArrayList which contains an amount of beans. However, in the last iteration i want to perform some special action. My current code looks something like this: logic:iterate id=foo name=bar scope=session indexId=index ... logic:equal value=... name=index ... /logic:equal /logic:iterate This is something that JSTL does *extremely* well: c:forEach items=foo.bar var=bar varStat=stat c:if test=stat.last do what needs to be done /c:if /c:forEach -- Tim Slattery [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: logic:iterate question
Oops, did you mean to do this? c:forEach items=foo.bar var=bar varStat=stat c:if test=stat.last ^^^ do what needs to be done /c:if /c:forEach shouldn't that be? c:if test=${stat.last} ^^ ^ -- James Mitchell Software Engineer / Struts Evangelist http://www.struts-atlanta.org 678.910.8017 (cell) AIM: jmitchtx MSN: [EMAIL PROTECTED] - Original Message - From: Slattery, Tim - BLS [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Friday, February 06, 2004 9:29 AM Subject: RE: logic:iterate question i have a question about the logic:iterate tag. My tag iterates over an ArrayList which contains an amount of beans. However, in the last iteration i want to perform some special action. My current code looks something like this: logic:iterate id=foo name=bar scope=session indexId=index ... logic:equal value=... name=index ... /logic:equal /logic:iterate This is something that JSTL does *extremely* well: c:forEach items=foo.bar var=bar varStat=stat c:if test=stat.last do what needs to be done /c:if /c:forEach -- Tim Slattery [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: logic:iterate question
shouldn't that be? c:if test=${stat.last} Yes, it sure should. And the first line should be: c:forEach items=${foo.bar} var=bar varStat=stat So the whole thing should look like this: c:forEach items=${foo.bar} var=bar varStat=stat c:if test=${stat.last} do what needs to be done /c:if /c:forEach -- Tim Slattery [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: logic:iterate question
From: Dragos Madalin Popa [mailto:[EMAIL PROTECTED] How can I iterate over a collection which depends of a request parameter? JSTL and/or Struts-EL can probably help, but I'm not quite sure what your question is. Can you give an example? -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: logic:iterate question
Hi, Thank you for your answer.I would like to change the code shown below, to pass a request parameter to the modelList function;something like this: public Collection getModelList(String requestString){}, where requestString is a parameter of the http request.. Warmest Regards, Dragos logic:iterate id=model name=models property=modelList tr tdbean:write name=model property=name //td tdbean:write name=model property=description //td /tr /logic:iterate From: Dragos Madalin Popa [mailto:[EMAIL PROTECTED] How can I iterate over a collection which depends of a request parameter? JSTL and/or Struts-EL can probably help, but I'm not quite sure what your question is. Can you give an example? -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: logic:iterate question
From: Dragos Madalin Popa [mailto:[EMAIL PROTECTED] Thank you for your answer.I would like to change the code shown below, to pass a request parameter to the modelList function;something like this: public Collection getModelList(String requestString){}, where requestString is a parameter of the http request.. logic:iterate id=model name=models property=modelList tr tdbean:write name=model property=name //td tdbean:write name=model property=description //td /tr /logic:iterate I don't think you can pass parameters in JSTL, at least not yet. But you could, in your action, call getModelList passing the String you got from the request, and then when you forward to the JSP, iterate over that Collection. If getModelList returned a Map, or you made a getAllModelLists method that returns a Map, you might have this: c:forEach items=${myBean.allModelLists[theRequestParam]} item=${model} c:out value=${model.name}/ /c:forEach That depends on how big they are, and whether they change for each user. If you models are fixed and change infrequently, you might be able to put a big Map in Application scope and use it across the entire webapp. Out of curiosity, what class is getModelList from? -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: logic:iterate question
You should be able to use BeanUtils' mapped property access for this, right? c:set var=modelListProp value=modelList(${param.paramName})/ jsp:useBean id=modelListProp type=java.lang.String/ bean:define id=modelList name=bean property=%= modelListProp %/ Which should give you a bean called modelList that holds your collection. This assumes there's a bean called bean whose class implements the getModelList method. Quoting Wendy Smoak [EMAIL PROTECTED]: From: Dragos Madalin Popa [mailto:[EMAIL PROTECTED] Thank you for your answer.I would like to change the code shown below, to pass a request parameter to the modelList function;something like this: public Collection getModelList(String requestString){}, where requestString is a parameter of the http request.. logic:iterate id=model name=models property=modelList tr tdbean:write name=model property=name //td tdbean:write name=model property=description //td /tr /logic:iterate I don't think you can pass parameters in JSTL, at least not yet. But you could, in your action, call getModelList passing the String you got from the request, and then when you forward to the JSP, iterate over that Collection. If getModelList returned a Map, or you made a getAllModelLists method that returns a Map, you might have this: c:forEach items=${myBean.allModelLists[theRequestParam]} item=${model} c:out value=${model.name}/ /c:forEach That depends on how big they are, and whether they change for each user. If you models are fixed and change infrequently, you might be able to put a big Map in Application scope and use it across the entire webapp. Out of curiosity, what class is getModelList from? -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: logic:iterate question
Forgot the obligatory, but you should really do this in an action. There's no reason to clog your JSP with this kind of stuff. Grab the collection in an action, set it as a request attribute, forward to the JSP, and... Quoting Kris Schneider [EMAIL PROTECTED]: You should be able to use BeanUtils' mapped property access for this, right? c:set var=modelListProp value=modelList(${param.paramName})/ jsp:useBean id=modelListProp type=java.lang.String/ bean:define id=modelList name=bean property=%= modelListProp %/ Which should give you a bean called modelList that holds your collection. This assumes there's a bean called bean whose class implements the getModelList method. Quoting Wendy Smoak [EMAIL PROTECTED]: From: Dragos Madalin Popa [mailto:[EMAIL PROTECTED] Thank you for your answer.I would like to change the code shown below, to pass a request parameter to the modelList function;something like this: public Collection getModelList(String requestString){}, where requestString is a parameter of the http request.. logic:iterate id=model name=models property=modelList tr tdbean:write name=model property=name //td tdbean:write name=model property=description //td /tr /logic:iterate I don't think you can pass parameters in JSTL, at least not yet. But you could, in your action, call getModelList passing the String you got from the request, and then when you forward to the JSP, iterate over that Collection. If getModelList returned a Map, or you made a getAllModelLists method that returns a Map, you might have this: c:forEach items=${myBean.allModelLists[theRequestParam]} item=${model} c:out value=${model.name}/ /c:forEach That depends on how big they are, and whether they change for each user. If you models are fixed and change infrequently, you might be able to put a big Map in Application scope and use it across the entire webapp. Out of curiosity, what class is getModelList from? -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.com/ -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: logic:iterate question
I don't think you can pass parameters in JSTL, at least not yet. But you could, in your action, call getModelList passing the String you got from the request, and then when you forward to the JSP, iterate over that Collection. I am not sure what you meant, Wendy, but, in case you meant that you cannot use parameters, then check out: http://jakarta.apache.org/struts/faqs/indexedpropers.html . If this is helpful, I use this with a BeanMap I whipped up: public final class BeanMap implements Map { private Map map; private BeanMap() { } public static Map getInstance(Map map) { BeanMap bean = new BeanMap(); bean.setMap(map); return bean; } public void setMap(Map map) { this.map = map; log.info(this.map); } public void setValue(Object key, Object value) { map.put(key,value); } public Object getValue(Object key) { return map.get(key); } // Forwarding, composition, methods public void clear() { map.clear(); } public booleancontainsKey(Object key) { return map.containsKey(key);} public booleancontainsValue(Object value) { return map.containsValue(value); } public SetentrySet(){ return map.entrySet(); } public booleanequals(Object object) { return map.equals(object); } public Object get(Object key) { return map.get(key); } public inthashCode(){ return map.hashCode(); } public booleanisEmpty() { return map.isEmpty(); } public SetkeySet() { return map.keySet(); } public Object put(Object key, Object value) { return map.put(key,value); } public void putAll(Map map) { map.putAll(map); } public Object remove(Object key){ return map.remove(key); } public intsize(){ return map.size(); } public Collection values() { return map.values(); } public String toString(){ return map.toString(); } }///;-) Bye 'd bye, Michael
Re: logic:iterate question
if you know its only one item, why don't change the action... insteat of: request.setAttribute(testers,testerInfo); try request.setAttribute(testers,testerInfo[0]); hernux - Original Message - From: struts [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Friday, December 19, 2003 6:51 AM Subject: logic:iterate question I have logic:iterate id=testers name=testerInfo . /logic:iterate I only have one item in the testerInfo collection. Why can't i do bean:define id=testers name=testerInfo/ Or how can i put it to the first item? Thanks ! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: logic:iterate question
The following link should help: http://www.mail-archive.com/[EMAIL PROTECTED]/msg71256.html however it talks about using el, but this is not necessary. I have got the nested tags to work properly. The logic tag should work, but I think I was doing something slightly wrong when I tried. Remember to have getMap(String key) and setMap(String key, Object value) in your form. The online help has more on this. sandeep --- [EMAIL PROTECTED] wrote: hi all, i have a Map-backed action Form which contains an HashMap the ActionForm is as follows public MapActionForm extends ActionForm { HashMap table = new HashMap(); public void setValue(String key, String value) { ... } public Object getValue(String key) { .. } public HashMap getTable() { return table; } } in one of jsp i have to display a textfield for each key contained in the HashMap. i have written following code (name of the bean is DisplayKeys) logic:iterate id=params collection=%= displayKeys.getTable() % tr tdbean:write name=params//td tdhtml:text property=value(bean:write name=params/)//td /tr /logic:iterate but when i get into the page (after populating the bean) i got following exception: org.apache.jasper.JasperException: /callservice.jsp(53,79) equal symbol expected the hashmap contains parameter names. in the jps i want to display the name of the parameter (done with bean:write name=params) and i want to display close to teh name an input text with the name of the parameter.. Example: in the map i have following values param1, param2, and in the jsp i want to display param1 : input type=text name=param1/ anyone can give me some help? regards marco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: logic:iterate question
my previous question regarding use of logic:iterate with a HashMap can be cleared up by using the 'name' attribute rather than the 'collection' attribute in the tag. now that i figured that out, i'm having some trouble nesting an iterate. now that i have the example below actually able to render, the nested logic:iterate only generates one result (although there are many in the Collection) before moving on to the next result in the outer iterator. any ideas how to fix this? thanks /gp logic:iterate id=list name=events bean:define id=event name=list property=key type=com.foo.bar.EventDisplay/ bean:define id=tickets name=list property=value type=java.util.Collection/ bean:write name=event property=title/ logic:iterate id=ticket name=tickets bean:write name=ticket property=location/ /logic:iterate /logic:iterate From: Garth Patil [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: logic:iterate question Date: Sat, 25 Jan 2003 05:59:56 + i have a HashMap stored in the session (as 'events') i'm trying to use the logic:iterate tag to iterate through it in my jsp in a nested fashion. the HashMap has a bean as the key and a collection of beans as its value. when i try to run the page, i get an error: Cannot create iterator for this collection. any ideas? my jsp looks like this. logic:iterate id=list collection=events bean:define id=event name=list property=key type=com.foo.bar.EventDisplay/ bean:define id=tickets name=list property=value type=java.util.Collection/ bean:write name=event property=title/ logic:iterate id=ticket name=tickets bean:write name=ticket property=location/ /logic:iterate /logic:iterate _ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] _ Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: logic:iterate question
Dumb question: Is the object reference 'myObj' pointing at anything before set it to the name 'myObj'? That sounds confusing -- too many myObjs floating around. Suppose you had pageContext.setAttribute(myObj, foo, PageContext.PAGE_SCOPE); My question is whether 'foo' is set before this call. Sri -Original Message- From: Andy Kriger [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 03, 2002 3:24 PM To: Struts Users Mailing List Subject: logic:iterate question I have a JSP. I have some scriplet code that defines an object and then I want to iterate over that object, but I keep getting an error that the object is not defined in the page scope. Looking at the docs I don't understand what I'm doing wrong. --- % pageContext.setAttribute(myObj, myObj, PageContext.PAGE_SCOPE); % logic:iterate id=ele name=myObj property=records scope=page !-- do stuff -- /logic:iterate --- myObj has a getRecords() method that returns the array i want to iterate over When i load the page i get 'Cannot find bean myObj in scope page' Any ideas? thx andy -- To unsubscribe, e-mail: mailto:struts-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: logic:iterate question
Yes - I store some data in it and then want to use that data later in the page. -Original Message- From: Sri Sankaran [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 03, 2002 15:32 To: Struts Users Mailing List Subject: RE: logic:iterate question Dumb question: Is the object reference 'myObj' pointing at anything before set it to the name 'myObj'? That sounds confusing -- too many myObjs floating around. Suppose you had pageContext.setAttribute(myObj, foo, PageContext.PAGE_SCOPE); My question is whether 'foo' is set before this call. Sri -Original Message- From: Andy Kriger [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 03, 2002 3:24 PM To: Struts Users Mailing List Subject: logic:iterate question I have a JSP. I have some scriplet code that defines an object and then I want to iterate over that object, but I keep getting an error that the object is not defined in the page scope. Looking at the docs I don't understand what I'm doing wrong. --- % pageContext.setAttribute(myObj, myObj, PageContext.PAGE_SCOPE); % logic:iterate id=ele name=myObj property=records scope=page !-- do stuff -- /logic:iterate --- myObj has a getRecords() method that returns the array i want to iterate over When i load the page i get 'Cannot find bean myObj in scope page' Any ideas? thx andy -- To unsubscribe, e-mail: mailto:struts-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: logic:iterate question
Just a guess, but perhaps try using the type attribute? Like ... logic:iterate id=ele name=myObj property=records scope=page type=your.java.class.for.myObj Susan Bradeen On 12/03/2002 03:40:04 PM Andy Kriger wrote: Yes - I store some data in it and then want to use that data later in the page. -Original Message- From: Sri Sankaran [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 03, 2002 15:32 To: Struts Users Mailing List Subject: RE: logic:iterate question Dumb question: Is the object reference 'myObj' pointing at anything before set it to the name 'myObj'? That sounds confusing -- too many myObjs floating around. Suppose you had pageContext.setAttribute(myObj, foo, PageContext.PAGE_SCOPE); My question is whether 'foo' is set before this call. Sri -Original Message- From: Andy Kriger [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 03, 2002 3:24 PM To: Struts Users Mailing List Subject: logic:iterate question I have a JSP. I have some scriplet code that defines an object and then I want to iterate over that object, but I keep getting an error that the object is not defined in the page scope. Looking at the docs I don't understand what I'm doing wrong. --- % pageContext.setAttribute(myObj, myObj, PageContext.PAGE_SCOPE); % logic:iterate id=ele name=myObj property=records scope=page !-- do stuff -- /logic:iterate --- myObj has a getRecords() method that returns the array i want to iterate over When i load the page i get 'Cannot find bean myObj in scope page' Any ideas? thx andy -- To unsubscribe, e-mail: mailto:struts-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: logic:iterate question
You'll have to use indexed property getters. I believe you'll also have to put vTwo into your form bean so you can take advantage of the indexed property getter. Like so: logic:iterate id='item' name='vOne' indexId='idx' logic:notEqual name=%=idx.intValue()% value=0 , /logic:notEqual bean:write name='item'/:bean:write name='myForm' property='%=vTwo[ + idx.intValue() + ] %' / /logic:iterate I used single quotes around the attributes here because of the double quotes within the JSP expression, b.t.w. Note that this would be a lot cleaner if you used a Tuple object (named whatever you like) that contained (number,letter) fields and use a single Vector of these objects: logic:iterate id='tuple' name='tupleVector' indexId='idx' logic:notEqual name=%=idx.intValue()% value=0 , /logic:notEqual bean:write name=tuple property=number/:bean:write name=tuple property=letter / /logic:iterate bean:write name='responseProcessForm' property='%= msgCode[ + index.intValue() + ] %' -Original Message- From: Andy Kriger [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 02, 2002 11:52 AM To: Struts Users Mailing List Subject: logic:iterate question I have two vectors of the same length. I can iterate over one and retrieve values. How can I use the index of that iteration to reference the other vector? For example vOne = { 1,2,3,4 } vTwo = { a,b,c,d } I iterate over vOne producing 1,2,3,4, logic:iterate id='item' name='vOne' indexId='idx' bean:write name='item'/, /logic:iterate How can I get the output to produce 1:a,2:b,3:c,4:d,? (note the formatting is not important, just interested in how to reference vTwo using vOne's idx) thx -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: logic:iterate question
Since you can access specific item in a list through something like this: bean:write property=vTwo[0]/ You should be able to do what you want through a scriptlet: ie bean:write property='%=vTwo[+idx+]%'/ We use this trick all the time ( and I gleaned it from this fabulous list in the first place.) -Peter On Wed, 2002-10-02 at 14:51, Andy Kriger wrote: I have two vectors of the same length. I can iterate over one and retrieve values. How can I use the index of that iteration to reference the other vector? For example vOne = { 1,2,3,4 } vTwo = { a,b,c,d } I iterate over vOne producing 1,2,3,4, logic:iterate id='item' name='vOne' indexId='idx' bean:write name='item'/, /logic:iterate How can I get the output to produce 1:a,2:b,3:c,4:d,? (note the formatting is not important, just interested in how to reference vTwo using vOne's idx) thx -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: logic:iterate question (index available?)
-Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 29, 2002 2:46 PM To: [EMAIL PROTECTED] Subject: logic:iterate question (index available?) hello all, is there any way to get the current loop number (or index) of a an iterate tag? i have the following code: Just read the API description for logic:iterate. Your answer is one of the attributes of logic:iterate. I'm leaving out the actual attribute name to make sure you read it, because it is very useful to go through it. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: logic:iterate question
Hey, It's not a problem to pull a list out of an object. My code is: logic:iterate id=hw name=currentData property=hwList type=com.moog.us.rur.data.Hardware This means that my app locates the object called currentData, and iterates through an ArrayList within it (which is the hwList). The element of the iteration is stored in a page scope variable (the hw). The type attribute specifies the type of objects that are in the ArrayList. I hope this helps ya out. ~ Keith http://www.buffalo.edu/~kkamholz -Original Message- From: Aiken, Weston - Raleigh, NC [mailto:[EMAIL PROTECTED]] Sent: Friday, August 09, 2002 11:40 AM To: [EMAIL PROTECTED] Subject: logic:iterate question Consider the following scenario: My Action class adds a Facility object to the request and forwards to a JSP for presentation. The Facility object contains an array of PhoneNumber objects. My question is: Using struts tags, is it possible to pull the PhoneNumber[] array out of the Facility object and then iterate through them? If the PhoneNumber array were in the request by itself, then the iterate tag would work fine, but the array needs to pulled out of the Facility first. Thanks for any help -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: logic:iterate question
The nested framework from Arron Bates is the ticket (see www.keyboardmonkey.com). With it you could %-- Form using a Facility bean --% nested:iterate property=phoneNumbers nested:write property=areaCode/ /nested:iterate Of course, the property attributes assume the corresponding getter methods. The beauty of this is that you can go any number of levels deep. Sri -Original Message- From: Aiken, Weston - Raleigh, NC [mailto:[EMAIL PROTECTED]] Sent: Friday, August 09, 2002 11:40 AM To: [EMAIL PROTECTED] Subject: logic:iterate question Consider the following scenario: My Action class adds a Facility object to the request and forwards to a JSP for presentation. The Facility object contains an array of PhoneNumber objects. My question is: Using struts tags, is it possible to pull the PhoneNumber[] array out of the Facility object and then iterate through them? If the PhoneNumber array were in the request by itself, then the iterate tag would work fine, but the array needs to pulled out of the Facility first. Thanks for any help -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: logic:iterate question
Keith Perfect, thanks a bunch. Weston -Original Message- From: [EMAIL PROTECTED] at INTERNET Sent: Friday, August 09, 2002 12:08 PM To: Aiken, Weston - Raleigh, NC; [EMAIL PROTECTED] at INTERNET Subject: RE: logic:iterate question Hey, It's not a problem to pull a list out of an object. My code is: logic:iterate id=hw name=currentData property=hwList type=com.moog.us.rur.data.Hardware This means that my app locates the object called currentData, and iterates through an ArrayList within it (which is the hwList). The element of the iteration is stored in a page scope variable (the hw). The type attribute specifies the type of objects that are in the ArrayList. I hope this helps ya out. ~ Keith http://www.buffalo.edu/~kkamholz -Original Message- From: Aiken, Weston - Raleigh, NC [mailto:[EMAIL PROTECTED]] Sent: Friday, August 09, 2002 11:40 AM To: [EMAIL PROTECTED] Subject: logic:iterate question Consider the following scenario: My Action class adds a Facility object to the request and forwards to a JSP for presentation. The Facility object contains an array of PhoneNumber objects. My question is: Using struts tags, is it possible to pull the PhoneNumber[] array out of the Facility object and then iterate through them? If the PhoneNumber array were in the request by itself, then the iterate tag would work fine, but the array needs to pulled out of the Facility first. Thanks for any help -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: logic:iterate question
logic:iterate id='element' name='attribute' scope='page' type='java.lang.String' indexId='index' bean:write name='MAP_STATE_KEY' property='mapController.dataConnection.attributeNames[%= index %]' scope='session'/ Correct your bean:write tag so attribute property becomes full scriplet syntax coded : property='%= \mapController.dataConnection.attributeNames[\+ index + \]\%' Nico -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: logic:iterate question
I have not used the indexId property before myself, but I have experienced with other properties/tags that names you define in the tag itself is not available from scriptlets. So the snippet %= index% will return an empty string or fail. ida -Original Message- From: Graham Lounder [mailto:[EMAIL PROTECTED]] Sent: 25. april 2002 14:36 To: [EMAIL PROTECTED] Subject: logic:iterate question Hello all, I've got a question about the logic:iterate tag. I'm trying to reference a bean which returns a String[] but I only want one of the values in the array. The indexID is working but it isn't getting passed to the bean:write tag corretly. It throws a java.lang.IllegalArgumentException: Invalid indexed property 'attributeNames[]' If I passed the bean a hardcoded index value, it works. I can also print out the value of the index. I think it may be some kind of timing issue in struts and maybe it can't be done. Any Ideas? logic:iterate id='element' name='attribute' scope='page' type='java.lang.String' indexId='index' bean:write name='MAP_STATE_KEY' property='mapController.dataConnection.attributeNames[%= index %]' scope='session'/ /logic:iterate Thanks, Graham -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: logic:iterate question
Hi , From what I understand you want to create links for each headline and pass the head line as a parameter. So inside the logic:iterate tag U should put : logic:iterate. jsp:useBean id=info class=java.util.HashMap/ %info.put(HeadLineID, X); % html:link page=/details.do name=info Headline /html:link /logic:iterate U can replace the one line of code with jsp:setProperty of the bean info It worked for me. Konstantina ---Original Message - From: Oliver Kiessler [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Thursday, February 14, 2002 12:58 PM Subject: logic:iterate question hello, i have a problem on one of my views with a logic:iterate tag. i have an action that fetches news headlines from a database (headline,headlineID) and stores them in a bean (headlines-Arraylist,headlinedID-Vector) which is appended to request/session. On the view i want to iterate through the Arraylist with the headlines which basically works fine. but i need to create links like this: a href=ViewHeadlineAction.do?headlineID=XXYZ/a how would i use the iterate tag? do i have to use the nested tag? (i am currently using struts 1.0.2) i dont want to use any java code in my view, only tags... thanks, oli -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: logic:iterate question
links like this: a href=ViewHeadlineAction.do?headlineID=XXYZ/a supposing the logic:iterate id paramenter is set to element It should be something like this html:link page=ViewHeadlineAction.do paramName=element paramId=headlineID paramPropery=getterMethodWhoReturnsX instead of the static a/a checks this document http://jakarta.apache.org/struts/struts-html.html for html:link reference doc. Hope this helps. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: logic:iterate question
This should work ... ( use bean:write to set the value of the parameter ... ) logic:iterate id=headline name=headlines scope=session a href=ViewHeadLineAction.do?headLineId=bean:write name=headline property=headlineID/ View Headline /a /logic:iterate On 14 Feb 2002 11:58:39 +0100 Oliver Kiessler [EMAIL PROTECTED] wrote: hello, i have a problem on one of my views with a logic:iterate tag. i have an action that fetches news headlines from a database (headline,headlineID) and stores them in a bean (headlines-Arraylist,headlinedID-Vector) which is appended to request/session. On the view i want to iterate through the Arraylist with the headlines which basically works fine. but i need to create links like this: a href=ViewHeadlineAction.do?headlineID=XXYZ/a how would i use the iterate tag? do i have to use the nested tag? (i am currently using struts 1.0.2) i dont want to use any java code in my view, only tags... thanks, oli -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- Get your firstname@lastname email at http://Nameplanet.com/?su -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: logic:iterate question
thanks! thats it. now it works... ;) oli Am Don, 2002-02-14 um 12.13 schrieb Ivan Siviero: links like this: a href=ViewHeadlineAction.do?headlineID=XXYZ/a supposing the logic:iterate id paramenter is set to element It should be something like this html:link page=ViewHeadlineAction.do paramName=element paramId=headlineID paramPropery=getterMethodWhoReturnsX instead of the static a/a checks this document http://jakarta.apache.org/struts/struts-html.html for html:link reference doc. Hope this helps. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- mailto: [EMAIL PROTECTED] web: http://www.linustar.de gnupg key: http://www.linustar.de/pgp/kiessler.gpg icq: 136832122 --- The more I question the origin and meaning of our existence, the less I care. And the less I care, the more I question myself. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: logic:iterate question
I have a similiar question, but this time with a button Every row will have a show action. With a link there is no problem (using the method described) but with a button I have a problem since I cant replace the onclick event with a parameter. html:button onclick=go('show',bean:write name=loop value=id/)/ this should become input type=button onclick=go(show,1) Gr Ronald -Original Message- From: Oliver Kiessler [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 12:21 PM To: Struts Users Mailing List Subject: Re: logic:iterate question thanks! thats it. now it works... ;) oli Am Don, 2002-02-14 um 12.13 schrieb Ivan Siviero: links like this: a href=ViewHeadlineAction.do?headlineID=XXYZ/a supposing the logic:iterate id paramenter is set to element It should be something like this html:link page=ViewHeadlineAction.do paramName=element paramId=headlineID paramPropery=getterMethodWhoReturnsX instead of the static a/a checks this document http://jakarta.apache.org/struts/struts-html.html for html:link reference doc. Hope this helps. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- mailto: [EMAIL PROTECTED] web: http://www.linustar.de gnupg key: http://www.linustar.de/pgp/kiessler.gpg icq: 136832122 --- The more I question the origin and meaning of our existence, the less I care. And the less I care, the more I question myself. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer ---
RE: logic:iterate question
can't you create a form around each button ?? On Thu, 14 Feb 2002 12:29:34 +0100 Ronald Haring [EMAIL PROTECTED] wrote: I have a similiar question, but this time with a button Every row will have a show action. With a link there is no problem (using the method described) but with a button I have a problem since I cant replace the onclick event with a parameter. html:button onclick=go('show',bean:write name=loop value=id/)/ this should become input type=button onclick=go(show,1) Gr Ronald -Original Message- From: Oliver Kiessler [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 14, 2002 12:21 PM To: Struts Users Mailing List Subject: Re: logic:iterate question thanks! thats it. now it works... ;) oli Am Don, 2002-02-14 um 12.13 schrieb Ivan Siviero: links like this: a href=ViewHeadlineAction.do?headlineID=XXYZ/a supposing the logic:iterate id paramenter is set to element It should be something like this html:link page=ViewHeadlineAction.do paramName=element paramId=headlineID paramPropery=getterMethodWhoReturnsX instead of the static a/a checks this document http://jakarta.apache.org/struts/struts-html.html for html:link reference doc. Hope this helps. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- mailto: [EMAIL PROTECTED] web: http://www.linustar.de gnupg key: http://www.linustar.de/pgp/kiessler.gpg icq: 136832122 --- The more I question the origin and meaning of our existence, the less I care. And the less I care, the more I question myself. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer --- -- Get your firstname@lastname email at http://Nameplanet.com/?su -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: logic:iterate question
can't you create a form around each button ?? I can do that I suppose, but not sure whether old netscape users like multiple forms. Other problem is that if you define forms within a table the table row will become larger, but thx for that solution Gr Ronald Furore B.V. Rijswijkstraat 175-8 Postbus 9204 1006 AE Amsterdam tel. (020) 346 71 71 fax. (020) 346 71 77 --- The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer ---
RE: logic:Iterate question
Hi, try: logic:iterate id=facility scope=session name=surveyForm property=generalFacilityList table tr td bean:write name=facility property=code/ /td td bean:write name=facility property=description/ /td td html:checkbox name=facility property=state/ /td td bean:write name=facility property=state/ /td /tr /table /logic:iterate that is pure html... hope this helps Alexander Jesse -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, September 24, 2001 1:02 AM To: [EMAIL PROTECTED] Subject: logic:Iterate question Hi all, I am using the iterate tag to iterate over a collection of items stored in the FormBean. And all work fine (so far :) ). My question is: A I have a large number of items in the collection is it possible arrange them in columns?? Here is a code snippet: logic:iterate id=facility scope=session name=surveyForm property=generalFacilityList table tr bean:write name=facility property=code/ bean:write name=facility property=description/ html:checkbox name=facility property=state/ bean:write name=facility property=state/ /tr /table /logic:iterate This prints everything in one long column. Is there a html thing I can use?? regards Shea Kelly Consultant Software Engineer Object Oriented Pty Ltd PO Box 528, North Sydney NSW 2059 Phone: +61 2 9957-1092 Direct: +61 2 9459-3335 Fax: +61 2 9956-5089 Mobile: 0416 110 499 Email: [EMAIL PROTECTED] Web: http://www.oopl.com.au http://www.oopl.com.au/
Re: logic:Iterate question
If you mean, can you wrap a long column into two or more columns, like a newspaper article, then there is no html way to do this. You would need to do in manually somehow. Will - Original Message - From: Shea Kelly [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, September 23, 2001 7:01 PM Subject: logic:Iterate question Hi all, I am using the iterate tag to iterate over a collection of items stored in the FormBean. And all work fine (so far :) ). My question is: A I have a large number of items in the collection is it possible arrange them in columns?? Here is a code snippet: logic:iterate id=facility scope=session name=surveyForm property=generalFacilityList table tr bean:write name=facility property=code/ bean:write name=facility property=description/ html:checkbox name=facility property=state/ bean:write name=facility property=state/ /tr /table /logic:iterate This prints everything in one long column. Is there a html thing I can use?? regards Shea Kelly Consultant Software Engineer Object Oriented Pty Ltd PO Box 528, North Sydney NSW 2059 Phone: +61 2 9957-1092 Direct: +61 2 9459-3335 Fax: +61 2 9956-5089 Mobile: 0416 110 499 Email: [EMAIL PROTECTED] Web: http://www.oopl.com.au http://www.oopl.com.au/