6
<s:select
  name="PenaltyPercentage"
  id="PenaltyPercentageId"
  list="#{'7.5%':'7.5%', '15.0%':'15.0%'}" <!-- shows error in this line -->
  headerKey=""
  headerValue="Please Select"
  emptyOption="false">
</s:select>

the error messages reads as below

Encountered ":" at line 1, column 9.
Was expecting one of:
"}" ...
"." ...
"]" ...
">" ...
"<" ...
seenimurugan
  • 464
  • 4
  • 19

1 Answers1

6

Netbeans 7 uses JSP EL 2.1 which uses the # character now.

For me (Netbeans IDE 7.0 RC1) it compiles fine and works although the line is flagged with an error. If glassfish will not execute the jsp then the following link shows how to disable JSP EL in a JSP 2.1 container (bottom of the following link).

http://struts.apache.org/2.0.14/docs/ognl.html

Probably the easiest solution at this time is to add the class of the map:

#@java.util.LinkedHashMap@{ "foo" : "foo value", "bar" : "bar value" } 

Found in this thread: http://struts.1045723.n5.nabble.com/s2-JSF-JSP-EL-vs-OGNL-EL-td3528303.html

For information on the JSP EL 2.1 See: http://jcp.org/aboutJava/communityprocess/final/jsr245/index.html


You are probably just showcasing the issue but just to be sure, if you supply a list rather than a map then the value returned to the server will be the same as the displayed value. So the following produces the same select box and does not produce an error:

<s:select
  list="{'7.5%','15.0%'}" <!-- does not show error -->
  headerValue="Please Select"
  emptyOption="false">
</s:select>

I spent a little time seeing if I could change the JSP EL version in Netbeans 7 without success, also tried to find a way to disable JSP EL error checking without success. So if you must use OGNL maps in your JSP either disable JSP EL (which isn't an attractive option for some) or explicitly declare the map as shown.

Quaternion
  • 10,380
  • 6
  • 51
  • 102
  • Since this answer has not been accepted, can you further clarify what it is you are looking for? – Quaternion May 15 '11 at 17:54
  • #@java.util.LinkedHashMap@{ "foo" : "foo value", "bar" : "bar value" } this solved the problem. Thanks a lot Quaternion. You are a star. – seenimurugan Jun 01 '11 at 11:14
  • I solved using the full-form but still at some places where I use s:property, s:iterator in javascript it's giving me error and the more strange thing is it's giving error on page, without pointing out the line number. I was able to trace the location and am 100% sure that, something normal even gives error when included in javascript. Any solution ? – coding_idiot Apr 13 '13 at 19:52