When I click on submit button for a jsf page from a jsf portlet, mymethod of jsf bean is invoked.
<h:commandButton id="id1" action="#{Mybean.mymethod}" value="Click" />
public String mymethod() {
FacesContext fc = FacesContext.getCurrentInstance();
Object obj = fc.getExternalContext().getResponse();
if (obj instanceof ActionResponse){
System.out.println("ActionResponse !");
} else if (obj instanceof RenderResponse) {
System.out.println("RenderResponse !");
}
}
But none of the types its satisfying for Response object. What type of response is it? Beause I am trying to figure if it is ActionResponse, then I need to set setEvent method. And I guess it should be ActionResponse type right? I wonder why its not.
<-Modified->
Now I am getting Action Response. Might be because I have jsf 1.2 instead of 1.1 and I am in different system.
For a Portlet A, I have set the event in bean as follows,
ar.setEvent("showResults", "true"); //ar is ActionResponse
Then in Portlet class for Portlet B, I am doing as follows,
public class IPC extends GenericFacesPortlet {
protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException
{
if (request.getAttribute("showResults") == "true") {
request.setAttribute("javax.portlet.faces.viewId", "/JsfB_alt.jsp");
}
super.doView(request, response);
}
@ProcessEvent
public void processIPCEvent(EventRequest eRequest, EventResponse eResponse)
throws PortletException, IOException
{
Event event = eRequest.getEvent();
if(event.getName().equals("showResults")){
System.out.println("Event encountered !");
eRequest.setAttribute("showResults", "true");
}
}
}
So what I am trying to do is change from default view of Portlet B from /JsfB.jsp to /JsfB_alt.jsp when I click the button in Portlet A by setting an event.
But event is not listened as I can see that "Event encountered" is not getting printed.
I even tried changing processIPCEvent to processEvent with @Override but still its not called. I hope it will be called automatically when there is any event, right? I feel problem in setting event in ar.setEvent() What do you think?
FYI, I am using weblogic server 10.3 and jsf 1.2
Please suggest what could be the problem.