Understanding the Initialize Method

Hi,

I

Initialize method is invoked every time page bean is created. When you switch between custom inbox and task details because it stays within a scope of the same web application (both custom inbox and task details portlets are defined in the same app) you task details page bean never expires and thus leading to case you have described.

We already have an SR opened on this issue because it is a common problem, but we don’t offer a solution just yet.

The way to workaround this on your side would be to test “taskID” preference and invoke web service if it changed in beforeRenderResponse() method. You can use the same place to refresh any internal providers which also might be cached and cause old data to show up in the ui:

String taskID = “”;

protected void beforeRenderResponse() {
super.beforeRenderResponse();
String newTaskID = (String) resolveExpression(“#{activePreferencesBean.taskID}”);
if (!taskID.equals(newTaskID)) {
// call web service
}
}

You can use the other methods:

public void beforeRestoreView()
public void afterRestoreView()
public void beforeRenderResponse()
public void beforeApplyRequestValues()
public void afterApplyRequestValues()
public void beforeProcessValidations()
public void afterProcessValidations()
public void beforeUpdateModelValues()
public void afterUpdateModelValues()
public void beforeInvokeApplication()
public void afterInvokeApplication()

They are executed in the following order:

*** Executing BEFORE RESTORE VIEW
*** Executing AFTER RESTORE VIEW
*** Executing BEFORE APPLY REQUEST VALUES
*** Executing AFTER APPLY REQUEST VALUES
*** Executing BEFORE PROCESS VALIDATIONS
*** Executing AFTER PROCESS VALIDATIONS
*** Executing BEFORE UPDATE MODEL VALUES
*** Executing AFTER UPDATE MODEL VALUES
*** Executing BEFORE INVOKE APPLICATION
*** Executing AFTER INVOKE APPLICATION

Edgardo

Hi,

I tried the following in my class DefinicionesInicialesViewDefaultviewView which extends BaseTaskDetailsPageBean.

protected void beforeRenderResponse()
{
//execute original beforeRenderResponse
super.beforeRenderResponse();

  //get new task Id 
  String newTaskID = (String) resolveExpression("# {activePreferencesBean.taskID}"); 
	
  //check if we are in a new task
if (!this.definicionesInicialesViewDefaultviewView.definicionesIniciales.getTaskID().equals(newTaskID)) 
{ 

 	//instantiate web service object
FljBuscaDefinInicialInfo objSvc = getFljBuscaDefinInicialInfo();
	
//set input parameters
objSvc.getParameters().setP_NUM_SINI (this.definicionesInicialesViewDefaultviewView.definicionesIniciales.getTaskData().getClaimsDocument().getExpediente_Doc().getExpediente_doc().getNum_sini());

objSvc.getParameters().setP_NRO_EXPED(this.definicionesInicialesViewDefaultviewView.definicionesIniciales.getTaskData().getClaimsDocument().getExpediente_Doc().getExpediente_doc().getNro_exped());
	
//execute web service
objSvc.refresh();
	
//set values to business data  
this.definicionesInicialesViewDefaultviewView.definicionesIniciales.getTaskData().getClaimsDocument().getExpediente_Doc().getExpediente_doc().setNegligencia(objSvc.getResult().getNEGLIGENCIA());
		this.definicionesInicialesViewDefaultviewView.definicionesIniciales.getTaskData().getClaimsDocument().getExpediente_Doc().getExpediente_doc().setMto_danos_prop(java.lang.Double.parseDouble(objSvc.getResult().getMTO_DANOS_PROP()));
	}

}

But I’m getting the following error:

[POP.001.0002] A “javax.portlet.PortletException” occurred with the Message “com.webMethods.portal.bizPolicy.BizException: [POP.001.0002] A “javax.portlet.PortletException” occurred with the Message “at com.webMethods.caf.faces.portlet.FacesPortlet.render(FacesPortlet.java:460)””

java.lang.NullPointerException
at com.webMethods.caf.definicionesinicialesview.DefinicionesInicialesViewDefaultviewView.beforeRenderResponse(DefinicionesInicialesViewDefaultviewView.java:78)
at com.webMethods.caf.faces.bean.BaseViewBean.beforePhase(BaseViewBean.java:85)
at com.webMethods.caf.faces.bean.FacesBeanPhaseListener.beforePhase(FacesBeanPhaseListener.java:30)
at com.webMethods.caf.faces.portlet.PortletLifecycle.phase(PortletLifecycle.java:241)


I’m executing correctly the web service?

Thanks

use this.definicionesIniciales.getTaskData()…

instead of

this.definicionesInicialesViewDefaultviewView.definicionesIniciales…

and that solve it

Thanks