开发者

JSF2: Pass objects from one requestscoped bean into another Requestscoped bean?

In JSF2, h开发者_高级运维ow can i pass objects from one requestscoped bean to another requestscoped bean? I really don't want to make them sessionscoped.

Maybe can i inject one bean in the other?

Thank you.


Use the ManagedProperty annotation:

@ManagedBean(name="beanA") @RequestScoped
public class BeanA implements Serializable {
  @ManagedProperty(value="#{beanB}") 
  private BeanB beanB;
  public void setBeanB(BeanB b) { this.beanB = b; }
  public BeanB getBeanB() { return beanB; }
}

@ManagedBean(name="beanB") @RequestScoped
public class BeanB implements Serializable {}

I haven't tested that code. You can achieve similar results by defining managed properties in faces-config.xml.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