This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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(...);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a simple question about Form Bean setter method