Zhiyong Li wrote:

> I have two questions related with the set methods in any of the Form
> class, such as MyActionForm.
>
> 1. It seems to me that if we use a form with POST method, the
> corresponding "set" method will be called as it should be. What I want
> to confirm is that if I have the URL with query string, does the
> parameter specified overthere also cause the "set" to be called? For
> example, I have the URL: http://.../action?name=value And in the
> MyActionForm.java, I have the method:
>
>         public void setName(String name) {name = value;}
>

I imagine you really meant:

    private String name;
    public void setName(String name) {this.name = name;}

right?

>
> My experiment shows that when I clicked the URL, setName got called.
>

Yes -- the controller servlet sees that the field name (from the form) matches
the property name (from the bean), once you apply the JavaBeans design patterns
for method names.  See the JavaBeans spec for more details.

>
> 2. My second question is that I found the "set" method did not got
> called if the length of the "keyword" is 2. For example, in the above
> example, if "name" is "aT" and I have the "set" method,
>
>         public void setAT(String aT) {aT = value;}
>
> The "setAT" does not got called.
>

That's because this spelling does not match the required design pattern, so the
controller servlet (actually, it is the Java introspector that is used to ask a
bean class what it's property setter methods are) does not recognize this as a
property.

>
> Thank you for the help,
> Zhiyong Li
> Platform Development
> iBiomatics LLC ,  a SAS Company
> (919) 653-2746
> [EMAIL PROTECTED]

Craig McClanahan


Reply via email to