Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

netbeans 7.0 shows error in Struts2 select tag .. netbeans version 6.9 does not show this error [duplicate]

<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:
"}" ...
"." ...
"]" ...
">" ...
"<" ...
like image 317
seenimurugan Avatar asked May 09 '11 15:05

seenimurugan


1 Answers

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.

like image 172
Quaternion Avatar answered Oct 14 '22 01:10

Quaternion