私はSpring管理のJSF beanを使用していますが、今は注釈タグを使用する必要がありますか?Springの範囲かJSFか?Spring管理のJSF bean
@ViewScopedはJSFアノテーションが機能しておらず、リクエストスコープとして動作していることに気付きましたか?
私はSpring管理のJSF beanを使用していますが、今は注釈タグを使用する必要がありますか?Springの範囲かJSFか?Spring管理のJSF bean
@ViewScopedはJSFアノテーションが機能しておらず、リクエストスコープとして動作していることに気付きましたか?
を実装することができ、その後、あなたはorg.springframework.context.annotation.Scope
注釈と範囲をマークする必要があります。
この記事を読む:この記事の情報:http://www.beyondjava.net/blog/integrate-jsf-2-spring-3-nicely/
を私はこれをした:あなたのバッキングBeanを作成し、その後
public abstract class AutowireableManagedBean {
protected Logger logger = LoggerFactory.getLogger(getClass());
protected AutowireCapableBeanFactory ctx;
@PostConstruct
protected void init() {
logger.debug("init");
ctx = WebApplicationContextUtils
.getWebApplicationContext(
(ServletContext) FacesContext.getCurrentInstance()
.getExternalContext().getContext())
.getAutowireCapableBeanFactory();
// The following line does the magic
ctx.autowireBean(this);
}
...
}
:
は、このようなJSFバッキングBeanの抽象スーパークラスを定義します。そのスーパークラスを拡張すると、Spring Beanをオートワイヤーすることができ、JSF固有のビュースコープを使用することができます:
@ManagedBean
@ViewScoped
public class MyBackingBean extends AutowireableManagedBean {
@Autowired
private MyDao myDao;