Forum Stats

  • 3,874,709 Users
  • 2,266,767 Discussions
  • 7,911,957 Comments

Discussions

Ajax - PortletBackingContext not available

668753
668753 Member Posts: 3
edited Nov 11, 2008 2:09AM in WebLogic Portal
Hi,

I am facing a problem while using portal aware XmlHttpRequest object on weblogic portal 10.2.
I am giving an ajax(portal aware) calls to an JPF action method , which in turns try to get the PortletBackingContext object through that request but strangely I am getting null as return.
I don't know what I am missing, I have already set the portal's property asynchronus mode = enabled, DVT = true, DISC =true.
I am putting the jsp and action method code here.can anybody help me for this...

JSP - javaScript method

function ${prefix}_doOnRowSelected(rowID)
{
alert("Selected row ID is "+rowID);

var xmlHttpReq001;
xmlHttpReq001 = new bea.wlp.disc.io.XMLHttpRequest();
alert(xmlHttpReq001);
var appContext = bea.wlp.disc.context.Application.getInstance();
var wellNo1 = "ep001";

var url = "/" + appContext.getWebAppName();
url +="/pageFlowControllers/wellSearch/raiseCustomEvent.do";

if(xmlHttpReq001)
{ alert("sending xmlHttpRequest");
xmlHttpReq001.open('GET', url, true);
var params = "";
params += "&WellNO=" + wellNo1;

xmlHttpReq001.send(params);
}

}//End Function....


CONTROLLER ACTION -


@Jpf.Action()
public Forward raiseCustomEvent()
{

String METHOD_NAME="raiseCustomEvent";
RmpLogger perfLogger = new RmpLogger(this.getClass());
perfLogger.start(METHOD_NAME);
logger.debug(METHOD_NAME, "Inside ");

String wellNo = getRequest().getParameter("WellNO");
//I am able to print this value
System.out.println("ROW NO ==" + wellNo);

System.out.println("raiseCustomEvent()::-Firing customEvent through PortletBackingContext");
PortletBackingContext context = null;
HttpServletRequest outerRequest = null;
outerRequest = ScopedServletUtils.getOuterRequest (getRequest());

context = PortletBackingContext. getPortletBackingContext(outerRequest);

//Prints null as value..
System.out.println("PortletBackingContext " + context);
//At this step it throw a nullPointerException
context.fireCustomEvent ("WellSelectionChange", "WELLNO");
System.out.println("After Firing the event");

perfLogger.end(METHOD_NAME);
perfLogger=null;
Forward forward = null;
return forward;
}
Tagged:

Answers

  • I think you're facing a couple of issues here.

    By hitting a ".do" url directly you're not going through portal, which results in:
    1) A new pageflow instance being created (can check by looking at the id when system.out.println'ing the pageFlow obj)
    2) no PortletBackingContext is available

    Try targeting the windowURL of the current portlet instead.

    Also, if the result of your custom event will affect other markup (such as update another portlet or change pages) you'll need to refresh that portlet (or some parent) on the client to give it a chance to respond to the event.
  • 668753
    668753 Member Posts: 3
    I have checked the page flow instance for every new Ajax call(through system.out.println) and it is same always.

    I want to hit a page flow action directly and how it is possible by using windowUrl.
This discussion has been closed.