-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi :
I have defined some attributes in the servletcontext like this:
public void contextInitialized(ServletContextEvent event){
ServletContext context = event.getServletContext();
List<State> listState = null;
List<City> listCities = null;
try {
listState = ApiManager.getStateDao().readAllState();
listCities = ApiManager.getCityDao().readAllCity();
} catch (DAOException ex) {
java.util.logging.Logger.getLogger(ContextListener.class.getName()).log(Level.SEVERE, null, ex);
}
context.setAttribute(Constants.listStates, listState);
context.setAttribute(Constants.listCities, listCities);
log.debug("contextInitialized : void");
}
and later am trying to access the same in the intiatior like this:
public void doAfterCompose(Page page, Component[] comp)
throws java.lang.Exception {
ServletContext context = (ServletContext) Executions.getCurrent().getDesktop().getWebApp().getNativeContext();
List listStates = (List)context.getAttribute(Constants.listStates);
page.setVariable("modelStates", listStates);
super.doAfterCompose(page, comp);
}
}
but am not able to get hold of the attributes. What wrong am I doing?
regards
Devinder
did you put the declaration of servletcontext listener in your web.xml?
/robbie
Asked: 2009-04-03 19:36:53 +0800
Seen: 511 times
Last updated: Apr 06 '09