cancel
Showing results for 
Search instead for 
Did you mean: 

cannot set value to context element

Former Member
0 Kudos

Hi,

I have tried to set the value retrieved from IGPStructureInfo into the ContextElement in execute method.

However, when I tried to retrieve the value in other method, I get a null.

For example:

execute (... ) {

this.executionContext = executionContext;

//Process the input parameters

IGPStructure input = executionContext.getInputStructure();

IGPStructure recommendStructure = input.getStructure("GP_IN");

//Retrieve data and set new values in the context

String A= recommendStructure.getAttributeAsString("I_A");

contextElement.setA(A);

}

Then In

public void wdDoInit()

{

...

String A = contextElement.getA("A");

// when i print the string A at this point, it is null

}

I am currently using CE7.1

Can help??? Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Please provide full code inside wdDoInit(). Has the execute() method already been called when you access the context attribute?

Armin

Former Member
0 Kudos

hi,

The full code is something like this:

public void wdDoInit()

{

//@@begin wdDoInit()

IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();

// Retrieve user id in the Enterprise portal

String epUserId= this.getUserId();

// Retrieve Name from Enterprise Portal

wdContext.currentContextElement().setRoNric(epUserId);

try {

// 1. create model objects

resignationModel = new MResignationWS();

Request_RequestDetail requestDetailModel = new Request_RequestDetail(resignationModel);

// 2. associate model objects

String roNric = contextElement.getRoNric();

String requestId = contextElement.getRequestId();

requestDetailModel.setRoNric(roNric);

requestDetailModel.setRequestId(requestId);

// 3. bind executable model object to context node

wdContext.nodeRequest_ReqDetail().bind(requestDetailModel);

// 4. invoke ResignationService <<Web Service>>

logger.logT(Severity.INFO, "invocaing resignation services for Recommendation Request Details ");

requestDetailModel.execute();

wdContext.nodeResponse().invalidate();

}catch(WDWSModelExecuteException e ) {

msgMgr.reportException(textAccessor.getText("RESIGNATION_DETAILS_ERROR"));

msgMgr.reportException(e.getStackTraceString());

logger.logT(Severity.ERROR, e.getStackTraceString());

}catch (Throwable e) {

msgMgr.reportException(textAccessor.getText("SYSTEM_ERROR"));

msgMgr.reportException(e.getLocalizedMessage());

logger.logT(Severity.ERROR, e.getLocalizedMessage());

}

//@@end

}

execute method does invoke since i have place the value to the context and do a print in the method. At that point in time, there value still exist, however when it is retrieve from the wdDoInit method, it is null

Former Member
0 Kudos

What do you mean with "something like this"? Is this the real code or not? Where do you access the attribute using that strange method getA("A")?

Armin

Former Member
0 Kudos

For execute method :

execute (... ) {

this.executionContext = executionContext;

//Process the input parameters

IGPStructure input = executionContext.getInputStructure();

IGPStructure recommendStructure = input.getStructure("GP_IN");

//Retrieve data and set new values in the context

String requestId= recommendStructure.getAttributeAsString("I_RequestId");

contextElement.setRequestId( requestID); // I set this request id to the context element in WD

// i have tried retrieve from this requestId from contextElement using contextElement.getRequestId and there is value here.

}

public void wdDoInit()

{

//@@begin wdDoInit()

IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();

// Retrieve user id in the Enterprise portal

String epUserId= this.getUserId();

// Retrieve Name from Enterprise Portal

wdContext.currentContextElement().setRoNric(epUserId);

try {

// 1. create model objects

resignationModel = new MResignationWS();

Request_RequestDetail requestDetailModel = new Request_RequestDetail(resignationModel);

// 2. associate model objects

String roNric = contextElement.getRoNric();

String requestId = contextElement.getRequestId(); // Here i retrieved, but it is null

requestDetailModel.setRoNric(roNric);

requestDetailModel.setRequestId(requestId);

// 3. bind executable model object to context node

wdContext.nodeRequest_ReqDetail().bind(requestDetailModel);

// 4. invoke ResignationService <<Web Service>>

logger.logT(Severity.INFO, "invocaing resignation services for Recommendation Request Details ");

requestDetailModel.execute();

wdContext.nodeResponse().invalidate();

}catch(WDWSModelExecuteException e ) {

msgMgr.reportException(textAccessor.getText("RESIGNATION_DETAILS_ERROR"));

msgMgr.reportException(e.getStackTraceString());

logger.logT(Severity.ERROR, e.getStackTraceString());

}catch (Throwable e) {

msgMgr.reportException(textAccessor.getText("SYSTEM_ERROR"));

msgMgr.reportException(e.getLocalizedMessage());

logger.logT(Severity.ERROR, e.getLocalizedMessage());

}

//@@end

}

Former Member
0 Kudos

Where does this variable "contextElement" come from, where is it set?

Armin

Former Member
0 Kudos

Hi,

wdDoInit() is called prior to your execute method. You are setting the context in the execute() method which has not yet been called while you are trying to get the value of the requestId in wdDoInit(), thus resulting into a null value.

Regards,

Murtuza

Former Member
0 Kudos

That mean: WDoInit will execute before getDescription and execute. In this case, do I retrieve the information and populate the data in execute method? or is there other method I can use to prepare the data to display to WD?

Any recommendation?

Edited by: wei wei on May 12, 2008 2:01 PM

Former Member
0 Kudos

Hi, I have displayed a message in each of the method and realise that execute method is invoked first then followed by the WDoInit(). In this case, the value should have been set.

any idea??? I am stuck!!! any one can help?

Former Member
0 Kudos

You are right. I have resolve the problem.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Why are you fetching value this way:

String A = contextElement.getA("A");

Try this :

String A = contextElement.getA();

regards,

amit bagati

Former Member
0 Kudos

HI,

I tried. but still cannot.

Don't understand why the value passed from the GP cannot be set to WD context Element?

did i miss something? or do i need to instantiate?

help help??