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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies 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
 
Similar Threads
NoSuchMethodError
Will the setters be called
javabean getter and setter
Pre-select collection of options (drop-downs)
<jsp:useBean> example