aspose file tools*
The moose likes JSP and the fly likes Cannot find a setter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Cannot find a setter" Watch "Cannot find a setter" New topic
Author

Cannot find a setter

Charessa Reilly
Ranch Hand

Joined: May 26, 2011
Posts: 39
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

Joined: Jan 10, 2002
Posts: 61043
    
  66

Why are you using <jsp:attribute> tags in the first place instead of just using standard attribute notation on the tag?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Charessa Reilly
Ranch Hand

Joined: May 26, 2011
Posts: 39
Just doing what I've learned. See the first line of my above post. Still very much learning.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61043
    
  66

What happens when you try the normal syntax?
Charessa Reilly
Ranch Hand

Joined: May 26, 2011
Posts: 39
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

Joined: May 26, 2011
Posts: 39
for kicks, I even tried switching the order of the declarations: and the error message remains the same.
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Stefan Evans wrote:I presume you have a methods getAUser() and setAUser().


Ouch. It's the dreaded "setEMailAddress" problem!
Charessa Reilly
Ranch Hand

Joined: May 26, 2011
Posts: 39
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: May 26, 2011
Posts: 39
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: May 26, 2011
Posts: 39
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot find a setter