Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to reference a file from a viewlet via an URL?

Hello,
I have the following scenario: I've created a viewlet which is a client-side JavaScript that can invoke a server-side Java code via MODELLED_REST service calls. So far so good...
Now, I need to reference a file from my viewlet via an URL. I'd like to be able to do something like; reference the file "test.xml" from the viewlet defined in the dashboard for project "myProject":
http://localhost:9942/jazz/web/projectc/myProject#action=myfile=c:/jazz/test/test.xml

- How can I map the Jazz root web server with a physical directory? There is no api such as getRootDirectory()

- Is it the right approach?

Thank you in advance for any help....

0 votes



2 answers

Permanent link
Hi,

The simplest way is to put the file in a web bundle. That is, an OSGi bundle with the web bundle marker extension:

<extension point="net.jazz.ajax.webBundles"/>

Place the file in your /resources folder, which is the web root of the bundle, and use dojo.moduleUrl to get a URL to it. Here's an example from the bookmarks viewlet:

dojo.moduleUrl("com.ibm.team.dashboard.viewlets.web", "ui/internal/templates/BookmarksViewlet.html");

If you don't have a bundle to put it in, or you need it to be dynamic, you'll need to provide your own service to serve the file. There is no built-in service to serve files like this because it would be insecure - you'd be able to read any file on the server. Instead, you need to get your service to only serve this file and not allow any other files to be served. Alternatively, you can add it to your own separate Web app and serve it however you like. That's that comes to mind at the moment. Hope it helps.

Thanks,
Curt

0 votes


Permanent link
Thanks that helps.

Hi,

The simplest way is to put the file in a web bundle. That is, an OSGi bundle with the web bundle marker extension:

<extension>

Place the file in your /resources folder, which is the web root of the bundle, and use dojo.moduleUrl to get a URL to it. Here's an example from the bookmarks viewlet:

dojo.moduleUrl("com.ibm.team.dashboard.viewlets.web", "ui/internal/templates/BookmarksViewlet.html");

If you don't have a bundle to put it in, or you need it to be dynamic, you'll need to provide your own service to serve the file. There is no built-in service to serve files like this because it would be insecure - you'd be able to read any file on the server. Instead, you need to get your service to only serve this file and not allow any other files to be served. Alternatively, you can add it to your own separate Web app and serve it however you like. That's that comes to mind at the moment. Hope it helps.

Thanks,
Curt

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Dec 01 '09, 8:37 a.m.

Question was seen: 6,791 times

Last updated: Dec 01 '09, 8:37 a.m.

Confirmation Cancel Confirm