Troy,

Yes, you can use the constructor for these tasks, if it suits you. I would be cautious though, what I put in a managed-bean constructor. Keep in mind that the class will be automatically instantiated by the framework any time it is looked up or otherwise referenced. I've gotten myself into trouble by over-using the constructors.

In our project, we do still use the contstructors to load any drop-down lists that are rather static. For loading live data or dynamic drop-downs, however, we steer clear and go in favor of a load() method which is explicitly called as a result of the business logic set in motion by the command action.

Our pattern is far from perfect - we're just adapting as we go. I'd suggest you play around with it a bit, and see what works best. Don't rule out the use of the constructor, but don't abuse it either! ;)

Regards,

Jeff Bischoff
Kenneth L Kurz & Associates, Inc.

Troy Bull wrote:
Greetings

I have a faces page that allows the user to edit a table in the database. What I want to do is in the constructor of the backing bean load up some data from the database so that it can be displayed and edited on the faces page. Is this considered bad form? Also just off the top of my head is this a place I can also load collections that will be used for drop down list boxes?

Please help, I don't want to do things the wrong way...

Troy





Reply via email to