cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the contents of a text file and populate the data in a table ?

Former Member
0 Kudos

Hello All,

Can anyone advise on how to acheieve the above ? I am trying to read in a text file (CSV) and have the contents populated to the respective UI elements in a table. Any help is greatly appreciated.

from

Kwok Wei

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Let us consider you have list of names(Seperated by delimeter) in a text file and you want to display in a table.

1. Create Context Node "Names" and context attribute "Name"

2. Create Table and bind to the above context.

3.Write the following code in the "Init method.

try{

FileReader f =new FileReader("");

BufferedReader r=new BufferedReader(f);

String names=r.readLine();

Vector Names=new Vector();

// Use Tokenizer and store all the names i a vector//

for(int i=0;i<Names.size();i++){

IPrivate<<VieName>>.INameElement ele=wdContext.createNameElement();

ele.set<<Name>>( Names.get(i).toString());

wdContext.NodeName().addElement(ele);

}

Regards, Anilkumar

Message was edited by: Anilkumar Vippagunta

Former Member
0 Kudos

Thanks for the very prompt reply Anilkumar !!

I will go and try it out know. Btw, if I am using the FileUpload UI element, will I still be able to link this uploaded file directly and have it populated in my table then ?

from

Kwok Wei

Former Member
0 Kudos

If you have an upload element, you can upload the file to the server and access it directly as said in the code above

Former Member
0 Kudos

Hello Anilkumar,

Another question. May I ask whats the cardinality and selection value for the Value Node - Names ? I seems to be having some problem in deplying. Thanks.

from

Kwok Wei

Former Member
0 Kudos

As the node is being used for creating table the cardinality can be 0:n

Regards

Noufal

Answers (1)

Answers (1)

Former Member
0 Kudos

Example

How you want to name the Node and attribute is upto you only.

NodeName : Employee

AttributeName :Name

If you create ValueNode by default Cardinality will be 0..n and selection will be 0..1

So you can keep the default values.

Regards, Anilkumar