This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSP and the fly likes Is it possible to inline an array/list as a tag parameter? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Is it possible to inline an array/list as a tag parameter?" Watch "Is it possible to inline an array/list as a tag parameter?" New topic
Author

Is it possible to inline an array/list as a tag parameter?

Peter White
Greenhorn

Joined: Aug 25, 2004
Posts: 2
Hello,

I'm using code generation to generate JSP documents and would like to be able to pass selection values to my custom select field tag as follows as opposed to dynamically building a List via scriptlets and passing the list as my "items":

<ui:select name="locked" items='${{"","Please Select"},{"true","Yes"},{"false","No"}}'/>

When I try this, I get the following stack trace. I've tried several varations of this syntax with no luck and was wondering if this is even possible or if I just haven't nailed the correct syntax yet.

As a side note, I'm using JSP 2.0 tag files as opposed to coding my tag library in Java.

Thanks in advance!
Peter


org.apache.jasper.JasperException: /WEB-INF/forms/doctest_en-us.jspx(83,103) "${<<"","Please Select"},{"true","Yes"},{"false","No"}>>" contains invalid expression(s): javax.servlet.jsp.el.ELException: Encountered "{", expected one of [<INTEGER_LITERAL>, <FLOATING_POINT_LITERAL>, <STRING_LITERAL>, "true", "false", "null", "(", "-", "not", "!", "empty", <IDENTIFIER>]

at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:83)

at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:402)

at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:236)

at org.apache.jasper.compiler.JspUtil.validateExpressions(JspUtil.java:640)
.
.
.
Vijayendra V Rao
Ranch Hand

Joined: Jul 04, 2004
Posts: 195
I assume that the 'ui' tag has been defined in your tag lib file. By looking at the exception, I think that the class (probably you would have defined this class within some other custom tag such as <tagclass> does not recognize a few of the string literals that you have specified in your name attribute of the <ui/> tag.

I am not sure if this is actually the problem in your case, but I remember facing a problem on similar lines with the values that I had provided for the tag's attribute were not being recognized by the corresponding tag class. Just check if this is the case.


Vijayendra <br /> <br />"The harder you train in peace, the lesser you bleed in war"
Vijayendra V Rao
Ranch Hand

Joined: Jul 04, 2004
Posts: 195
Originally posted by Vijayendra V Rao:
I assume that the 'ui' tag has been defined in your tag lib file. By looking at the exception, I think that the class (probably you would have defined this class within some other custom tag such as tagclass, does not recognize a few of the string literals that you have specified in your name attribute of the <ui/> tag.


Sorry, the winking eye was a mistake
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61457
    
  67

No, you cannot automatically create lists using any type of EL notation.
[ November 08, 2004: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Peter White
Greenhorn

Joined: Aug 25, 2004
Posts: 2
Thanks for the replies. It looks like I can do what I want with OGNL so now I need to find a way to replace the default ExpressionEvaluator used in JSP 2.0 with my own that can use OGNL to evaluate the inlined lists.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Is it possible to inline an array/list as a tag parameter?