This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
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.
Joined: Feb 06, 2010
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.
Joined: Jun 21, 2008
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.
Joined: Feb 06, 2010
Okay. Thank you for your help. I no longer want to which is a very good thing!