mercredi 1 juillet 2015

How to propagate parameter from JSF to EJB

I need to propagate some parameter (attribute) from JSF (UI layer) to EJB.

@Stateful(name = "myBeanDispatcher")
@Local(MyBean.class)
public class MyBeanDispatcher implements MyBean {
    @EJB(lookup = "lookup_string2")
    private MyBean myBean1;

    @EJB(lookup = "lookup_string2")
    private MyBean myBean2;

    public void someMethod() {
        if (jsfParameter == "Value1") {
            myBean1.someMethod();
        } else {
            myBean2.someMethod();
        }
    }
}

@Named
public class JsfBean {
    @EJB(beanName = "myBeanDispatcher")
    private MyBean myBean;
}

Depending on this parameter different implementations of the interface must be called. I already have a bunch of services and now need to customize the calls. And I don't want to add new parameter to each existing method. Is this even possible to pass some contextual data from JSF to EJB?

Aucun commentaire:

Enregistrer un commentaire