List of usage examples for org.springframework.web.jsf FacesContextUtils getRequiredWebApplicationContext
public static WebApplicationContext getRequiredWebApplicationContext(FacesContext fc) throws IllegalStateException
From source file:com.blogspot.na5cent.orm.util.JSFUtils.java
public static ServletContext getServletContext() { return FacesContextUtils.getRequiredWebApplicationContext(FacesContext.getCurrentInstance()) .getServletContext(); }
From source file:th.co.geniustree.osgi.prototype.authen.util.SpringUtils.java
public static <T> T getBean(Class<T> clazz) { ServletContext servletContext = FacesContextUtils .getRequiredWebApplicationContext(FacesContext.getCurrentInstance()).getServletContext(); return getBean(servletContext, clazz); }
From source file:th.co.geniustree.osgi.prototype.authen.util.SpringUtils.java
public static Object getBean(String bean) { ServletContext servletContext = FacesContextUtils .getRequiredWebApplicationContext(FacesContext.getCurrentInstance()).getServletContext(); return getBean(servletContext, bean); }
From source file:com.autentia.wuija.util.web.jsf.SpringUtils.java
/** * Devuelve un bean sacndolo del ApplicationContext de Spring. El ApplicationContext de Spring lo obtiene gracias * al contexto de JSF. Es obligatorio que ya exista el ApplicationContext, de lo contrario se lanzar una excepcin. * <p>//www .j a v a2 s . co m * La busqueda del bean se hace slo por nombre. * * @param <T> * @param beanName * @param beanClass * @param context * @return */ @SuppressWarnings("unchecked") public static <T> T getBean(FacesContext context, Class<T> beanClass, String beanName) { // XXX [wuija] hacer que si no se encuentra por nombre, se busuqe por tipo final WebApplicationContext wac = FacesContextUtils.getRequiredWebApplicationContext(context); final T bean = (T) wac.getBean(beanName, beanClass); return bean; }
From source file:pl.chilldev.facelets.taglib.spring.social.AbstractConnectedTag.java
/** * {@inheritDoc}//from w w w.j ava 2s .com * * @since 0.0.1 */ @Override public void apply(FaceletContext context, UIComponent parent) throws IOException { // get required components WebApplicationContext applicationContext = FacesContextUtils .getRequiredWebApplicationContext(context.getFacesContext()); ConnectionRepository connectionRepository = applicationContext.getBean(ConnectionRepository.class); // if connections repository does not exist simply don't process the content if (connectionRepository != null) { String provider = this.provider.getValue(context); // decide whether process or not the content of current element if (this.checkMatch(connectionRepository.findConnections(provider).size() > 0)) { this.nextHandler.apply(context, parent); } } }
From source file:org.hdiv.phaselisteners.LogMessageListener.java
public void beforePhase(PhaseEvent event) { if (log.isDebugEnabled()) { log.debug("MESSAGEVALIDATION - BEFORE"); }// w ww. j a va 2 s . c o m if (this.logMessages == null) { WebApplicationContext wac = FacesContextUtils.getRequiredWebApplicationContext(event.getFacesContext()); Logger logger = (Logger) wac.getBean("logger"); this.logMessages = new LogMessages(); this.logMessages.init(logger); } }
From source file:org.hdiv.phaseListeners.ComponentMessagesPhaseListener.java
public void beforePhase(PhaseEvent event) { if (this.messagesLog == null) { if (log.isDebugEnabled()) { log.debug("Initialize ComponentMessagesPhaseListener dependencies."); }/* w ww .j a v a2 s.co m*/ WebApplicationContext wac = FacesContextUtils.getRequiredWebApplicationContext(event.getFacesContext()); Logger logger = (Logger) wac.getBean("logger"); this.messagesLog = new ComponentMessagesLog(logger); } }
From source file:org.hdiv.phaselisteners.ComposePhaseListener.java
public void beforePhase(PhaseEvent event) { if (this.factory == null) { WebApplicationContext wac = FacesContextUtils.getRequiredWebApplicationContext(event.getFacesContext()); this.factory = (DataComposerFactory) wac.getBean("dataComposerFactory"); }//ww w . j a va2 s. c o m HttpServletRequest request = (HttpServletRequest) event.getFacesContext().getExternalContext().getRequest(); IDataComposer composer = this.factory.newInstance(); composer.startPage(); HDIVUtil.setDataComposer(composer, request); }
From source file:pl.chilldev.facelets.taglib.spring.web.MessageTag.java
/** * {@inheritDoc}/*from w ww . j av a 2 s . com*/ * * @since 0.0.1 */ @Override public void apply(FaceletContext context, UIComponent parent) { // get required components WebApplicationContext applicationContext = FacesContextUtils .getRequiredWebApplicationContext(context.getFacesContext()); MessageSource messageSource = applicationContext.getBean(MessageSource.class); String message = this.message.getValue(context); Locale locale = this.locale == null ? context.getLocale() : (Locale) this.locale.getObject(context, Locale.class); // if message source is not available simply stay with original message if (messageSource != null) { // note that we don't pass any arguments, we will handle interpolation on our as Spring's implementation // doesn't interpolate default message message = messageSource.getMessage(message, null, locale); } // interpolate parameters String separator = this.separator == null ? "," : this.separator.getValue(context); message = MessageFormat.format(message, this.args == null ? null : this.resolveArguments(this.args.getObject(context), separator)); // just output the text if (this.var == null) { UIOutput component = new UIOutput(); component.setValue(message); parent.getChildren().add(component); } else { // assign result to the variable context.setAttribute(this.var.getValue(context), message); } }