You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by vn...@ca.ibm.com on 2002/06/07 23:46:56 UTC
array as a parameter
Hi,
I'm trying to develop a tag that accepts an array as parameter. Does
anyone know what I need to do to have this work properly and use the
contents of this
array.
For example I would like to create a tag such as the one below. And then
the tag will function by doing something such as matching 'home' to '86400'
and 'away' to '604800':
<mytaglib:list name="myname" valueProperty="{86400,604800}"
displayProperty="{'home', 'away' }"/>
Common sense says that I just treat the parameter like any other array
(ie:see the set method below) but for some reason I get an error when using
the tag.
public void setValueProperty(String [] value){
valueProperty=value;
}
(where valueProperty is defined as a String array)
If anyone could help me with this, it would be greatly appreciated.
Thanks,
Vipan Nikore
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: array as a parameter
Posted by Shawn Bayern <ba...@essentially.net>.
On Fri, 7 Jun 2002 vnikore@ca.ibm.com wrote:
> Hi,
> I'm trying to develop a tag that accepts an array as parameter. Does
> anyone know what I need to do to have this work properly and use the
> contents of this
> array.
>
> For example I would like to create a tag such as the one below. And then
> the tag will function by doing something such as matching 'home' to '86400'
> and 'away' to '604800':
>
> <mytaglib:list name="myname" valueProperty="{86400,604800}"
> displayProperty="{'home', 'away' }"/>
You cannot pass a Java array literal to a JSP tag. You can either use an
rtexprvalue to pass the information to the tag for a pre-defined array, or
use JSTL's expression language (with a JSTL tag) to do the same
thing. That is, either
<% Object[] a = { ... } %>
<mytaglib:list valueProperty="<%= a %>" />
or
<c:forEach items="${myArrayFromAScopedVariable}"/>
--
Shawn Bayern
"JSTL in Action" http://www.jstlbook.com
(coming in July 2002 from Manning Publications)
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>