dws rs-create custom toolbox objects and templates optional

18
CREATE CUSTOM TOOLBOX OBJECTS AND TEMPLATES D em o 1 Create a Custom Toolbox O bject © 2004, Cognos Incorporated 1 This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Upload: jasbir0920

Post on 04-Apr-2015

199 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: DWS RS-Create Custom Toolbox Objects and Templates Optional

C R E A T E C U S T O M T O O L B O X O B J E C T S A N D T E M P L A T E S

Demo 1

Create a Custom Toolbox Object

© 2004, Cognos Incorporated 1This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 2: DWS RS-Create Custom Toolbox Objects and Templates Optional

C O G N O S R E P O R T N E T 1 . 1 - R E P O R T A U T H O R I N G P A R T 2

Demo 1: Create a Custom Toolbox Object

Purpose:We want to enhance our reports with a unique corporate graphic. However, this object does not currently exist in the layout toolbox. As a result, we want to add the graphic to the toolbox as a new custom object. Once we add this object, we can include it in future reports.

Task 1. Examine the existing toolbox objects in Report Studio.

1. Open your browser and in the address box, type http://<servername>/crn and then press Enter.

2. On the Log on screen, type report_author in the User ID box, and ra1234 in the Password box, and then click OK.

Cognos Connection appears.

3. In the upper right corner, click Report Studio.

Cognos Report Studio opens in a separate window and asks if you would like to create a new report or open an existing one.

4. Click Create a new report, click List, and then click OK.

5. In the Insertable Objects pane, click the Toolbox tab.

The objects on this tab can be placed anywhere in the layout. For example, we can add a text item to the page header.

6. On the Explorer bar, point to Query Explorer , and then click the Queries folder.

The only object on the Toolbox tab is Query. We can drag this object to add it to the list of available queries.

7. Double-click Query1, and then click the Toolbox tab.

The Toolbox tab now displays the objects that can be added to a query. For example, we can drag a tabular model to the Tabular Data section.

8. Drag a Tabular Model from the Insertable Objects pane to the Tabular Data section, double-click Tabular Model1, and then click the Toolbox tab.

2 © 2004, Cognos Incorporated

This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 3: DWS RS-Create Custom Toolbox Objects and Templates Optional

C R E A T E C U S T O M T O O L B O X O B J E C T S A N D T E M P L A T E S

The Toolbox tab displays the objects that can be added to a tabular model. For example, we can add a child tabular model to the Children section.

9. Point to Query Explorer, click Query1, and then click the Toolbox tab.

10. Drag a Tabular Set from the Insertable Objects pane to the Tabular Data section, and then double-click Tabular Set1.

The Toolbox tab displays the objects that can be added to a tabular set. For example, we can add a tabular model to the left and right sides of the tabular set.

Task 2. Examine Toolbox.xml and StandardComponents.xml in Notepad.

1. Open Windows Explorer, and then navigate to <Cognos ReportNet installation location>\Program Files\Cognos\crn\webcontent\pat.

2. Right-click Toolbox.xml, point to Open With, and then click Notepad.

If no menu appears when you point to Open With, you will have to click on Open With to open a dialog box and specify that you want files of this type (XML files) to open in Notepad. In the Open With dialog box, select Notepad, and then click OK. This Notepad option will now appear the next time you point to Open With.

The configuration file opens in Notepad. Notice that there is one set of <ListView> tags for each toolbox context. The toolbox objects that are visible in the Report Studio user interface are shown between each set of <ListView> tags.

Each <ListItem> tag defines a toolbox entry. Each <ListItem> tag, in turn, contains attributes that define it, such as the icon that appears on the Toolbox tab.

3. Close Toolbox.xml.

4. Right-click StandardComponents.xml, point to Open With, and then click Notepad.

The configuration file opens in Notepad. This file contains the definition of the individual toolbox objects. Each object is either an internal Report Studio function or a piece of report specification XML code.

