Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP tags parameters type  RSS feed

 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
// 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 ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly. Why not just try it out for yourself?
bear
[ January 23, 2003: Message edited by: Bear Bibeault ]
 
Marty Hall
Author
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
David Hibbs
Ranch Hand
Posts: 374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!