1

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.

Gopi
  • 227
  • 2
  • 10
  • 30

2 Answers2

0

This is probably due to the portlet bridge implementation being used in your application.

Since the JSF implementations are written to work with the servlet API, they won't work out of the box in a portlet. So, when a context is created the portlet response will likely be adapted to a servlet response. The context merely returns the objects passed to it at creation time.

In the bridges I've used (IBM implementations) these wrappers also implement the portlet interfaces but I'm not aware of a requirement to do so.

You may want to state your platform, libraries and their versions if you want a more informed answer.

Community
  • 1
  • 1
McDowell
  • 107,573
  • 31
  • 204
  • 267
0

I defined as java event (jsr) using <event-definition> and <supported-processing-event> in portlet.xml and now I am able to listen to it.

Gopi
  • 227
  • 2
  • 10
  • 30