Tuesday, August 14, 2007

Method to get spring applicatin context from JSF

if(userAcctService == null){
ServletContext servletContext =
(ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext();
ApplicationContext appContext =
WebApplicationContextUtils.getWebApplicationContext(servletContext);

//WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext());
userAcctService = (UserAcctService)appContext.getBean("httpInvokerProxy");
}

No comments: