cancel
Showing results for 
Search instead for 
Did you mean: 

Procedure: Display of HTML stream using LinkToURL/LinkToAction UI Elements

Former Member
0 Kudos

Hi All,

I would like to know the procedure in which you include the static HTML files in project and then displayed using both : <b>LinkToURL</b> & <b>LinkToAction</b> UI Element.

Someone suggested using the FileOutputStream.

Can someone just explain the procedure step wise how to display the HTML Files kept in project(kept in MIMES Folder) using both the UI Elements.

Thanks in advance

Srikant

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Venkata,

I'll offer you a solution for displaying the HTML file (stored inside the same project) through LinkToURL UI. I don't know whether this is the correct way of doing it, but it always worked for me. If someone knows a better way, please let us know. I'm listing down each step involved in this :

1) <b>copy the html page to your mimes folder</b>

Switch to Navigator view of your NWDS. In your WebDynpro project navigate to the folder src->mimes ->components -> <your component name>. paste your html file(let's say abc.html) here.

2) <b>create an HTTP alias for the server folder of your WAS.</b>

Refer the weblog /people/renjith.andrews/blog/2005/03/31/creating-an-http-alias-in-was on how to create an HTTP alias.

Create an HTTP alias for the path 'Drive:\usr\sap\<SAP SYSTEM ID><Instance num>\j2ee\cluster\server0'. Let's call the alias 'systemAlias'.

3) <b>Create a LinkToURL UI element</b>

Create a LinkToURL UI element & mapp it's 'reference' property to some attribute, say 'url_path'. set 'target' as _NONE if you need to open the page in a new window.

4) <b>Write the necesary code in your WD iview.</b>

Retrieve the path of the html page using the following line of code :

String retrieved_path = WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(),"abc.html");

But this path starts from the server0 folder of your WAS and it starts like "./temp/webdynpro/web/local...". So we need to remove the leading dot.

String actual_path = retrievd_path.substring(1);

Now we need to append this path to the server alias to form the url of the html page.

String url = "http://<your-server-name>:50000/serverAlias"+actual_path ;

set the 'url_path' as this value:

wdContext.currentContextElement().setUrl_path(url);

This will give you the desired functionality.

I know this is a long way of achieveing a relatively small functionality. Even I would like to know a simpler way if there exists one.

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

The following should work:

1. Put the HTML file, e.g. "x.html", into folder src/mimes/Components/<your_component>

2. Set property LinkToURL.reference to "x.html"

No need to create an alias, compute the URL etc.

Armin

Former Member
0 Kudos

Hi Nibu,

Well if I'm keeping the files in the <components> folder, then what is the need of me creating HTTP alias. As without puttin the files in the project folder, and keepin it on server machine and giving the alias and hardcoding like this

<i>wdContext.currentContextElement.seturl("http://<servername>:<portno>/alias/abc.html");</i>

gives me the file.

Please explain me about this?

I want to know where is the default location we should put these files so that instead of hardcoding like above we can use something like this:

<i>./temp/webdynpro/...</i>

as instead of hardcoding of server i want to use alias?

and the way it suggested to pass the name in reference property, it doesn't work. Can some one suggest better method. as hardcoding is not good method.

Please suggest some method which is alternative to it??

thanks in advance

Srikant

Former Member
0 Kudos

Hi Venkat

When you create a alias it can point to any folder in your server. Well if you do no want to hardcode the server name then you can get the details of the server as follows

WDSystemLandscape.getSLDHost()":"WDSystemLandscape.getSLDPort()"/"<alias name>"/"<name of the file >

Regards

NagaKishore V

Former Member
0 Kudos

Hi Nibu and Naga,

I've followed the steps mentioned ,except instead of:

<b>WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObject,"abc,html");</b>

I'm using

<b>WDURLGenerator.getResourcePath("abc,html");</b>

I'm getting these errors:

1.The requested resource does not exist.

Details: Go to main page of this application!

on clicking main page it gives

2.You are not authorized to view the content of the requested directory.

Details: Directory listing is not allowed on this server.

Can you tell me where i'm doing the error.

Thanks

Srikant

Former Member
0 Kudos

How i will paste HTML file in components? in that components only delete option is there...How i paste my html file in there? pls tell me...

Former Member
0 Kudos

How to create HTML alias file?pls tell me...

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Venkat,

Use this code as Nibu said

WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(),"abc.html");

Regards,

Jaydeep

Former Member
0 Kudos

Hi

Well i tried its giving error as <b>WDAliasResolvingException</b> .

Can you tell me what i should to resolve it?

Thanks in advance

Srikant

Former Member
0 Kudos

Hi,

This exception is thrown if the alias to deployable object and application couldn't be resolved.

Try accessing the file using using

http://<Server name>:<port>/<alias name>/<your file name>

If the file doesn't open then your alias is wrong otherwise it should work.

Regards,

Jaydeep

Former Member
0 Kudos

Hi Jaydeep,

You righthly said that alias is not resolved. I've already defined the alias name in the VA. But still its giving error.

My files are located in my project folder. So firstly they will be getting deployed then they will be accessible.

I have given systemAlias as HTTP Alias

<i>systemAlias = C:/usr/sap/J2E/JC00/j2ee/cluster/server0</i>

and in the <i>\temp\webdynpro\web\<proj_name>\Components\<component-name></i> folder the files have been uploaded too.

here it is <i>./temp/webdynpro/web/local/proj_name/components/component_name/</i>

So, But when i write the code

<i>WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObject(),"abc.html")</i>

its giving error of Unhandled Exception Type <i><b>WDAliasResolvingException</b></i>

but on giving following code:

<i>WDURLGenerator.getResourcePath("abc.html");</i>

its returning following message.

<i>./temp/webdynpro/web/abc.htm</i>

So as u see there is confilct when it comes to the location of the file.

How to resolve this issue?

Thanks in advance

Srikant

Former Member
0 Kudos

Armin,

I had tried that many times before going for this. Unfortunately it didn't work for me. Can you please confirm if you have used this for LinkToUrl UI?

The other alternative I found was storing the html file in the mimes folder & hardcoding the source as http://<host name>:50000/webdynpro/resources/local/<your-project>/Components/<your-component>/<your html file name>.

This hardcoding of the entire path worked fine for me, but not just giving the file name only as you said.

Best Regards,

Nibu.

Former Member
0 Kudos

Hi,

1. In case of LinkToAction , place a FrameUIElement and assign the source of the frame to the html page.

2. In case of URL check the following post and assign the URL source to the http://path

Regards, Anilkumar

Former Member
0 Kudos

Hi Anil

I can understand the part for LinkToAction UI Element.

Can you be more descriptive on LinkToURL UI Element.

I just want to know how to go about this through

1.FileReader

2.and any other way.

Can u be more elaborative?

Thanks in advance

Srikant

Former Member
0 Kudos

hi Anil,

i tried LinkToAction, placed a IFrame UI element and assgined the source of the frame to HTML page by following method.

Firstly i got the path of path of the HTML page through

<i>String path = WDURLGenerator.getResourcePath("abc.html");

wdContext.currentContextElement().setCaption(path);</i>

where Content is context element.

And the context element in the IFrame UI element is mapped to it.

but its giving error.

Can u tell me where i'm going wrong?

Thanks in advance

Srikant

Former Member
0 Kudos

hi Anil

Can u explain how to repeat the procedure in LinkToURL UI elment as i'm not able to fix the problem.

Thanks in advance

Srikant