aspose file tools*
The moose likes Struts and the fly likes a simple question about Form Bean setter method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "a simple question about Form Bean setter method" Watch "a simple question about Form Bean setter method" New topic
Author

a simple question about Form Bean setter method

Artemesia Lakener
Ranch Hand

Joined: Jun 21, 2005
Posts: 162
In Form Bean's setter method, is there any "rule" we have to follow for naming convention ? for example, if I have a variable called "day_of_travel",

can I do

public void setDay_of_travel(...);

or

public void setDay_Of_travel(...);

or

public void setDay_Of_Travel(...);

If all of three methods work, then it seems there is no rule, then how does struts know when user enter that field which setter method it should use to fill the Form bean instance ?

thanks.
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
According to the standard Java Bean naming convention, the following is correct:

public void setDay_of_travel(...);

Of course, in Java, the variable would normally be named...

dayOfTravel

...and therefore have a corresponding setter of:

setDayOfTravel(...);
 
Don't get me started about those stupid light bulbs.
 
subject: a simple question about Form Bean setter method