loading records into variable with data type 'list of values'

Hi,
i have a need to load the values of rows into an array variable.
in the context, i have created a variable with 'list of values' data type; but i am not sure how to assign values to this variable.
i would need a pointer for this.
any suggestions on how to do this?
thanks a lot,
Nicolas
5 REPLIES
Community Manager

Re: loading records into variable with data type 'list of values'

Hello Nicolas
At the moment, there is a bug on 'list of values' type, it only stores the last value.
You can use to tJavaFlex and define a list to stores the values of rows.
eg:
tFileInputDelimited--row1-->tJavaFlex
on the start code part:
java.util.List<String> list=new java.util.ArrayList<String>();
on the main code part:
list.add(row1.name);
on the end code part, set this list to a global var.
globalMap.put(list,list);
On the next subjob, you can get this list and iterate each value
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

Re: loading records into variable with data type 'list of values'

i suppose i was getting stuck with this bug.
thanks for clarifying the matter.

regards,
Nicolas

Re: loading records into variable with data type 'list of values'

hi folks,
i quick updated.
i am still find errors while using the JavaFlex;
the problem is with assigning the local list to the context variable, see below:

// start code
java.util.List<String> localList =new java.util.ArrayList<String>();

// main code
localList.add(row5.header_attributeValue);

// end of the component, outside/closing the loop
System.out.println( "printing columns list from array");
System.out.println( "============================================================");
System.out.println();
System.out.println( localList.toString());
System.out.println( "============================================================");
System.out.println( );
// the above prints the correct list
globalMap.put( context.listOfValues , localList );

could you please provide me with information on how to set the localList value to the context variable?
many thanks,
Nicolas
Community Manager

Re: loading records into variable with data type 'list of values'

Hello Nicolas
As I said before, the type 'list of values' is a bug, so I suggest you to use a java list. In the end code, we set a list to a global var, eg:
globalMap.put("list",localList);

and later we can get this list and iterate each value of list, eg:
java.util.List<String> newlistName =new java.util.ArrayList<String>();
newListName=(java.util.List<String>)globalMap.get("list")

Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

Re: loading records into variable with data type 'list of values'

thanks shong,
but i am failing to understand how this process works.
i tried using a javaflex to iterate over the variable but it fails.
could you explain in further detial how to retrieve the value of this 'list of values' variable?
thanks a lot

Nicolas