We all know we can get any Bean name in Java class Get JSF managed bean by name in any Servlet related class
Now my question is I have 3 Bean with 3 different JSF/XHTMl page and all 3 JSF/XHTML pages open a popup Modal Window with same component inside it right now we used 3 different popup and its working
But i want to use only one popup should be use so here issue is that I have to call some method from Popup to corresponding Parent Bean.
So for this i will want to pass bean name as a argument in the action attribute . Now for this how i would know Which bean class is parent of Popup Window.
<h:commandButton value="button" action="#{popupbean.someMethod(Parentbeanname)}"
and in my Popupbean.java i have wrote this code if i will get bean name as a string
public void addFeature(String beanName){
Bean bean = (Bean) request.getSession().getAttribute("beanName");
}
or I will get class name
public void addFeature(object className) {
if (classname instanceof Abean) {
ABean abean = (Abean) classname;
abean.callSomeMethod();
} else if (classname instanceof Bbean) {
BBean abean = (Bbean) classname;
bbean.callSomeMethod();
}