© 2004, Cognos Incorporated 3This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 4: DWS RS-Create Custom Toolbox Objects and Templates Optional

C O G N O S R E P O R T N E T 1 . 1 - R E P O R T A U T H O R I N G P A R T 2

Each set of <toolboxControl></toolboxControl> tags defines a toolbox object. The id attribute is the name referenced in the Toolbox.xml file.

5. Close StandardComponents.xml.

4 © 2004, Cognos Incorporated

This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 5: DWS RS-Create Custom Toolbox Objects and Templates Optional

C R E A T E C U S T O M T O O L B O X O B J E C T S A N D T E M P L A T E S

Task 3. Add a new toolbox object to a blank report and view the specification.

1. In Report Studio, on the toolbar, click New , and then click No when prompted to save changes.

2. Click Blank, click OK, and then click the Toolbox tab.

11. Drag an Image to the layout.

12. Click the image, in the Properties pane, click the URL property, and then click the ellipsis.

The Image URL dialog box appears.

13. Click Browse, click cube.gif, and then click OK.

14. Click OK.

The spinning cube image is added to the report.

15. With the image still selected, from the Tools menu, click Show Specification (Selection).

The XML code referencing the image is shown. We will add this code to the StandardComponents.xml file.

16. Close the XML Specification window, and then close Report Studio without saving changes.

Task 4. Edit StandardComponents.xml to add the spinning cube graphic to the toolbox.

1. In Windows Explorer, right-click StandardComponents.xml, point to Open With, and then click Notepad.

The configuration file opens in Notepad.

2. Under the <toolboxControls> tag, edit the file so that it appears as shown below (see the highlighted portion):

© 2004, Cognos Incorporated 5This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 6: DWS RS-Create Custom Toolbox Objects and Templates Optional

C O G N O S R E P O R T N E T 1 . 1 - R E P O R T A U T H O R I N G P A R T 2

2. Save and close StandardComponents.xml.

6 © 2004, Cognos Incorporated

This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 7: DWS RS-Create Custom Toolbox Objects and Templates Optional

C R E A T E C U S T O M T O O L B O X O B J E C T S A N D T E M P L A T E S

Task 5. Edit Toolbox.xml to make the toolbox object available for use in reports.

1. In Windows Explorer, right-click Toolbox.xml, point to Open With, and then click Notepad.

The configuration file opens in Notepad.

2. Under the <ListItems> tag, edit the file so that it appears as shown below (see the highlighted portion):

3. Save and close the file.

Task 6. Restart Report Studio and view the new toolbox object.

1. Open Report Studio, and then click Create a new report.

2. Click Blank, click OK, and then click the Toolbox tab.

The spinning cube toolbox object is shown on the Toolbox tab. We can add this object to the layout of any report.

3. In the Insertable Objects pane, drag a Spinning Cube to the layout.

The object is added to the report. The result appears as shown below:

© 2004, Cognos Incorporated 7This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 8: DWS RS-Create Custom Toolbox Objects and Templates Optional

C O G N O S R E P O R T N E T 1 . 1 - R E P O R T A U T H O R I N G P A R T 2

4. Click the Spinning Cube.

Notice that, in the Properties pane, the URL property is set automatically. Because we have modified the configuration files, we do not have to manually customize the properties of each custom toolbox object.

5. Save the file as Demo 1_Create Custom Toolbox Objects and Templates in the Create Custom Toolbox Objects and Templates folder.

3. Close Report Studio, and then close Internet Explorer.

Results:We added a custom graphic object to the layout toolbox. We can now include this graphic in future reports.

8 © 2004, Cognos Incorporated

This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 9: DWS RS-Create Custom Toolbox Objects and Templates Optional

C R E A T E C U S T O M T O O L B O X O B J E C T S A N D T E M P L A T E S

Demo 2

Create a Custom Template

© 2004, Cognos Incorporated 9This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 10: DWS RS-Create Custom Toolbox Objects and Templates Optional

