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

Cannot find a setter

 
Charessa Reilly
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's time for another round of "Charessa has no idea what she's doing!"

Ok, so I'm calling this custom tag:



With this code in the .jsp file:


and Tomcat is telling me:
/detailview.jsp(32,4) Unable to find setter method for attribute: aUser


(line 32 of detailview.jsp corresponds with ]<inq:singleRec>)

soooo.. what did I miss this time?

edit: fixed the line the error was referring too, I copied the wrong line at first)
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using <jsp:attribute> tags in the first place instead of just using standard attribute notation on the tag?
 
Charessa Reilly
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just doing what I've learned. See the first line of my above post. Still very much learning.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens when you try the normal syntax?
 
Charessa Reilly
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried calling it with this:

<inq:singleRec aUser="${user}" theID="${id}" />

and I got the same result. ${user} is a properly assigned field. If I take out the tag call and put in just ${user} it displays the variable's value.
 
Charessa Reilly
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for kicks, I even tried switching the order of the declarations: and the error message remains the same.
 
Stefan Evans
Bartender
Pie
Posts: 1670
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I presume you have a methods getAUser() and setAUser().

My suggestion would be to try:


Check out the decapitilize method in java.beans.Introspector for an explanation.
 
Paul Clapham
Sheriff
Pie
Posts: 20758
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:I presume you have a methods getAUser() and setAUser().


Ouch. It's the dreaded "setEMailAddress" problem!
 
Charessa Reilly
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe I'm missing a fundamental principle of custom tags.

I thought <%@ attribute name="someName" required="true" %> was all the code I needed to write in a tag to create that attribute in the tag. The jsp container would then create the appropriate getter and setter for it when it compiled. Am I wrong? Do I need to go back to jsp kindergarten?
 
Paul Clapham
Sheriff
Pie
Posts: 20758
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's nothing to do with custom tags. Follow the link that Stefan provided (to the Introspector class) and read the full text describing the decapitalize() method. It's simply a quirk of the name you chose.
 
Charessa Reilly
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
even though if I'm not using a bean?

ugh. hwo about I just make them all lower case. Will later maintainers hate me?
 
Paul Clapham
Sheriff
Pie
Posts: 20758
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the same naming and capitalization conventions as for beans. The problem only arises when your property name (for a bean) or parameter name (in this case) starts with a lower-case character followed by an upper-case character, as in "eMail" (where I got burned by this) or as in "aUser" (your situation).

Why not just call the parameter "user"? Or if the "A" stands for something, like say "Abattoir" then spell that out?
 
Charessa Reilly
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah, the "a" was just an indefinite article. I swapped the name out. And, actually, this helps with an issue in another issue in another area. So I'm glad I asked. Thanks for the help!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic