8
Views
8
Comments
Solved
Record List in Java Extension Parameter
Application Type
Traditional Web
Platform Version
10.0.1102.1

Hi there,

I am wondering how to pass a list and then use it in Java extension as an output?

What should i pass in outsystems action and what is the code in java extension?

I want to return array of messages from kafka confluence.

I try a simple one like this:

in the caller (klik button), i send the parameter of type:

ToObject(JSonAcclist)

where 

JSonAcclist is of type
AccountTypeJson Record List

The Java extenstion is like this:

public static ActTryList mosTryList(java.lang.Object inParamParameter1) {

 

 ActTryList result = new ActTryList();

 result.outParamParameter2 ="1";

 // TODO: Write implementation for action

 RecordList recordList = (RecordList) inParamParameter1;

 

 STAccountTypeJsonStructure jstru = new STAccountTypeJsonStructure();

 jstru.ssAccountType = "hi";//aData.value();

 

 RCAccountTypeJsonRecord rec = new RCAccountTypeJsonRecord();

 rec.ssSTAccountTypeJson = jstru;

 

 try {

 result.outParamParameter2 ="2";

 recordList.append(rec);

 } catch (Exception e) {

 result.outParamParameter2 ="3" + e.getMessage();

 // TODO Auto-generated catch block

 e.printStackTrace();

 }

 


 return result;

, but i got error cast message in the exception:

Cannot cast 

outsystems.noskafkaconfluencebox.records.RCAccountTypeJsonRecord 

to 

oskafkaconfluencetest.records.RCAccountTypeJsonRecord

regards and thanks

Rank: #223
Solution

After 2 days trying, Eureka! -  I got the correct result - i stuck because of focus on "passed by reference" in only one INPUT parameter, the working one is to provide another OUTPUT with same type or of type Object that encpasulate that result. What is interesting is that if i only put Output parameter and append it, the result is also empty, so the Input is non trivial here, may be just for dummy, and then copy the Input result to the Output. Here are the steps in details:

1. Create a Struct, say it StruText with contains one attribute - AttribStru - of type Text

2. Create a Record, name it STRecord with contains one attribute - of type StruText 

3. Create an Action, name it TryList with these parameters: param1 as "INPUT" parameter with data type Record List and its record definition is STRecord; param2 as "OUTPUT" parameter with data type Record List and its record definition is STRecord;param3as "OUTPUT" parameter with data Object

The pics are here:


and the Java code is like this below:

package outsystems.noskafkaconfluencebox.actions;


import outsystems.hubedition.runtimeplatform.db.RecordList;

import outsystems.noskafkaconfluencebox.recordlists.RLSTrecordRecordList;

import outsystems.noskafkaconfluencebox.records.RCSTrecordRecord;

import outsystems.noskafkaconfluencebox.records.RCStruTextRecord;


public class ActTryList {

public String outParamParameter2;

public RLSTrecordRecordList outParamParameter5;

public java.lang.Object outParamParameter4;


/**

*

* @param inParamParameter1

**/

public static ActTryList mosTryList(java.lang.Object inParamParameter1, RLSTrecordRecordList inParamParameter3) {

 

 ActTryList result = new ActTryList();

 result.outParamParameter2 ="1";

 // TODO: Write implementation for action

 

 //RecordList rl = (RecordList)inParamParameter3;


 try {

 result.outParamParameter2 = result.outParamParameter2 + "88";

 

 RCStruTextRecord rtxt = new RCStruTextRecord();

 rtxt.ssSTStruText.ssAttribStru = "abc";

 

 RCSTrecordRecord rec = new RCSTrecordRecord();

 rec.ssSTSTrecord.ssAttribute1 = rtxt;

 inParamParameter3.append(rec);

 

 result.outParamParameter5 = inParamParameter3;

 result.outParamParameter4 = (Object)inParamParameter3;

 //rl.append(rec);

 

 } catch (Exception e) {

 result.outParamParameter2 = result.outParamParameter2 + "3" + e.getMessage();

 // TODO Auto-generated catch block

 e.printStackTrace();

 }

 

 return result;

}



}

Last, but not least, the caller is like this:


where:

and this is the result after calling:


regards and thank you

mvp_badge
MVP
Rank: #2

Hi IBox,

You could check Forge Extensions like XML Records or SortRecordList to see how it's done.

Rank: #223

Hi Sir,

I have check it, but the XML record is in .NET. 

And the Sort Record List, do not do append.

regards and thank you

Rank: #223

Why i refer to the same structure created in the Integration Studio used by the caller and the Java Extension cannot be cast? So confusing.

Rank: #223

How to cast it?

Tq

Rank: #223
Solution

After 2 days trying, Eureka! -  I got the correct result - i stuck because of focus on "passed by reference" in only one INPUT parameter, the working one is to provide another OUTPUT with same type or of type Object that encpasulate that result. What is interesting is that if i only put Output parameter and append it, the result is also empty, so the Input is non trivial here, may be just for dummy, and then copy the Input result to the Output. Here are the steps in details:

1. Create a Struct, say it StruText with contains one attribute - AttribStru - of type Text

2. Create a Record, name it STRecord with contains one attribute - of type StruText 

3. Create an Action, name it TryList with these parameters: param1 as "INPUT" parameter with data type Record List and its record definition is STRecord; param2 as "OUTPUT" parameter with data type Record List and its record definition is STRecord;param3as "OUTPUT" parameter with data Object

The pics are here:


and the Java code is like this below:

package outsystems.noskafkaconfluencebox.actions;


import outsystems.hubedition.runtimeplatform.db.RecordList;

import outsystems.noskafkaconfluencebox.recordlists.RLSTrecordRecordList;

import outsystems.noskafkaconfluencebox.records.RCSTrecordRecord;

import outsystems.noskafkaconfluencebox.records.RCStruTextRecord;


public class ActTryList {

public String outParamParameter2;

public RLSTrecordRecordList outParamParameter5;

public java.lang.Object outParamParameter4;


/**

*

* @param inParamParameter1

**/

public static ActTryList mosTryList(java.lang.Object inParamParameter1, RLSTrecordRecordList inParamParameter3) {

 

 ActTryList result = new ActTryList();

 result.outParamParameter2 ="1";

 // TODO: Write implementation for action

 

 //RecordList rl = (RecordList)inParamParameter3;


 try {

 result.outParamParameter2 = result.outParamParameter2 + "88";

 

 RCStruTextRecord rtxt = new RCStruTextRecord();

 rtxt.ssSTStruText.ssAttribStru = "abc";

 

 RCSTrecordRecord rec = new RCSTrecordRecord();

 rec.ssSTSTrecord.ssAttribute1 = rtxt;

 inParamParameter3.append(rec);

 

 result.outParamParameter5 = inParamParameter3;

 result.outParamParameter4 = (Object)inParamParameter3;

 //rl.append(rec);

 

 } catch (Exception e) {

 result.outParamParameter2 = result.outParamParameter2 + "3" + e.getMessage();

 // TODO Auto-generated catch block

 e.printStackTrace();

 }

 

 return result;

}



}

Last, but not least, the caller is like this:


where:

and this is the result after calling:


regards and thank you