| Author |
dynamic list - javax.el.PropertyNotFoundException
|
Steve Henderson
Greenhorn
Joined: Feb 06, 2010
Posts: 3
|
|
I'm getting a javax.el.PropertyNotFoundException when running my code. I'm using Glassfish v2.1. I'm trying to implement a dynamic list using a custom tag. The custom tag is basically the <select> tag with a foreach to iterate through the elements and add them to the list. However, when I pass the Array to the tag via EL and try to retrieve attributes of the individual elements using the "var" attribute of the foreach tag, I get this exception. For some reason, the JVM is considering the "var" attribute to be a String and not an object of the type of the array. Hopefully, someone can explain this because it is making me want to
Here is the exception:
javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property 'text'.
Here is the custom tag code:
Here is the JSP code which uses this tag:
Now if I implement the same code used in the custom tag in the JSP and do not call the custom tag "dropDownList," I have no problems.
Here's an example of code that works without exception:
Thanks in advance for the help.
|
Steve
|
 |
Hany Shafik
Ranch Hand
Joined: Jun 21, 2008
Posts: 80
|
|
I think you will have to add rtexpvalue="true" for the attribute "options" as it is by default is false. Not sure but I guess what happened is that he converted the array to string by calling toString and then passed the result value to the custom tag.
|
 |
Steve Henderson
Greenhorn
Joined: Feb 06, 2010
Posts: 3
|
|
Thank you for the help. I have found that it works fine when I add a type attribute to the "options" attribute in the custom tag.
Here is the code:
It also works when i declare the type to be java.lang.Object[]. I did, however, add the "rtexprvalue" attribute to the "options" attribute declaration but I found that it worked without this.
Now my question is, why is the type attribute necessary in the custom tag code? There must be some basic principle of EL that I don't understand.
|
 |
Hany Shafik
Ranch Hand
Joined: Jun 21, 2008
Posts: 80
|
|
I am sorry for my earlier reply. I checked the JSP specs and I found that in case of tag files rtexprvalue defaults to true unlike the corresponding TLD element.
Also I have found that type defaults to java.lang.String if not specified which causes the above error.
|
 |
Steve Henderson
Greenhorn
Joined: Feb 06, 2010
Posts: 3
|
|
Okay. Thank you for your help. I no longer want to which is a very good thing!
|
 |
 |
|
|
subject: dynamic list - javax.el.PropertyNotFoundException
|
|
|