Re: Java Bean Question
Chris ( Val ) wrote:
Point taken, but that's what I have read. Just to clarify, does
that myth also apply to enterprise java beans?
Enterprise JavaBeans are a completely different animal.
Lew wrote:
There is absolutely no mention in the specification of a pattern for the
constructor, not even that there must be a default constructor, much less that
it be specific. In fact, aBeanis not even limited to a single class.
Again, it's just what I have read in some tutorials, possibly
even on Sun's own site.
Citations? I take my information from the JavaBeans specification document,
which one might take to be authoritative. Did you read it?
The spec recommends instantiation through a call to Beans.instantiate().
Just out of interest, where would you make that call? (servlet, JSP,
etc...)
Anywhere you instantiate a Bean. I admit I've never followed that
recommendation, but then I haven't been using the full power of the JavaBeans
framework.
But if I supply my own user defined (overloaded) constructor that
takes arguments, doesn't the side effect of that cause the compiler
or JVM to *not* provide a default constructor anymore? thus it has
to be explicitly defined? or is it still not a requirement that it
be present at all?
Did you notice upthread that I said:
It only needs to be explicit if there is a non-default constructor
or if it does significant construction work, not usual for JSP beans.
?
This is the usual rule for default constructors.
--
Lew