It's all about the answers!

Ask a question

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


EclipseTalk . (32736161) | asked Dec 01 '09, 8:37 a.m.
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....

2 answers



permanent link
Curtis d'Entremont (1.3k3) | answered Dec 01 '09, 11:51 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
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

permanent link
EclipseTalk . (32736161) | answered Dec 01 '09, 12:43 p.m.
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

Your answer


Register or 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.