It's all about the answers!

Ask a question

Embedding Dashboard Problem


Hao Chen (73194) | asked Feb 15 '11, 9:42 p.m.
Hi,
We want to embedding custom Dashboard in our application and develop some viewlets to show some chart.
We follow the document : https://jazz.net/wiki/bin/view/Main/EmbeddingDashboards
Our enviorment: A server run Jazz Foundation Server 3.0.0.
Our application Run on a Jetty Server as eclipse plug-in.
Our Target Platform base on Foundation SDK 3.0.1&Eclipse(We update to the latest one : 20110215-2034 dev-offering
We try to write a service which call JTS dashboard service like this:
@Override

public void doGet(HttpRequest request, HttpResponse response)
throws IOException {

IDiscoveryHelper helper = Discovery.getHelperForAppGroup();
IServiceResource jfsDashboardServiceDescription = helper.getService(
DiscoveryConstants.SERVICE_TYPE_DASHBOARDS,
new DiscoveryRequestParams(ThreadContext.get()));
String dashboardServiceUrl = jfsDashboardServiceDescription
.getProperty(DiscoveryConstants.SERVICE_PROPERTY_SERVICE)
.getResourceURI();
System.out.println(dashboardServiceUrl);
HttpClient httpClient = (HttpClient) request.getParams().getParameter(Constants.HTTP_CLIENT_PARAM_NAME);
HttpGet get = new HttpGet(dashboardServiceUrl+"/4");
HttpRequestUtil.copyCacheAndConditionalRequestHeaders(request, get);
HttpResponse jfsResponse = httpClient.execute(get, ThreadContext.get());
if (jfsResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
ErrorUtils.handleErrorResponse(jfsResponse, null);
}

// Return the response to the client
response.setStatusLine(jfsResponse.getStatusLine());
if (jfsResponse.getEntity() != null) {
response.setEntity(jfsResponse.getEntity());
}

}

"/4" is the URL when we access the JFS Server Dashboard by "/jts/web/dashboard/4"
We run this service, it returns a html page with Loading in it.

<DOCTYPE>


<Licensed>

<html>

<head>
<meta>
<meta>
<title></title>

<link>
<link>

<style>
#net-jazz-ajax-NoScriptMessage {
width: 100%;
color: #D0D0D0;
font-size: 2em;
text-align: center;
position: absolute;
top: 1%;
z-index: 999;
}
</style>

</head>

<body>
<noscript><div>Javascript is either disabled or not available in your Browser</div></noscript>
<div>Loading...</div>
<div></div>

<script>
djConfig = {
isDebug: false,
usePlainJson: true,
baseUrl: "/jts/web/dojo/",
locale: "zh-cn",
localizationComplete: true
};
/*null*/
net = {jazz: {ajax: {}}};
net.jazz.ajax._contextRoot = "/jts";
net.jazz.ajax._webuiPrefix = "/web/";
</script>

<script></script>


<script>
/* <CDATA> */
</script>

<script>
/* <CDATA> */
</script>
</body>
</html>

How can I embed it in our application?

And I try the way in the bottom of the above document:
I added a dijit widget:
var myDashboard = new Dashboard({

url: "https://example.com/jts/dashboards/123" <== change to my url
});
myDiv.appendChild(myDashboard.domNode);


I found that it call our application web service as below:
/service/com.ibm.team.dashboard.common.internal.service.IDashboardRestService/initData

But we didn't register the restService, I thought maybe the service is run on our JFS Server, how could I config it?

Is there any other information can help me to solve it?

Thanks. :D

9 answers



permanent link
Curtis d'Entremont (1.3k3) | answered Feb 16 '11, 11:14 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
This topic applies to 3.0.1 only (it is subtly mentioned at the top). It is also brand new so you'd need a foundation build and JTS from >=2011/02/15.

As for the initData call, you're right, it's supposed to call the JTS. I missed a section in the wiki topic - you need to add two elements to your rootservices document:

<jd:viewletServiceRoot rdf:resource="https://example.com/jts"/>
<jd:viewletWebUIRoot rdf:resource="https://example.com/yourapp"/>

The service root should be the JTS and the Web UI root your app.

I will add it to the wiki topic shortly. This is a temporary measure that I hope to remove in the future.

As for the service returning HTML, it will return HTML if the Accept header requests it. If you want to get the RDF of the resource, you should add an Accept header with application/rdf+xml.

permanent link
Hao Chen (73194) | answered Feb 17 '11, 2:00 a.m.
Thanks for your instructions. Our target platform is update to 2011/02/15. But our JFS is still 3.0.0. Will it take any problem?

We add the two elements in our application's rootservices, but the dijit widget still try to GET the application's service as /service/com.ibm.team.dashboard.common.internal.service.IDashboardRestService/initData and return 403 code.

And for dashboard Service, when I add Accept Header with application/rdf+xml, it still return a loading page, how could I combine the service and the dashboard widget in our application?

