droux
Aug 23rd, 2004, 04:24 AM
I have this in a Struts action. For some reason it feels "wrong" to me.
CategoryDAO dao = (CategoryDAO) WebApplicationContextUtils.getWebApplicationContex t(this.servlet.getServletContext()).getBean("CategoryDAO");
Category category = dao.createCategory(form.getName());
Both CategoryDAO and Category are interfaces.
I would have preferred using a prototype bean so that I can do something like this:
Category category = ...getBean("Category");
But then I need to setup the bean using:
category.setName(form.getName());
If there are a lot of properties I need to set this is going to get tedious.
Somewhere I am not understanding IOC very well. Please help!
CategoryDAO dao = (CategoryDAO) WebApplicationContextUtils.getWebApplicationContex t(this.servlet.getServletContext()).getBean("CategoryDAO");
Category category = dao.createCategory(form.getName());
Both CategoryDAO and Category are interfaces.
I would have preferred using a prototype bean so that I can do something like this:
Category category = ...getBean("Category");
But then I need to setup the bean using:
category.setName(form.getName());
If there are a lot of properties I need to set this is going to get tedious.
Somewhere I am not understanding IOC very well. Please help!