• 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

Diff btwn beans and ordinary object

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i got some doubts
whats the difference btwn java beans and ordinary objecs ?
why we need init in servlets and aplets why can we have constructors which can do the same work. why did java use init() methods instead of constructors?
please answer in detail
thanks in advance
Cherry

 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A bean is just a software module that has been carefully structured so that it is easily re-usable most ANYWHERE. Lot's of the class that we use all the time are already beans, they are not application or "context" specific.
From: http://developer.java.sun.com/developer/onlineTraining/Beans/JBShortCourse/ beans.html#beanIntroWhat

What's a Bean?
A Bean is a JavaBeans component. Beans are independent, reusable software modules. Beans may be visible objects, like AWT components, or invisible objects, like queues and stacks. A builder/integration tool manipulates Beans to create applets and applications.


****************************
You need an init in an applet to make a GENERIC method that the containing application (the browser or AppletViewer) can call on ANY applet to get it going. Constructors are not Generic. They must match the name of the Applet class.
The HTML page names the class that is the Applet. The browser does not actually do a "new Applet();" command. Remember the browser itself is (probably) not written in java. It is a native application making a call to a java class with an agreed upon "interface" (the AppletStub). The agreement is the set of methods that the browser must be able to honor on ANY APPLET like init(), start(), stop(), and setStub(). These are called by the browser without your coding them.

[This message has been edited by Cindy Glass (edited June 01, 2001).]
 
Cherry Mathew
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Cindy,
I got that explanation about init() but not beans
when sun came up with the bean concept then it will have some definite advantage. like how it works or something like that.
please explainin deatil.
Thanks in advance
Cherry
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Cherry Mathew:
Hi Cindy,
I got that explanation about init() but not beans
when sun came up with the bean concept then it will have some definite advantage. like how it works or something like that.
please explainin deatil.
Thanks in advance
Cherry


hi cherry,
let me try but i might be wrong!
Java Beans component model specifies a way of writing ur classes and methods.
It c'd be as simple as following the naming conventions specified by the model from Sun.
Now the container which w'd get ur bean on runtime can do an introspection on your object and if u follow the naming conventions specified ,get to know the properties of ur object.
So any java class can be converted to a java bean just by following a certain set of naming conventions.
Now this is not all.
If u check out java.beans package there are tons of classes listed out there if u need to do detailed stuff in addition to just setting/ getting a property.
karthik.

 
Cherry Mathew
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Karthik,
So its just a specification nothing more right
thank u very much
Bye Cherry
reply
    Bookmark Topic Watch Topic
  • New Topic