Here is what I assumed Struts was doing: take the property name, capitalize the first letter, append get to the front and then call that method:

lName -> LName -> getLName()
fax -> Fax -> getFax()

This technique would jive with what most IDE's do when they generate getters for attributes.

But, instead, I think *this* is what it's doing:

The "get" is stripped off of each getter method, then the java.beans.Introspector.decapitalize is being called on what's left. This creates a mapping of names to their corresponding getter methods.

So I'd have
getLName -> LName -> decapitalize -> LName
getFax -> Fax -> decapitalize -> fax

meaning that a property of "fax" would call getFax() and a property of LName would call getLName(). Any other variations (ie, Fax or lName) would not have a corresponding getter method. Personally, I think this is confusing, but at least I understand it now, and I'll name my variables to account for this behavior.

Thanks for the assistance.


David Graham wrote:


Section 8.8 of the JavaBeans spec details the capitalization rules. My
guess is that it can't find your property because it starts with 2 upper
case letters and assumes the rest is upper case (which getLName isn't). Use "lastName" and everything will work fine :-).


David

--- Wes Rood <[EMAIL PROTECTED]> wrote:


Could you point me to more information on this behavior?

I'm still confused as to why it will capitailze the "f" in "fax" to locate the getFax() method, but it will not capitalize the "l" in "lName" to locate the getLName() method.

Thanks!

David Graham wrote:



This is standard JavaBean behavior.  Regardless, I encourage you to use
lastName instead because lName is rather ugly and confusing.

David

--- Wes Rood <[EMAIL PROTECTED]> wrote:




I have an object as follows

public class Contact {
...
  private String lName;  // the contact's last name
  private String fax; // the contact's fax number
...
  public String getLName() {
      return lName;
  }

  public String getFax() {
      return fax;
  }
...
}

Then I use <nested:iterate> to go through a list of Contact objects


and

attempt to access the lName and the fax attributes. I observe the following behavior:

<nested:write property="fax" /> correctly displays the value of the "fax" attribute
while:
<nested:write property="Fax" /> causes org.apache.jasper.JasperException: No getter method for property contacts[0].Fax of bean ...


Apparently it is uppercasing the "f" in "fax" to call getFax(), but


when


the "F" is already in caps, it doesn't see the attribute. This is


fine,


but then I tried accessing the "lName" property:

<nested:write property="lName"/> causes org.apache.jasper.JasperException: No getter method for property contacts[0].lName of bean ...
while:
<nested:write property="LName" /> correctly displays the value of the "lName" attribute


I also rewrote the jsp logic using <logic:iterate> and <bean:write>


and

the same thing happened.

What is going on here? It appears that the "N" in the lName property


is


affecting how the "L" is handled. Any ideas?



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to