Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamic list - javax.el.PropertyNotFoundException

 
Steve Henderson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Hany Shafik
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. Thank you for your help. I no longer want to which is a very good thing!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic