JSF Renderer to get bean in Spring context
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
//get Spring Context
WebApplicationContext appCtx = FacesContextUtils.getRequiredWebApplicationContext(context);
BeanClass bean = (BeanClass)appCtx.getBean("beanId");
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
//get Spring Context
WebApplicationContext appCtx = FacesContextUtils.getRequiredWebApplicationContext(context);
BeanClass bean = (BeanClass)appCtx.getBean("beanId");
本文介绍了一个具体的示例,展示了如何在JSF应用中注入Spring管理的bean。通过覆盖`encodeBegin`方法,从Spring上下文中获取指定ID的bean,并将其类型转换为所需的`BeanClass`。
554

被折叠的 条评论
为什么被折叠?