C O G N O S R E P O R T N E T 1 . 1 - R E P O R T A U T H O R I N G P A R T 2

Demo 2: Create a Custom Template

Purpose:Management wants all future reports to use a corporate template. However, they do not want to have to manually select this template each time they create a report. Therefore, we will create a custom template that contains and add it to the list of available templates. Once we have created this custom template, we can use it as the basis for future reports.

Task 1. Examine AppComponents.xml and templates.xml in Notepad.

1. If necessary, in Windows Explorer, navigate to <Install Location>\Program Files\Cognos\crn\webcontent\pat.

2. Right-click AppComponents.xml, point to Open With, and then click Notepad.

The configuration file opens in Notepad. Each ListItem tag specifies a label, an icon, and a template name. The label attribute refers to the label that the user sees in the New dialog box (for example, List). The icon attribute refers to the image that the user sees in the New dialog box (for example, the icon for the List template). The template attribute refers to a named entry in the templates.xml file.

3. Close AppComponents.xml, and then open templates.xml in Notepad.

Notice that the name attribute of the template element contains the same name as the template attribute of the ListItem element in the AppComponents.xml file. Each template is defined between the <report></report> tags and is a valid report specification.

4. Close templates.xml.

Task 2. Create the template report in Report Studio.

1. In Report Studio, create a new list report.

2. Select the list columns, and then press Delete .

3. On the toolbar, click Page Structure , click Page1, and then in the Properties pane, click the Background Image row.

10 © 2004, Cognos Incorporated

This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 11: DWS RS-Create Custom Toolbox Objects and Templates Optional

C R E A T E C U S T O M T O O L B O X O B J E C T S A N D T E M P L A T E S

4. Click the ellipsis.

The Background Image dialog box appears.

5. In the Position area, click Align Middle Center , in the Tiling area, click Do not tile to select it, and then click Browse.

The Image Browser dialog box appears.

6. Click cover2.jpg, click OK, and then click OK again.

7. On the toolbar, click Page Design .

The image is added to the center of the page.

8. In the Insertable Objects pane, click the Toolbox tab, and then drag a Table to the left of the text item in the header.

The Insert Table dialog box appears.

9. Click OK, and then drag a Spinning Cube to the right cell of the table.

10. Drag a Text Item to the left cell of the table, type The Great Outdoors Company, and then click OK.

11. Click the text item (not the table cell), in the Properties pane, click the Font row, and then click the ellipsis.

The Font dialog box appears.

12. In the Size box, click 14pt, in the Weight box, click Bold, and then click OK.

13. Run the report.

The result appears as shown below:

© 2004, Cognos Incorporated 11This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 12: DWS RS-Create Custom Toolbox Objects and Templates Optional

C O G N O S R E P O R T N E T 1 . 1 - R E P O R T A U T H O R I N G P A R T 2

14. Close Report Viewer.

15. From the Tools menu, click Copy Report To Clipboard, save the report as Demo 2_Create Custom Toolbox Objects and Templates, and then close Report Studio.

12 © 2004, Cognos Incorporated

This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 13: DWS RS-Create Custom Toolbox Objects and Templates Optional

C R E A T E C U S T O M T O O L B O X O B J E C T S A N D T E M P L A T E S

Task 3. Add the template XML report specification to the templates.xml file.

1. In Windows Explorer, open templates.xml in Notepad.

2. Under the <templates> tag, paste the report specification from the clipboard, and then make the following changes:

Below the <templates> tag, add a tag that reads <template name=”CorporateTemplate”>.

The xml:lang attribute is removed from the <report> tag.

The name attribute within the <modelConnection> tag is set to empty double quotes. Report Studio will use the model you select when creating a new report.

After the </report> tag at the end of the new code pasted in, add a tag that reads </template>.

The result appears as shown below:

