Hi,
    You can try this approach.
                 In the place of string array, you can use a Vector, to
which you can add the required elements and pass it to the tag library
definition. Ofcourse, you need to change the code a little to use a Vector
in place of a string. Anyway you have to do some code change, even if you
use the String tokenizer approach.

regards,
balaji.



----- Original Message -----
From: "cbarnes" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 21, 2002 5:43 PM
Subject: attributes for custom tags


> I am writing a custom tag where one of the attributes required is a String
> array. I know I'm being awkward but I want to be able to create this
string
> array within the custom tag line. I imagined that I would be able to do
> something like the following
>
> <prefix:mytag myattribute="<%= new String[] {item1, item2, item3} %>" />
>
> However, tomcat wants to translate the type into something.class, but gets
> muddled up because of the [].
>
> I then thought I could change the String array into a String of comma
> separated items, and allow the custom tag to convert this into a string
> array using a StringTokenizer. However, the problem here is that each of
the
> items in the list is an expression. I had imagined that if I did something
> like the following
>
> <prefix:mytag myattribute="<%= item1 %>, <%= item2 %>, <%= item3 %>" />
>
> that each expression would be evaluated. But it doesn't. It recognises the
> first <%= and the last %> and tries to evaluate everything in between as
one
> expression.
>
> If I change it to
>
> <prefix:mytag myattribute="<%= item1, item2, item3 %>" />
>
> the expressions don't get evaluated and it doesn't consider it as one
quoted
> string anyway.
>
> Can anyone suggest how to get either of these 2 approaches to work, or
> suggest a different approach to set a custom tag attribute that is a list
of
> expressions?
>
> Thanks,
> Catharine
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to