// Create The Form var form = new Form("forms/bugSearchModel.xml");
// Set Some Form Specific Text Fields var model = form.getWidget(); model.buttonText = "Search"; model.title = "Search Bug Database";
form.showForm("internal/show-form/bugSearch");
// Create Hibernate Session
var factory = cocoon.getComponent(Packages.com.kismetsoftware.insecticide.PersistenceFactory.ROLE);
var hs = factory.createSession();
// Might as well quit now if the session is no good :(
if (hs == null){throw new Packages.org.apache.cocoon.ProcessingException("Hibernate session is null ");}
var bugSearch = new Packages.com.BugSearch(hs);
var eBug=new Packages.com.kismetsoftware.insecticide.Bug;
if (model.projectId.getValue() != null)
{
eBug.project=hs.find("from Project WHERE id='"+model.projectId.getValue()+"'").get(0);
}
eBug.severity=model.severity.getValue();
eBug.priority=model.priority.getValue();
eBug.opsys=model.opsys.getValue();
eBug.description=model.description.getValue();
eBug.status=model.status.getValue();
eBug.resolution=model.resolution.getValue();
var bug = bugSearch.findBugs(eBug);
// Clean Up Our Mess :) hs.flush(); hs.close(); cocoon.releaseComponent(factory);
// Send The User Their Result
cocoon.sendPage("internal/generate-view/bug_summary", {title : "Bugs",bug : bug});
so I guess my next question would be : would you just forget having a hibernate factory as a cocoon component? ie, just have yet another class like package.hibernateFactoryImpl? see I'm thinking it is too much overhead to be registering classes at every request.
I'm just very confused :)
Gregor J. Rothfuss wrote:
WHIRLYCOTT wrote:
If you will allow me to offer to you a thought which is only slightly related to your original question, I would strongly encourage you to move all of that transactional persistence stuff behind a facade a for a few reasons, listed in no particular order:
1) you'll be able to write junit tests to see if the backend is behaving
2) decouple your application layers into something resembling MVC
3) If you decide one day to use something other than Hibernate, you will be able to rip out the persistence mechanism without touching your flow controllers
4) you can reuse your facade in other applications
just to chime in here: phil used this technique to share these facades between struts and cocoon. very useful if you live in a heterogenous world..
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]