anyone have used a container to store application scope data?

please, let me know if it's a bad practice.

El mar, 16 de 05 de 2006 a las 17:15, Jorge Martín Cuervo escribió:

> Hi all,
> 
> <h2><fmt:message key="search2.filter.job.title"/></h2>
> <p class="pEstrecho">
>       <span><fmt:message key="search2.filter.job.sector"/></span>
>       <html:select property="industryCode" styleClass="selectAncho">
>               <html:options collection="industryCodeMap"
>                     property="key" labelProperty="value"/>
>       </html:select>
> </p>
> 
> I use html:select with html:options to populate the options from the
> application scope.
> In the application scope i have a attribute called "industryCodeMap"
> with a Map that contains the data.
> I used a ServletContextListener to load the data on the webapp startup
> and goes fine.
> 
> Now i want to change the startup process with struts plugin, and also
> works good with the service.
> 
> [...]
> public void init(ActionServlet servlet, ModuleConfig config) throws
> ServletException {
>               
>       serviceClassName = findServiceClassName(config);
>               
>       ItemDAO itemDAO = DAOFactory.getDAOFactory().getItemDAO();
> 
>       ApplicationContainer container = new ApplicationContainer();
>               
>       container.setSector(itemDAO.getItems(IConstants.SECTOR_BLOCK_NAME));
>       container.setArea(itemDAO.getItems(IConstants.AREA_BLOCK_NAME));
>       
> container.setCoutries(itemDAO.getItems(IConstants.COUNTRIES_BLOCK_NAME));
>               
>       container.setServiceFactory(this);
>               
>       servlet.getServletContext().setAttribute(
>               IConstants.APPLICATION_CONTAINER_KEY, container);
> }
> [...]
> public interface IConstants {
> 
>       String APPLICATION_CONTAINER_KEY = "__APPLICATION_CONTAINER_KEY";
> 
> [...]
> 
> 
> I prefer to user a container bean to keep my data, and now i try to
> change the html:options to:
> 
> <html:options collection="__APPLICATION_CONTAINER_KEY.area"
>                     property="key" labelProperty="value"/>
> and crash with:
> 
> 
> javax.servlet.jsp.JspException: Cannot find bean under name
> __APPLICATION_CONTAINER_KEY.area
> 
> 
> the questionm is, how can i access to the container and then the
> property area?

-- 
;-)
____________________________________
Jorge Martin Cuervo
Analista Programador

Outsourcing Emarketplace
deFacto Powered by Standards

email <[EMAIL PROTECTED]>
voz +34 985 129 820
voz +34 660 026 384
____________________________________

Reply via email to