• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why we are not using the full name of the method while setting the setproperty

 
Vasantha Prabha
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one tell why we are not mentioning the full name
while we set the property in the useBean tag
(eg)
<jsp:setProperty name="Id name" property="Count" value="2" />
and the method full name is -->public void setCount(int val)

Regards,
Sangeetha Prabindh
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cause you simple tell the jsp:setProperty tag which property should be filled and not which method to call.
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think someone from microsoft must have just moved to Sun to work on JSP because this is the sort of crappy thing that reminds me of visual basic and not my loverly Java.
One of the fundamental concepts of Java and OO is that you hide the property and provide access to it through access methods. Now what we have here makes it seem as if you are directly accessing the property, which can only lead to confusion. The idea of converting the property name into the method name to me stinks of one massive FUDGE, which is bound to lead to countless bugs. Silly Silly Sun
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search for information on the term 'java bean'.
bear
 
Steve Leach
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tim Baker:
I think someone from microsoft must have just moved to Sun to work on JSP because this is the sort of crappy thing that reminds me of visual basic and not my loverly Java.
One of the fundamental concepts of Java and OO is that you hide the property and provide access to it through access methods. Now what we have here makes it seem as if you are directly accessing the property, which can only lead to confusion. The idea of converting the property name into the method name to me stinks of one massive FUDGE, which is bound to lead to countless bugs. Silly Silly Sun

Not at all.
As an example, we have a JavaBean with a property called "name". It is implemented with a private field called "namevalue", and getter/setter methods called "getName" and "setName". Everything is encapsulated properly. If you call the field "name" rather than "namevalue" then everything stays the same. The confusion lies in thinking that you are directly accessing the field, when you are not.
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thats what i was saying
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!