Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a simple question about Form Bean setter method

 
Artemesia Lakener
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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(...);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic