cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the contents of a webpage dynamically using flat files ?

Former Member
0 Kudos

Hi, i'm new to WebDynpro. I want to know the steps to get the contents of a web page dynamically which is stored in a flat file.Please help in this asap.

Accepted Solutions (0)

Answers (9)

Answers (9)

Former Member
0 Kudos

No more field

Former Member
0 Kudos

Hi Senthil,

If you specify the path like that.. I think it wont understand and you get such exception

Check the below code..

String strPath = WDURLGenerator.getResourcePath(

wdComponentAPI.getDeployableObjectPart(),

"xxx");

FileReader fileReader = new FileReader(strPath);

where "xxx" is your file name.

Try to use the about code to get the path of your local file.

Regards,

Kavitha

Former Member
0 Kudos

hi,

if you are deploying your application in some other machine, then the flat file which your application is referring should also be in that machine , otherwise it'll throw filenotfound exception. so you try to put your flat file in the server and then run the application

Former Member
0 Kudos

Hi ,

Are you getting any exception while reading that file or it showing blank results ?

Please post the exceptions if any.

Regards, Anilkumar

Former Member
0 Kudos

I'm still getting this exception..

java.io.FileNotFoundException

is the syntax correct ?

Regards , Senthil.

Former Member
0 Kudos

Hi, This is my code wriiten in buttonAction.

i'm getting the following Exception. And file is there in the specified location also.

java.io.FileNotFoundException: D:\Test\file.txt (The system cannot find the path specified)

public void onActionBtnShow(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionBtnShow(ServerEvent)

try{

FileReader f =new FileReader("D:
Test
file.txt");

BufferedReader r=new BufferedReader(f);

String names=r.readLine();

wdContext.nodeTestNode().currentTestNodeElement().setCtxTextEdit(names);

}

catch( Exception e ) {

String Ex = e.toString();

wdContext.currentContextElement().setValue(Ex);

}

//@@end

}

Help me in this..i'm stuck for last three days in this.

thanks and regards,SenthilNathan.

Former Member
0 Kudos

Hi,

Are you deploying on your localmachine only ??

Please remove the blank spaces in the directory name if any.

Make sure that this directory exitis where the engine is ?

Regards, Anilkumar

Former Member
0 Kudos

Hi,

the file is in the local machine. no spaces also in the directory ,

FileReader f =new FileReader("D:
Test
file.txt");

Still i'm getting the same fileNotFound Exception.

it is working in core java. what might be the problem ..any properties or settings needed ?

Regards,SenthilNathan.

Former Member
0 Kudos

Hi,

In that case directly you can pass the location of the file for the filereader.

Regards, Anilkumar

Message was edited by: Anilkumar Vippagunta

Former Member
0 Kudos

HI,

FileReader f =new FileReader("D:
New Folder
file.txt");

i'm getting the exception java.io.FileNotFoundException: D:\New Folder\file.txt (The system cannot find the path specified)

But it is working in core java execution..

what is syntax to give filestructure for fileReader();

please help in this.

Former Member
0 Kudos

Hi Senthil,

Is the "D" drive mapped from a network drive?

From webdynpro application if you are trying to access a file in the network then you will get the FileNotFound exception. (Eventhough the network path is mapped).

Regards,

Santhosh.C

Former Member
0 Kudos

Hi,

First i suggest to check the vector weather it conatins the list of names or not.I feel something wrong with the way you are reading the values from the file.

Regards, Anilkumar

Former Member
0 Kudos

Hi Senthil

1. Create a node in the context say Flatfile with cardinality 0..n

2. Create a value attribute Eachline of type string in the node.

3. Create a Http alias for a directory where you have place a flatfile

try {

BufferedReader in = new BufferedReader(new FileReader(<http alias name>/<filename>));

String str;

i=0;

while ((str = in.readLine()) != null) {

IPrivate<viewname>.INodeFlatFile nodeflatfile = null

INodeFlatFile = wdContext.nodeFlatFile.createNodeFlatFileElement();

wdContext.nodeFlatFile.addElement(i,nodeflatfile);

i++

nodeflatfile.setEachline(str);

}

in.close();

} catch (IOException e) {

}

Let me know if you require additional help.

Regards

NagaKishore

Former Member
0 Kudos

Thanks Kishore, but i dont want this method of creating Alias.The flatfile sits in my local machine.

Please help me in this,

Thanks and regards,

Senthil.

Former Member
0 Kudos

Hi,

1.First you need to read the file and populate the context in webdynpro.

2. Iterate through the context and create&Bind the UIElements in the wdDoModifyView method.

Refer to DynamicProgramming tutorials for this.

Regards, Anilkumar

Former Member
0 Kudos

Hi Senthil,

You can do this by normal java file reading !!!

Regards, Anilkumar

Former Member
0 Kudos

Thanks Anilkumar.

Former Member
0 Kudos

Hi,

My requirement is to populate the contents to UI Elements like LinkToURL,TextView..from the flatfile.

it will be having more linkToURLs. I've done the application as static, now i'm trying to make it dynamic.

can you please help in this.

Former Member
0 Kudos

Hi,

I would advise you to go through this.

http://help.sap.com/saphelp_nw04/helpdata/en/89/73a840bd6d3c13e10000000a155106/frameset.htm

You have to get the no of UI elements needed,

use a loop and create as many elements as needed using

view.createElement(UI class,ID);

Former Member
0 Kudos

Hi Senthil,

If you requirement is read a flat file on click of the LinktoURL,

1. Create a Http System alias in Visual admin.

Refer to this blog for details.

/people/renjith.andrews/blog/2005/03/31/creating-an-http-alias-in-was

2. Store all your flat files in the direcory specified in the alias.

3. Link the Http alias with the filename to the reference property of linktoURL UI element.

OR

If you want to create dynamic UI elements based on the content of the flat file then onload of the view you can read the file from the Http alias you have created and do the necessary creation.

Regards

NagaKishore

Former Member
0 Kudos

HI All,

Can anone help me by sending the fullcode to extract contents from file to the UI elements like LinktoURL,

the page may have more UI elements,textviews etc..

i tried the following code..but it is not working.

i'm new to this but i need it very urgently..please help me in this..and i tried this in doInit().

try{

FileReader f =new FileReader("file.txt");

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++){

IPrivateLinkView.IContextElement l1 =wdContext.createContextElement();

l1.setCtxLink( Names.get(i).toString());

wdThis.wdGetContext().addElement(l1);

}

}

catch( Exception e ) {

e.printStackTrace();

}

Thanks and regards,

SenthilNathan.

Former Member
0 Kudos

hi Senthil ,

Have you got the details in node.Please check it out

Regards,

Rohit.

Former Member
0 Kudos

HI,

I tried with Node also.it is not fetching.i'm getting the blank result.

Regards,Senthil.

Former Member
0 Kudos

Hi Senthil,

FileReader f =new FileReader(path);

Give the full path name in place of path.

It is better to use

IPrivateLinkView.I<node name>Element l1

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

{

l1 = wdContext.create<node name>Element();

l1.setCtxLink((String) Names.get(i));

wdThis.wdGetContext().addElement(l1);

}

If your problem is not solved give the code where you use String tokeniser to seperate values

Regards,

Rohit.

Former Member
0 Kudos

Hi Senthil,

See this link

Regards

Rohit

Former Member
0 Kudos

Thanks Rohit.