permanent link
Curtis d'Entremont (1.3k3) | answered Feb 17 '11, 10:26 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Unfortunately the Dashboard widget won't work as described in the wiki topics in foundation 3.0, as I had to add code in 3.0.1 to support this.

As for the problem with returning a loading page, I should clarify, if HTML is acceptable as per any of the Accept headers, it will return HTML (the loading page you're seeing), otherwise if application/rdf+xml is acceptable, it will return that.

permanent link
Hao Chen (73194) | answered Feb 17 '11, 5:24 p.m.
Unfortunately the Dashboard widget won't work as described in the wiki topics in foundation 3.0, as I had to add code in 3.0.1 to support this.

As for the problem with returning a loading page, I should clarify, if HTML is acceptable as per any of the Accept headers, it will return HTML (the loading page you're seeing), otherwise if application/rdf+xml is acceptable, it will return that.


Hi,
I see you added url parameter in the dashboard.js.^_^
So is there any solution that I can only use the Dashboard Service API, and generate My Dashboard Page? I don't know how to deal the response. Or I had better wait for another build? :lol:

permanent link
Curtis d'Entremont (1.3k3) | answered Feb 17 '11, 5:38 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
It is probably more feasible to wait for another build, rather than trying to hack the 3.0 Dashboard javascript code. 3.0.1 M13 is scheduled to be declared on Feb 25th, and should be published to jazz.net shortly after that.

permanent link
Hao Chen (73194) | answered Feb 25 '11, 4:21 a.m.
It is probably more feasible to wait for another build, rather than trying to hack the 3.0 Dashboard javascript code. 3.0.1 M13 is scheduled to be declared on Feb 25th, and should be published to jazz.net shortly after that.


Hi, curtispd,
Is that widget work now ? Our team want to develop with viewlet in our Application before March,15th, is that possible?
Where can I get the latest JFS SDK?

Thanks

permanent link
Curtis d'Entremont (1.3k3) | answered Feb 25 '11, 10:16 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Yes, it should be possible with M13 once it's declared and published to jazz.net. There are still some approvals pending, and the self-hosting deployment is on monday evening, so it should be available for download soon.

permanent link
Hao Chen (73194) | answered Feb 27 '11, 11:50 p.m.
Yes, it should be possible with M13 once it's declared and published to jazz.net. There are still some approvals pending, and the self-hosting deployment is on monday evening, so it should be available for download soon.



Hi, curtispd,
Sorry to bother you again. The dashboard is still not work.LOL

I use the build 20110224-0215 as our target-platform, it still not work.
I debug the code found such things:
Dashboard.js ==>
com.ibm.team.dashboard.web.ui.internal.DashboardInitializationData ==>
DashboardClient.getInitData(srh); ==>DashboardClient.js
==>


/*

96 * Fetches the dashboard initialization data.
97 */
98 /* InitDataDTO */ getInitData: function(/* ServiceResponseHandler */ srh, /* ServiceTracker */ tracker) {
99 this._invoke("getInitData", {}, false, null, srh, tracker);
100 }

the parameter repositoryRoot is always null?
becasue of this, the net.jazz.ajax._dataServerRoot is null and when it post request ,it calls

function getServicePrefix() {
var dataServerRoot = dojo.getObject("net.jazz.ajax._dataServerRoot");
return dataServerRoot ? dataServerRoot + "/service/" : dojo.baseUrl + "../../service/";
}

so it call the service as our application contextroot in the front of url.
I guess it should be our config problem, but I don't know how to solve it.
Is that related the step:

<jd:viewletServiceRoot rdf:resource="https://example.com/jts"/>
<jd:viewletWebUIRoot rdf:resource="https://example.com/yourapp"/>

I added it in our application rootService feed back. And the first is remote Server, the second is the local one.

Just for test, I add a line in my code: net.jazz.ajax._dataServerRoot= "https://remote-jfs-server :9443/jts" before we add the widget.

The dashboard is unnormally showed.
It can show the layout of dashboard. Everything is ok but the viewlet is only has its winodw, the inner info is still loading. FYI, I add com.ibm.team.dashboard.viewlets.web bundle in our lanuch file. But the category of viewlets is empty.


Thanks a lot :P

permanent link
Curtis d'Entremont (1.3k3) | answered Feb 28 '11, 5:25 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
Hi,

The viewletServiceRoot is currently used to populate the net.jazz.ajax._dataServerRoot. This is to support legacy repository-type services on fronting applications that don't have repository installed - it sends the requests to the JTS instead.

So the dashboard service requests should be going to whatever you set the viewletServiceRoot to in your fronting app's rootservices URL. A restart may be needed to make this happen as I think the values can be cached in some cases.

Also, just to clarify, you mentioned a remote JTS - this is for your application's JTS, not the JTS of some remote viewlet, for example. If you're running a server in standalone mode, i.e. the fronting app and JTS in one launch, then you would point the viewletServiceRoot to your local server.

I noticed in your example "https://remote-jfs-server :9443/jts" is that there's an invalid space before the ":9443" part. This would result in an invalid URL which would probably cause bad things to happen.

Let me know if this helps.

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.