Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Peter White
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 V Rao
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you cannot automatically create lists using any type of EL notation.
[ November 08, 2004: Message edited by: Bear Bibeault ]
 
Peter White
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic