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
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).]
"JavaRanch, where the deer and the Certified play" - David O'Meara
posted 19 years ago
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
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.
posted 19 years ago
Hi Karthik, So its just a specification nothing more right thank u very much Bye Cherry
Have you no shame? Have you no decency? Have you no tiny ad?