<template name="CorporateTemplate"><report xmlns="http://developer.cognos.com/schemas/report/1/"><!--RS:1.1--><modelConnection name=""/><layoutList> <layout> <pageSet> <page name="Page1"> <pageBody> </pageBody> <pageHeader> <table> <tableRow> <tableCell> <textItem> <text>The Great Outdoors Company</text> </textItem> <style><CSS value="font-size:14pt;font-weight:bold"/></style> </tableCell> <tableCell> <image> <URL href="http://localhost/crn/samples/images/cube.gif"/> </image> </tableCell> </tableRow> <style><CSS value="border-collapse:collapse;width:100%"/></style> </table> <block class="reportTitle"> <textItem class="reportTitleText"> <text/> </textItem>

© 2004, Cognos Incorporated 13This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 14: DWS RS-Create Custom Toolbox Objects and Templates Optional

C O G N O S R E P O R T N E T 1 . 1 - R E P O R T A U T H O R I N G P A R T 2

</block> <style> <CSS value="padding-bottom:10px"/> </style> </pageHeader> <pageFooter> <table> <tableRow> <tableCell> <textItem> <expression>AsOfDate()</expression> </textItem> <style> <CSS value="vertical-align:top;text-align:left;width:25%"/> </style> </tableCell> <tableCell> <textItem> <text>- </text> </textItem> <textItem> <expression>PageNumber()</expression> </textItem> <textItem> <text> -</text> </textItem> <style> <CSS value="vertical-align:top;text-align:center;width:50%"/> </style> </tableCell> <tableCell> <textItem> <expression>AsOfTime()</expression> </textItem> <style> <CSS value="vertical-align:top;text-align:right;width:25%"/> </style> </tableCell> </tableRow> <style> <CSS value="border-collapse:collapse;width:100%"/> </style> </table> <style> <CSS value="padding-top:10px"/> </style> </pageFooter> <style> <CSS value="background-image:url(http://localhost/crn/samples/images/cover2.jpg);background-position:center center;background-repeat:no-repeat"/> </style> </page> </pageSet> </layout>

14 © 2004, Cognos Incorporated

This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 15: DWS RS-Create Custom Toolbox Objects and Templates Optional

C R E A T E C U S T O M T O O L B O X O B J E C T S A N D T E M P L A T E S

</layoutList></report></template>

3. Save and close templates.xml.

© 2004, Cognos Incorporated 15This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 16: DWS RS-Create Custom Toolbox Objects and Templates Optional

C O G N O S R E P O R T N E T 1 . 1 - R E P O R T A U T H O R I N G P A R T 2

Task 4. Edit the AppComponents.xml file to reference the template and include a cube icon.

1. In Windows Explorer, open AppComponents.xml in Notepad.

2. Under the <ListItems> tag, add a reference to the new template and a corresponding image.

The result appears as shown below (note the highlighted portion):

3. Open Windows Explorer, and then copy and paste cover2.jpg from the <Cognos ReportNet installation location>\Program Files\Cognos\crn\webcontent\samples\images directory to the <Cognos ReportNet installation location>\Program Files\Cognos\crn\webcontent\pat\images directory.

4. Save and close AppComponents.xml.

Task 5. Restart Report Studio and view the new template.

1. Open Report Studio, and then click Create a new report.

The new template is shown in the New dialog box. The result appears as shown below:

2. Click Corporate Template, and then click OK.

The new template is used as the basis for the new report.

5. Close Report Studio, and then close Internet Explorer.

Results:We created a custom template and added it to the list of

16 © 2004, Cognos Incorporated

This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.

Page 17: DWS RS-Create Custom Toolbox Objects and Templates Optional

C R E A T E C U S T O M T O O L B O X O B J E C T S A N D T E M P L A T E S

available templates. We can now use this template as the basis for future reports.

© 2004, Cognos Incorporated 17This guide contains proprietary information which is protected by copyright. No part of this document may be photocopied, reproduced, or translated into another language.