revision to the html:link tag

2001-04-23 Thread Andre_Beskrowni



currently there are two ways to add parameters when using the link tag.  you can
either:
(1) specify 1 parameter using the paramId/paramName/paramProperty/paramScope
attributes of the tag, or
(2) specify a Map of name/value pairs that the name and property attributes

method 1 is obviously limiting.

method 2 is kind of a pain in the butt if you want to include parameters with
values from multiple bean, etc.  i get really annoyed at the idea of having to
created an extra Map just to store some values to be used in a URL.

here's my proposal.  you can keep the previously mentioned methods of adding
parameters and add another that looks like the following example:


  
  
  
  click here


this would result in a link that look like this:


click here


i have written this tag combination for my use, and would be happy to pass it
along if you think it would useful in the struts taglib.  basically i used the
same link tag with 2 changes:
1) set the  in the tld to be "JSP"
2) moved construction of the url to the doEndTag method

the urlParam tag just sets creates a Map to store its name-value pairs, stores
it in the PageContext, and sets the parent link tag's name attribute to the new
Map.  (as a result, you need to remove this value from the PageContext in the
link tag's release method.)

this tag combination adds some handy new functionality, and is
backwards-compatible as well.

ab





RE: Iterate -- Logic Tag

2001-03-16 Thread Andre_Beskrowni



while it's true that java iterators and enumerators don't provide an index when
you loop through them, how many times have you found yourself using a local
count variable that you increment inside the loop?  i've encountered it plenty.
i don't think it's an uncommon scenario.

recently, i've ended up using a solution similar to Michael's to keep a counter,
but this doesn't seem ideal to me.  if people are really adamant about keeping
the iterate tag as it is, maybe the alternative would to construct an
indexedIterate tag or something like that.  on the other hand, from looking at
the source code for the iterate tag, there's already a lengthCount attribute
that stores the number of iterations.  why not just expose that?

ab

>  From:  [EMAIL PROTECTED]
> Date:   03/16/2001 10:55 AM
>
>raghu tadi <[EMAIL PROTECTED]> wrote:
>> How do i get the Position value of a particular element in say a
>> Vector when i use the iterate tag.Sample snippet would be like,
>> 
>> Vector v has some String elements..
>> for(int i =0 ; i < v.size(); i++)
>> {
>>out.println(v.elementAt(i));
>> }
>> 
>> Question is: How do i get the i-th element from Vector V when i use
>> the Iterate Tag..
>
>As Jean-Noel said, if you really want to get a particular element, you
>don't want to use iterate. But if what you are actually looking for is
>how to get the index of the current element inside an iterate block, I
>think you need to manage that separately. It's not ideal, but here's
>what I do to produce a table with alternately shaded rows:
>
>   <% int rowNumber = 0; %>
>   
> <% if( ( ++rowNumber % 2 ) == 1 ) { %>
> 
> <% } else { %>
> 
> <% } %>
>   ...
>   ...
>   ...
> 
>   
>
>It would be nice if interate also made an index available, but you can
>do something like that as a work-around for now (unless someone has a
>better suggestion).
>
>--
>Michael Hackett
>Developer, Pictorius Inc.
>
>
>