• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

a simple question about Form Bean setter method

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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(...);
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic