Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

How to create dashboard viewlets in Rational Team Concert

Call REST services and other Dojo widgets as you need them

Geetu Garg (geetu.garg@in.ibm.com), Senior Application Developer, IBM
Photo of Geetu Garg
Geetu Garg is a senior application developer for Java technology who joined IBM in 2005. She has been involved in extending and enhancing Rational Team Concert collaborative software development tools tool on the Jazz technology platform for IBM requirements.

Summary:  This article explains how to create a dashboard on the Jazz technology platform and add viewlets. It also describes how to customize a viewlet programmatically by using JavaScript and calling REST services and Dojo widgets that you want to include in the viewlet.

Date:  13 Apr 2010
Level:  Intermediate PDF:  A4 and Letter (118KB | 12 pages)Get Adobe® Reader®
Also available in:   Chinese  Korean

Activity:  16812 views
Comments:  

You can create dashboards by using the Web user interface (UI) of IBM® Rational Team Concert™. You define a new dashboard and configure it by choosing which viewlets you want to include from the Viewlet Selector, or you can create a dashboard from a template as this article explains. Each viewlet shows information about some aspect of a project, team, work items, builds, and so forth. Viewlets are defined in code and contributed by extension points. This article focuses on creating personal dashboards with custom viewlets. It describes how to customize a viewlet programmatically by using JavaScript and calling REST services and Dojo widgets that you might want to include in the viewlet.

Create a personal dashboard and add custom viewlets

  1. Navigate to the Web UI for Rational Team Concert on Jazz (https://localhost:9443/jazz/web), select the Dashboard page, and click Create Dashboard on that page (See Figure 1).

Figure 1. The Create Dashboard button
Screen segment shows the button
  1. Make sure that you have permissions set for Create and Save Dashboards in the Project Configuration Permissions (Figure 2).

Figure 2. Configure permissions
Configuration and Permissions views side-by-side
  1. Click the Add Viewlet button on the extreme right of the Dashboards page.

Note:
If the dashboard appears but doesn't have an Add Viewlet link, it means that the user that you are logged in as doesn't have permission to modify the dashboard. You will need to launch the Eclipse Rich Client Platform (RCP) client, log in to your local repository as an admin, and update the permissions in the process specification tab of the project area editor.


Figure 3. The Add Viewlet icon
Top of the Administrator's dashboard view
  1. Choose the viewlet that you want to add to your dashboard and click Add Viewlet (Figure 4).
  2. Then close this dialog window.

Figure 4. Select and then add the viewlets
'Application Factory Project Management' selected

The viewlet will now be on your dashboard.


Alternative: Create the viewlet programmatically

These steps outline what is required to declare a plug-in as a Web bundle. Upon completion, the plug-in will not actually contribute anything to the Web UI, but it will place resources on the server to ensure that it is working correctly.

Create a plug-in to hold the viewlet

Configure plug-in project

  1. Select File > New > Project > Plug-in Development > Plug-in Project, and click Next.
  2. Uncheck the Create a Java Project option.
  3. Enter a name that ends in .web for the project (for example: com.example.web).
  4. Click Next and then click Finish.
  5. Switch to the Dependencies tab of the Plug-in Manifest Editor for your new plug-in.
  6. Click the Add button, select the net.jazz.ajax plug-in, and click OK.
  7. Switch to the Extensions tab.
  8. Press the Add button, select the net.jazz.ajax.webBundles extension point, and press Finish.
  9. Click the Save button on the toolbar or press Ctrl + S to save the changes.

Register the viewlet

The viewlet needs to be registered in the plugin.xml file as an extension point, as Listing 1 shows.


Listing 1. Extension point for the plugin.xml file
<!-- Web bundle marker -->
<extension point="net.jazz.ajax.webBundles">
    <prerequisites>
        <requiredWebBundle id="net.jazz.ajax"/>
        <requiredWebBundle id="net.jazz.web.ui"/>
    </prerequisites>
</extension>

<!-- Viewlets and categories -->
    <extension point="com.ibm.team.dashboard.common.viewlets">
        <category id="com.ibm.afworkpktmgmt.category" name="AFWorkPacketMgmtViewlet">
        </category>
        
        <Viewlet icon="graphics/icons/icon.gif" 
        id="com.ibm.afworkpktmgmt.viewlet" refresh-interval="15" 
        title="Application Factory Work Packet Management" 
        widget="com.ibm.af.workpktmngmt.viewlet.web.ui.internal.AFWorkPacketMgmtViewlet">
        </viewlet>
        
        <viewlet-entry        category="com.ibm.afworkpktmgmt.category"
        title="Application Factory Work Packet Management"
        preview="graphics/images/preview-AFWorkPktMngmtViewlet.PNG"
        viewlet-id="com.ibm.afworkpktmgmt.viewlet">
        <description>
            This is the description of the AFWorkPacketMgmtViewlet entry 
            that appears in the viewlet chooser.
        </description>
        </viewlet-entry>

    </extension>

The Web bundle marker extension simply declares that this bundle has Web UI code. The Web UI code requires this in order to know which bundles to scan for code, the CSS, and so forth.

category: This is for the AFWorkPacketMgmtViewlet" root node in the Viewlet Selector (shown in Figure 4). The name is the label and the id is a language-neutral identifier that can be used to refer to this category.

viewlet: his is the viewlet definition (implementation). This is not the entry that shows up in the chooser (that's the viewlet-entry); it is the back-end code associated with the entry. The widget attribute is the name of the viewlet class in JavaScript that implements the viewlet logic. It's just like a fully qualified Java™ class name, except that it's a custom Dojo widget.

viewlet-entry: This is the entry that appears in the chooser. The viewlet ID points to the viewlet element, and the category points to the category element to link everything together. The preview and description are presented inside the Viewlet Selector.

Viewlet implementation (JavaScript)

Previously, in the plugin.xml file, the viewlet implementation pointed to this class:

com.ibm.af.workpktmngmt.viewlet.web.ui.internal.AFWorkPacketMgmtViewlet

This corresponds to the file in this path:

com.ibm.af.workpktmngmt.viewlet.web /resources/ui/internal/ AFWorkPacketMgmtViewlet.js

The resources segment is a special folder in Web bundles that contains all of the Web resources, and the internal segment is used to signal internal (non-API) code so that other developers don't create any dependencies on this code.

The package structure for this plug-in would be somewhat like the one in Figure 5.


Figure 5. Package structure
Tree view

The JavaScript (.js) file begins with the dojo.provide statement to make this Dojo accessible:

dojo.provide("com.ibm.af.workpktmngmt.viewlet.web.ui.internal.AFWorkPacketMgmtViewlet");

To be able to extend the base class viewlet (this is analogous to an import statement in Java):

dojo.require("com.ibm.team.dashboard.web.ui.Viewlet");

To allow you to use short form names, as in Java™ technology, you declare an alias, which is a local variable that points to the full class name wrapped in a function (see Listing 2). This is to ensure that this local variable doesn't conflict with anything in the global namespace.


Listing 2. Viewlet declaration
function() {
var Viewlet = com.ibm.team.dashboard.web.ui.Viewlet;
dojo.declare("com.ibm.af.workpktmngmt.viewlet.web.ui.internal.AFWorkPacketMgmtViewlet",
        Viewlet, {
constructor: function() {

                        this._widget = null;
    
    
            },

templatePath: dojo.moduleUrl("com.ibm.af.workpktmngmt.viewlet.web", 
"ui/internal/templates/AFWorkPacketMgmtViewlet.html"),
//functions related to events on the viewlet
});

})();

The dojo.declare statement declares the widget with the second parameter as Viewlet, the alias of the base class that it extends.

The template path is the path to the HTML file for this template-based Dojo widget which contains HTML code to be rendered on this viewlet.

Template file

The HTML template file serves as the design template for the presentation of the widget (in this case, your dashboard viewlet), as Listing 3 shows.


Listing 3. Viewlet template file
<div class="com-ibm-af-workpktmngmt-viewlet-web-ui-internal-AFWorkPacketMgmtViewlet">
<b> Work Packet Templating </b><br>
<a href=#  dojoAttachEvent="onclick: _exportAFOnClick">Export Factory WorkItems</a><br>
</div>

This could be a sample template that renders a link called "Export Factory WorkItems. This is the fully qualified CSS class name to scope it to only this viewlet:

com-ibm-af-workpktmngmt-viewlet-web-ui-internal-AFWorkPacketMgmtViewlet 

We have a special link that runs the script rather than linking to an HREF tag: (href=#).

The dojoAttachEvent is the Dojo Toolkit way of connecting the event and the handler. When it is clicked, it will call the given function on the appropriate viewlet instance with a properly scoped value.

The CSS file is also scoped to this viewlet by writing the fully qualified class name for each style.

The CSS is picked up as the CSS optimizer scans all Web bundles for any .css files and includes it in the styles that are sent to the browser. Here is an example of the contents of a .css file:

.com-example-star-widget .star {
    width:auto;
    height: 20px;
        position: relative;
        left: 4px;
}

The template file can also contain Dojo attach points to have a link to the JavaScript file for Dojo components to be added. This template would then truly serve as a design template, just to align all of your Dojo components. Listing 4 shows an example.


Listing 4. Viewlet template file elements with dojoAttachPoint
<div>

<table cellspacing="12">

    <tr>
        <td>
    
            <B>Project Area :</B>    
    
    </td>
    
    <td dojoAttachPoint='projectAreaListBox'>
            </td>
    </tr>
</table>
</div>

The JavaScript (.js) file would add widgets to the projectAreaListBox dojoAttachPoint as Listing 5 shows.


Listing 5. Linking dojoAttachPoint in the viewlet JavaScript file
this.projectAreaButton = new dijit.form.Button({

         id:  projectAreaButton",
        
            label: "Project",
            
         });
   
this.projectAreaListBox.appendChild(this.projectAreaButton.domNode);

Calling REST services from the viewlet

The viewlet might have components or might need to call REST services (see Listing 6) to get data either by sending certain parameters or by submitting a form.


Listing 6. Calling REST service with parameters
var handler = {
                _success: function(done){
                    
                    console.log("success  + done);
                    }
                   
               
                },

                _failure: function(done){
                    console.log("failure  + done);

                    
                }

            };
            
     var srh = new ServiceResponseHandler(handler, "_success", "_failure");

         var reqParms= {
        
            param1: value1,
            param2: value2,
            };

        var serviceRequest = 
        new ServiceRequest("com.ibm.af.template.common.IAFTemplateService", 
        "postImportWorkItems",reqParms );

TeamServerClient.invokeService(serviceRequest, srh);

Where com.ibm.af.template.common.IAFTemplateService is the interface for the service, postImportWorkItems is the method to be called with the mentioned Request Parameters.

These variables should be declared in the ,js file (see Listing 7).


Listing 7. Variable declaration in the .js file
var ServiceRequest = com.ibm.team.repository.web.transport.ServiceRequest;
var ServiceResponseHandler = com.ibm.team.repository.web.transport.ServiceResponseHandler;
var TeamServerClient = com.ibm.team.repository.web.transport.TeamServerClient;

These variables should also be declared as required by the Dojo Toolkit in a .js file as Listing 8 shows.


Listing 8. Variables declared in the JavaScript file
dojo.require("com.ibm.team.repository.web.transport.ServiceRequest");
dojo.require("com.ibm.team.repository.web.transport.ServiceResponseHandler");
dojo.require("com.ibm.team.repository.web.transport.TeamServerClient");

Calling the service and requesting parameters

You might want to call a service by sending the whole input form as one of the parameters so that the service can pick up the inputs filled in the form by the user. Listing 9 is an example of how you can do that.


Listing 9. Calling a service by sending a form
var service_uri = net.jazz.ajax._contextRoot+/service/
com.ibm.af.util.common.IAFFileUploadService?param1=+value1;


    var responseVar=;
    
    
    dojo.io.iframe.send({
        form: form1,
        url: service_uri,
        handleAs: "json",    
        enctype: "multipart/form-data",
        method:"post",
            
    load: function(response, ioArgs) {
            
            },

        error: function(response, ioArgs){
        
            },
        timeout: 120000  // in milli seconds	              
        });

Calling other Dojo widgets from the viewlet

If you want to call another widget or show another widget in a dialog window, use the code in Listing 10.


Listing 10. Calling other Dojo widgets
this._dialog = new dijit.Dialog({
                id: "detailDialog",              
                style: "height:500px;width:500px;overflow:hidden",
                                        
            
            });
        
    this._ dialog.domNode.appendChild(new Widget().domNode);

    dijit.byId('detailDialog').show();


Resources

Learn

Get products and technologies

Discuss

About the author

Photo of Geetu Garg

Geetu Garg is a senior application developer for Java technology who joined IBM in 2005. She has been involved in extending and enhancing Rational Team Concert collaborative software development tools tool on the Jazz technology platform for IBM requirements.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=481321
ArticleTitle=How to create dashboard viewlets in Rational Team Concert
publish-date=04132010
author1-email=geetu.garg@in.ibm.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.

Special offers