File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JSP tags parameters type Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "JSP tags parameters type" Watch "JSP tags parameters type" New topic
Author

JSP tags parameters type

Justin Chu
Ranch Hand

Joined: Apr 19, 2002
Posts: 209
// props is an array of my custom class.
<logic:iterate id="aAttr" collection="<%=props%>">
From the logic:iterate documentation

The collection to be iterated over MUST conform to one of the following requirements in order for iteration to be successful:
-An array of Java objects or primitives.
-An implementation of java.util.Collection, including ArrayList and Vector.
-An implementation of java.util.Enumeration.
-An implementation of java.util.Iterator.
-An implementation of java.util.Map, including HashMap, Hashtable, and TreeMap.

I am wondering how can a parameter accepts all those different type of Classes/Arrays at the same time?
Is it that in the source code, there are many overloaded functions?
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50691

Exactly. Why not just try it out for yourself?
bear
[ January 23, 2003: Message edited by: Bear Bibeault ]

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Marty Hall
Author
Ranch Hand

Joined: Jan 02, 2003
Posts: 111
I am wondering how can a parameter accepts all those different type of Classes/Arrays at the same time?
Is it that in the source code, there are many overloaded functions?

Well, if I were writing it, I probably would have a single method that takes an argument of type Object, then do reflection inside my method.
Cheers-
- Marty


Java training and consulting<br /><a href="http://www.coreservlets.com/" target="_blank" rel="nofollow">http://www.coreservlets.com/</a>
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
Originally posted by Chu Tan:
Is it that in the source code, there are many overloaded functions?

If you look at the code, the answer is 'no' -- it simply uses instanceof several times in order to create an iterator of the appropriate type. The beauty of open source is that the source is exactly that--open. Download it and look through it. You might learn something.


"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.
 
 
subject: JSP tags parameters type
 
Threads others viewed
Passing ArrayList to JSP custom Tag?
"javax.servlet.jsp.JspException: No collection found" using logic:iterate
Bad practise? JavaBean where setX() actually should be addX()?
Iterator and multibox
displaying data from arrays with html:text
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture