Is it possible to invoke more than one listener method using a single command component? For example,
A view scoped bean:
@ManagedBean
@ViewScoped
public final class ViewScopedBean implements Serializable
{
@ManagedProperty(value = "#{sessionScopedBean}")
private SessionScopedBean sessionScopedBean; //Getter/Setter.
private static final long serialVersionUID = 1L;
public ViewScopedBean() {}
public void action()
{
//Do something.
sessionScopedBean.action();
}
}
A session scoped bean:
@ManagedBean
@SessionScoped
public final class SessionScopedBean implements Serializable
{
private static final long serialVersionUID = 1L;
public SessionScopedBean () {}
public void action() {
//Do something.
}
}
A command button like the one given below,
<h:commandButton value="Action" actionListener="#{viewScopedBean.action}"/>
invokes the method action()
in ViewScopedBean
which in turn invokes the action()
method in SessionScopedBean
by injecting an instance of that bean.
Is it somehow possible do the same on XHTML so that a need to inject a bean just to invoke a method can be eliminated?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…