Tapestry is instantiating your engine class and it is doing it with the no-arguments constructor. There is no other way. Check with a debugger, either you code is being called, or your configuration is wrong. The engine object doesn't magically appear ... Tapestry invokes Class.newInstance() to create it and that's going to run the no-arguments constructor.
Having each instance of your engine keep its own database connection is probably not the best idea, since there isn't explicit control on how large the pool of engines is. You should look into using some form of database connection pooling; most application servers include this, and there are standalone libraries as well. -- [EMAIL PROTECTED] http://tapestry.sf.net > > Hi Howard, > Thanks for your reply. Yes, I updated my application specification to identify > the new engine subclass to instantiate. Why is the engine constructor not called > ? I think engine constructor is the best place to do initialization. > I guess page constructor is not the right place to do what I am doing, isn't it > ? In the absence of constructors not working, I have to either keep track of > whether engine::init() has been called by any listener method or create/destroy > the database connection in each listener method. Both approaches don't look > good, is there a better approach ? > Thanks, > Aejaz > "Howard M. Lewis Ship" <[EMAIL PROTECTED]> wrote: You did update your > application specification to identify the new engine > subclass to instantiate, right? > > The page constructor: the page is loaded (instantiated, then configured) > first, then attached to the engine, so a call to getEngine() returns null > inside the constructor. You're probably getting a NPE from your > constructor; you should see this in the exception report. > > I tend to just lazily create things as needed, rather than pre-create them. > > ----- Original Message ----- > From: "Aejaz Muslim" > To: > Sent: Tuesday, May 28, 2002 11:41 PM > Subject: [Tapestry-developer] Engine/Page constructor question > > > > > > Hi, > > > > I am extending from SimpleEngine & want to provide a constructor for my > Engine class where I want to initialize database connection & construct some > PreparedStatements, but this constructor is never called(This is a no > argument constructor). I wanted to do the same at page level by providing a > constructor for a page(Home) where I made a call to getEngine() & init() > method of my Engine class but I got an Exception which said that Tapestry > couldn't create the > > instance for the Home page. > > > > Is this the right way to do what I am doing ? Please let me know. > > > > Thanks, > > > > Aejaz > > > > > > > > > > > > > > > > --------------------------------- > > Do You Yahoo!? > > Yahoo! - Official partner of 2002 FIFA World Cup > > > > --------------------------------- > Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup _______________________________________________________________ Don't miss the 2002 Sprint PCS Application Developer's Conference August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm _______________________________________________ Tapestry-developer mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/tapestry-developer
