Forum Stats

  • 3,876,263 Users
  • 2,267,083 Discussions
  • 7,912,486 Comments

Discussions

Page Flow session Handling with Ajax

668753
668753 Member Posts: 3
edited Nov 10, 2008 1:33PM in WebLogic Portal
Hi,

I am facing a strange problem while using JPF with Ajax request calls.
It is very strange to me that while calling an action through XmlHttpRequest(portal aware) object controller maintains the state of its local action method variables also,
even if I set them to null It still maintains the variable state. I really don't know where it maintains that state and how to clear that.
I have tried a lot on this and didn't find any solution by now can anybody help me for the same...I am posting the code also here...

@Jpf.Action(forwards = { @Jpf.Forward(path = "/jsp/wellSearch/subGrid.jsp", name = "success") })
public Forward subGridAction()
{
//method local varaibles..
SearchCriteriaVO localSearchCriteriaVO = new SearchCriteriaVO();
ParameterVO parameterVO= new ParameterVO();
SearchCriteriaVO sessionSearchCriteriaVO=null;
String gridXmlSimple="";

String METHOD_NAME="subGridAction";
RmpLogger perfLogger = new RmpLogger(this.getClass());
perfLogger.start(METHOD_NAME);

//I am getting this request parameter from XmlHttpRequest object...
String fieldID = getRequest().getParameter("FIELD");


if(fieldID != null)
{
//Getting the session stored copy of object
sessionSearchCriteriaVO = (SearchCriteriaVO)getSession().getAttribute(RmpConstants.SEARCH_CRITERIA_VO);
localSearchCriteriaVO.setParameterList(null);
localSearchCriteriaVO.setParameterList(sessionSearchCriteriaVO.getParameterList());

parameterVO.setAttribute(RmpConstants.FIELD_KEY);
parameterVO.setOperator(Operator.EQ);
parameterVO.setValue(fieldID);

// localSearchCriteriaVO.addParameter(parameterVO) internally calls the setParameterList() to add this maintains a single list of all the parameterVO....
localSearchCriteriaVO.addParameter(parameterVO);
}

//I am checking the localSearchCriteriaVO's parameter list to know the values contained
//Strangely It for every new Ajax calls list maintains the previous values also..

for(ParameterVO pvo : localSearchCriteriaVO.getParameterList())
{
System.out.println(pvo.getAttribute()+" "+pvo.getOperator()+" "+pvo.getValue());
}

SearchResultVO searchResultVO = wellQueryBeanCtrl.runSearch(
localSearchCriteriaVO, getRequest());

if (localSearchCriteriaVO != null && searchResultVO != null)
{

System.out
.println("subGridAction::calling xmlProcessorCtrl");
gridXmlSimple = xmlProcessorCtrl.generateWellDetailsXML(searchResultVO);
// System.out.println("SubGridAction XML -- " + gridXmlSimple);
gridXmlSimple=gridXmlSimple.trim();
gridXmlSimple=gridXmlSimple.substring(38);
// System.out.println("SubGridAction XML SubString -- " + gridXmlSimple);
//testing
// getSession().setAttribute("xml", gridXmlSimple);
//...........................
this.setGridXmlStr(null);
this.setGridXmlStr(gridXmlSimple);


} else {
logger
.debug(
METHOD_NAME,
"WellSearchController-subGridAction():: SearchCriteriaVO or searchResultVO is null, so no generation of grid xml");
System.out
.println("WellSearchController-subGridAction():: SearchCriteriaVO or searchResultVO is null, so no generation of grid xml");
// return new Forward("success");
}

//I am setting all the variables to null, so for every new call there should not be any previous state..
localSearchCriteriaVO = null;
sessionSearchCriteriaVO =null;
parameterVO=null;
perfLogger.end(METHOD_NAME);
perfLogger = null;
Forward forward = new Forward("success");
return forward;
}

Edited by: user10525181 on Nov 4, 2008 10:31 PM

Edited by: user10525181 on Nov 5, 2008 4:16 AM

Answers

  • We wrote a tag to handle this use case, if I remember correctly.

    See the docs for the "Dynamic Content" tags at:
    http://download.oracle.com/docs/cd/E13155_01/wlp/docs103/portlets/building.html#wp1081461

    And:
    http://download.oracle.com/docs/cd/E13155_01/wlp/docs103/javadocjsp/commonui/index.html

    I believe they let you call actions on your JPF without facing the state issues that you're experiencing.
This discussion has been closed.