You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by rh...@rdg.boehringer-ingelheim.com on 2001/02/14 16:58:48 UTC

RE: ActionForm property naming convention problem

Yes, you described the scenario perfectly, and much better than I did :)
This is how I understand the process as well. Using your same example,
Struts will not allow that tag <html:text property="nTerminal"/> and
subsequently will not process the expected method named getNTerminal().
Instead a runtime error will occur while processing the tag (this is all the
information I get from the WebLogic Servlet container). For things to work,
I have to rename the property as "nterminal" in the bean and update the tag
as well to <html:text property="nterminal"/>. There is a problem with having
a capital letter in the 2nd position of the property name.
 
Bob

-----Original Message-----
From: Craig Tataryn [mailto:Craig.Tataryn@msdw.com]
Sent: Wednesday, February 14, 2001 10:28 AM
To: struts-user@jakarta.apache.org
Subject: Re: ActionForm property naming conventions


Basically (and I might be wrong) when you subsequently try access the
property, let's say with an <html:text property="nTerminal"/> tag,  Struts
will do a getNTerminal() on your ActionForm.  The default is to take the
property and do the following: 

1) append a "get" prefix to the property 
2) change the first letter of the property to uppercase 
3) call that method on the form bean. 


So for instance, it's prefixing your nTerminal property and mangaling it
like so: 


getNTerminal() 


Like I said, I haven't looked at the code, but this is how I understand the
process. 


Craig. 


rhayden@rdg.boehringer-ingelheim.com wrote: 


My question is best asked with an example... Why is it that I am unable to 
create a property named "nTerminal" for my ActionForm/JSP? This problem 
occurs when there is an uppercase letter in the 2nd position of the property

name. If I change the name to "nterminal" or "ntErminal" then things work 
just fine. In other words- getNterminal() is recognized by Struts, but 
getNTerminal() is invalid and results in a runtime error in the html tag. Is

this a limitation imposed by Javabean conventions or is this a Struts 
specific issue? (If you think I am crazy, then perhaps this problem is 
specific to WebLogic.) 

Thanks, 
Bob

-- 
I've been trying to change the world for years, but they just won't give me
the source code.... 
  


Re: ActionForm property naming convention problem

Posted by Craig Tataryn <Cr...@msdw.com>.
I think it's a problem with having the first letter of your property as
a small letter, I don't think it matters that the second letter is
capitalized.  Try it out and see.

FYI:

Found this somewhere a while back:
===========================
A PropertyDescriptor indicates not only the property, but also the
property
accessor methods (setter and getter methods). As described above, when
analyzing a bean, the Introspector first checks to see if it can get a
list of
PropertyDescriptors from the BeanInfo. If that fails, the Introspector
analyzes
the bean class, building a list of methods that match the signatures
<i>Type</i> get<i>Property</i>() and <i>void</i>
set<i>Property</i>(<i>Type</i>
value). From this list of methods, the Introspector then creates its own

PropertyDescriptor list.
===========================

And then this from the bean 1.01 spec:

8.8 Capitalization of inferred names.
========================
When we use design patterns to infer a property or event name, we need
to decide what rules
to follow for capitalizing the inferred name. If we extract the name
from the middle of a normal
mixedCase style Java name then the name will, by default, begin with a
capital letter.
Java programmers are accustomed to having normal identifiers start with
lower case letters.
Vigorous reviewer input has convinced us that we should follow this same
conventional rule
for property and event names.

Thus when we extract a property or event name from the middle of an
existing Java name, we
normally convert the first character to lower case. However to support
the occasional use of all
upper-case names, we check if the first two characters of the name are
both upper case and if
so leave it alone. So for example,
“FooBah” becomes “fooBah”
“Z” becomes “z”
“URL” becomes “URL”
We provide a method Introspector.decapitalize which implements this
conversion rule.
========================================

Craig.

rhayden@rdg.boehringer-ingelheim.com wrote:

>  Yes, you described the scenario perfectly, and much better than I did
> :) This is how I understand the process as well. Using your same
> example, Struts will not allow that tag <html:text
> property="nTerminal"/> and subsequently will not process the expected
> method named getNTerminal(). Instead a runtime error will occur while
> processing the tag (this is all the information I get from the
> WebLogic Servlet container). For things to work, I have to rename the
> property as "nterminal" in the bean and update the tag as well to
> <html:text property="nterminal"/>. There is a problem with having a
> capital letter in the 2nd position of the property name.Bob
>
>      -----Original Message-----
>      From: Craig Tataryn [mailto:Craig.Tataryn@msdw.com]
>      Sent: Wednesday, February 14, 2001 10:28 AM
>      To: struts-user@jakarta.apache.org
>      Subject: Re: ActionForm property naming conventions
>
>      Basically (and I might be wrong) when you subsequently try
>      access the property, let's say with an <html:text
>      property="nTerminal"/> tag,  Struts will do a getNTerminal()
>      on your ActionForm.  The default is to take the property and
>      do the following:
>
>      1) append a "get" prefix to the property
>      2) change the first letter of the property to uppercase
>      3) call that method on the form bean.
>
>      So for instance, it's prefixing your nTerminal property and
>      mangaling it like so:
>
>      getNTerminal()
>
>      Like I said, I haven't looked at the code, but this is how I
>      understand the process.
>
>      Craig.
>
>      rhayden@rdg.boehringer-ingelheim.com wrote:
>
>     > My question is best asked with an example... Why is it
>     > that I am unable to
>     > create a property named "nTerminal" for my ActionForm/JSP?
>     > This problem
>     > occurs when there is an uppercase letter in the 2nd
>     > position of the property
>     > name. If I change the name to "nterminal" or "ntErminal"
>     > then things work
>     > just fine. In other words- getNterminal() is recognized by
>     > Struts, but
>     > getNTerminal() is invalid and results in a runtime error
>     > in the html tag. Is
>     > this a limitation imposed by Javabean conventions or is
>     > this a Struts
>     > specific issue? (If you think I am crazy, then perhaps
>     > this problem is
>     > specific to WebLogic.)
>     >
>     > Thanks,
>     > Bob
>
>      --
>      I've been trying to change the world for years, but they
>      just won't give me the source code....
>
>
--
I've been trying to change the world for years, but they just won't give
me the source code....