Sunteți pe pagina 1din 45

SDK Java Tutorial

BusinessObjects 11 Windows

Designers Guide

Copyright

Copyright 2004 Business Objects. All rights reserved. If you find any problems with this documentation, please report them to Business Objects in writing at documentation@businessobjects.com.

Trademarks

Business Objects, the Business Objects logo, Crystal Reports, and Crystal Enterprise are trademarks or registered trademarks of Business Objects SA or its affiliated companies in the United States and other countries. All other names mentioned herein may be trademarks of their respective owners. Contains IBM Runtime Environment for AIX(R), Java(TM) 2 Technology Edition Runtime Modules (c) Copyright IBM Corporation 1999, 2000. All Rights Reserved. This product includes code licensed from RSA Security, Inc. Some portions licensed from IBM are available at http://oss.software.ibm.com/icu4j.

Use restrictions

This software and documentation is commercial computer software under Federal Acquisition regulations, and is provided only under the Restricted Rights of the Federal Acquisition Regulations applicable to commercial computer software provided at private expense. The use, duplication, or disclosure by the U.S. Government is subject to restrictions set forth in subdivision (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at 252.2277013. Business Objects owns the following U.S. patents, which may cover products that are offered and sold by Business Objects: 5,555,403, 6,247,008 B1, 6,578,027 B2, 6,490,593 and 6,289,352. 307-10-610-01

Patents

Part Number

Contents
Chapter 1 Introduction 3 Using the SDK Java tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Before you start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Chapter 2 Navigating through folders 5

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Navigating through folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Navigating through folders to list Web Intelligence document in the CMS . . 7 Searching for and listing universes in the CMS . . . . . . . . . . . . . . . . . . . . . . 9 Chapter 3 Viewing a Web Intelligence document 11

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Opening a Web Intelligence document . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Selecting a WebIntelligence report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Setting a pagination mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Setting the image viewing callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Displaying the report in HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Chapter 4 Detecting and refreshing prompts 19

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Detecting a prompt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Retrieving available prompts in the document . . . . . . . . . . . . . . . . . . . . . . 21 Retrieving a list of values (LOV) for prompts . . . . . . . . . . . . . . . . . . . . . . . 22 Setting values to a prompt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Chapter 5 Drilling in a document 25

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Before drilling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Activating drill mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

SDK Java Tutorial 1

Contents

Drilling on a dimension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Retrieving and populating the Drill Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Chapter 6 Saving a Web Intelligence document 31

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Saving a document in Personal and Corporate categories . . . . . . . . . . . . . 32 Chapter 7 Creating a Web Intelligence document 35

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Creating a document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Saving a new document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Index 39

2 SDK Java Tutorial

Introduction

chapte r

Introduction Using the SDK Java tutorial

Using the SDK Java tutorial


The SDK Java Tutorial is a series of code examples that show you how to do the following:

Retrieve the list of Web Intelligence documents and universe files available in the repository. Refresh Web Intelligence documents. Manage prompts Activate drill mode, specify drill on a dimension, and filter on dimension values. Save a document and set the documents properties. Create and save a new document.

Before you start


The information in this section applies to all lessons. The following objects are created at login and used throughout the tutorial:

ssio : This object is created when the user completes n a successful login. R epor tEngine : This object is created when the user completes a successful login and is stored in the users jsp session variable. IS ss ionMgr : This object is created when the user completes a e successful login and is stored in the users jsp session variable. IIn Sto : This object is created when the user completes a fo re successful login and is stored in the users jsp session variable. IE te rp n riseS e

Refer to the file login.jsp for information on these objects. Syntax specific to each tutorial is described before the code examples. For explanations of all other syntax, refer to the REBean Reference Guide. A document can be opened in 2 different ways:

Using the document ID. Using a storage token.

When a document is refreshed, a new storage token is created. This token can be used in another jsp page. Opening a document using a storage token provides better Web Intelligence server performance than using a document ID. Refer to the Customizing Web Intelligence with REBean guide for more information.

4 SDK Java Tutorial

Navigatin g throug h folders

chapte r

Navigating through folders Overview

Overview
This chapter describes how to navigate through folders in the Central Management System (CMS), and retrieve a list of documents and universes. Before running this tutorial, you must understand how to navigate through folders and categories to search for Web Intelligence documents and universes using InfoView. The code used in this tutorial to navigate and view available Web Intelligence documents can be found in docNav.jsp. The code to navigate and view available universes can be found in unvNav.jsp. The following table helps you keep track of your position in the tutorials. The current stage is highlighted. Stage Navigating through folders Viewing a Web Intelligence document Detecting and refreshing prompts Drilling in a document Saving a Web Intelligence document Creating a Web Intelligence document You learn how to... Navigate through folders to retrieve a list of Web Intelligence documents and universes. View, refresh and navigate through a Web Intelligence document. Retrieve a document that contains prompts, refresh and set the document prompts. Activate drill mode on a document, drill or filter on a dimension. Save a document. Create a new Web Intelligence document and save it.

Learnin g objective
In this chapter you will learn how to program the following:

Query the CMS to retrieve folder information. Navigate through folders Retrieve a list of Web Intelligence documents from the CMS. Retrieve a list of universes from the CMS.

6 SDK Java Tutorial

Navigating through folders Navigating through folders

Navigatin g throug h folders


All sub folders that contain Web Intelligence documents are created under the root folder (with id 0). The root folder is created when Web Intelligence is installed. To list folders stored in the CMS, you must first open the root folder, using the root folder ID; it is then possible to list sub folders and create a sub folder navigation functionality.

In this tutorial, when you open a folder, available sub folders and Web Intelligence documents are listed. The code used to browse sub folders and retrieve the documents and universes is described below.

Navigatin g throug h folder s to list Web Intelligenc e documen t in the CMS


The docNav.jsp script uses the following steps to implement the navigation functionality. 1. Retrieve the variable sID from the HTTP request parameters. The sID parameter is the unique ID for the top folder to be listed. If this parameter is null, the root folder ID (0) is used automatically. Retrieve and list the IInfoO b
ject representing the top folder.

2. 3.

Retrieve the II nfoO jec ts representing sub folders contained in the b top folder. Create links to docNav.jsp for each sub folder, pass the ID of the folder to be navigated in the sID parameter. Retrieve and list the IInfoO jects representing Web Intelligence b documents contained in the top folder.

4.

SDK Java Tutorial

Navigating through folders Navigating through folders to list Web Intelligence document in the CMS

The folder navigatio n functionality


To retrieve a list of folders on a Web Intelligence server, the CMS has to be queried. A query is run using the IIn S ore object. In these tutorials the fo t IIn fo Sto re is created when the user logs on to the Web Intelligence server, it is added to the users jsp session attributes. To retrieve folders or documents in the CMS, CI_ INFOOBJEC must be queried. The type of TS object searched for is controlled using SI_KIND in the query and the CeKind object. The following code taken from docNav. jsp shows how to retrieve the top folder in the document file structure. Example: Retrieve the top folder in a file structure.
IIn fo Sto re iI nf = (IIn oS re )s essio .g etA u f to n ttrib te("In fo Stoe ) r "; .. . String sQ uery = "SELECT SI_ID SI_NAME, SI_PARENTID FROM , + CI_INFOOBJ ECTS W H ER E ( SI_ID = " + iID + " A N D SI_KIND =\ ) '" + CeK ind.FOLD ER + "' ORDER BY SI_NAME ASC " \ ; .. . IIn Ob fo jects parentFolders = (IIn oO je ts ) iIn f b c f.q uery(sQ ue ry; )

Note: In these tutorials, the ISessionM r, IInfoS g tore , ReportE ngine and IU rInfo objects are created when the use logs in (login.jsp) and se stored in the users jsp session attributes for later use. These objects are retrieved when necessary using s ssi on e t trib te e .g tA u ( attr u ib t eName ). By querying on the SI_ID , for a specified kind (CeKind.F OLDER ) only the top or root folder is returned. To query for a list of sub folders, SI_PARENTID is used in the query. The result of this query is used to create the navigation mechanism. The following code shows the navigation functionality in docNav.jsp. Example: The navigation functionality in docNav.jsp.
sQuery = "SELECT SI_I D, SI_NAME SI_PARENTID FRO M , + CI_INFOOBJ ECTS W H ER E ( SI_PARENTID = " + iID + " A N D SI_KIND = ) \'" + CeK ind.FOLD ER + "' ORDER BY SI_NAME ASC " \ ; IInfo Objects subF olde rs = (II nfo b c O je t s) iI f query(sQ ue ); n. ry in iSiz = subF t e older s.sz ( ; i e) .. . fo (int i= ; i< ize; r 0 iS i+ ) { + IF old er iF ld = (IF old er)subFol de s e r .g t (i ; ) .. . <% <A HREF="docN av p s ID=<%=iFl d.g tID )%>" .js ? e (

8 SDK Java Tutorial

Navigating through folders Searching for and listing universes in the CMS

.. } .

<%=iFld. getID()% ></A> %>

Listin g Web Intelligenc e document s in a folder


To retrieve and work with a list of Web Intelligence documents in a folder is essentially the same as retrieving and working with a list of sub folders. What changes is the CeKind used in the query. The following code taken from docNav.jsp shows how to retrieve a list of Web Intelligence documents. Example: How to retrieve a list of Web Intelligence documents.
sQuery = "SELECT SI_ID SI_NAME, SI_PARENTID " , + "FROM CI_INFOOBJECTS WHER E ( SI_PARENTID = " + iID + ") A N D SI_KIND =\'" + CeKind .WEBI + "' ORDER BY SI_NAM E ASC \ "; IInfoO bj ec ts web iDocumen ts = (IIn O fo b je ts) iIn u c f.q er y(sQ uery ); int wSize = webi Docum ent s.sz ( ; i e) .. . fo (in j= r t 0; j< wSize; j++) { IInfoO bj ec iO t bj = (IIn oO f bject) webiDocum en .g t ts e .. . }

(j ; )

Note: Web Intelligence documents are represented by an IInfoObject in the CMS, their is no specialized object such as IFold er used for folders.

Searc hing for and listing universes in the CMS


Searching for and listing universes is done in the unvNav.jsp file. The method used to navigate through folders and list universes is the same as that used to navigate through folders and list Web Intelligence documents. The differences are:

You select objects from CI_APPOBJECTS to navigate to and list universes. To navigate and list documents, IInf oO jects are retrieved from b CI_INFOO BJECTS . The Root folder ID for Universes is 95

SDK Java Tutorial

Navigating through folders Searching for and listing universes in the CMS

The following code is taken from from unvNav. jsp shows how to retrieve the top folder of the universe file structure in the CMS. Note that although the query searches in CI_APPOBJECTS, it is still an object of SI_KIND , CeKin d.FOLDER that is being searched for. Example: Retrieve the top folder of the universe file structure in the CMS.
String sQ uery = "SELECT SI_ID SI_NAME, SI_PARENTID FROM , CI_APPOBJECTS W H ER E ( S ID \'" I_ = + iID + "' ) A N D SI_K IN D = \ \'" + CeK ind.FOLD ER + "' ORDER BY SI_NAME ASC " \ ;

To query for a list of sub folders, SI_PARENTID is used in the query in the place of SI_ID .

Listin g universe s in a folder


To retrieve and work with a list of universes in a folder is essentially the same as retrieving and working with a list of sub folders. Note that CeKin d.UNIVER SE is used in the query. The following code taken from unvNav.jsp shows how to retrieve a list of universes in a folder. Example: How to retrieve a list of universes
sQuery = "SELECT SI_I D, SI_NAME SI_PARENTID FRO M , CI_APPOBJECTS W H ER E " + "SI _PARENTID= \'" + iID + "' A N D SI_ KIND=\'" + CeKind .UNIVERSE \ + "' ORDER BY SI_NAME ASC"; \ IIn Ob fo jects webiU niv ers s = e (IIn oO je ts ) iIn f b c f.q uery(sQ ue ry; ) in wSiz = webiU t e nive rs s iz e( ; e .s ) .. . fo (int j=0; j<w r Size; j+ +) { IInfo Object iObj = (IInfoO bjec t)webiUn iv rse e s. .. . }

ge() tj;

10 SDK Java Tutorial

Viewin g a Web Intelligence document

chapte r

Viewing a Web Intelligence document Overview

Overview
This chapter describes how to view a Web Intelligence document. The following table helps you keep track of where you are in the tutorial. The current stage is highlighted. Stage Navigating through folders You learn how to... Navigate through repository folders to retrieve a list of Web Intelligence documents and universes. View, refresh and navigate through a Web Intelligence document. Retrieve a document that contains prompts, refresh and set the document prompts. Activate drill mode on a document, drill or filter on a dimension. Save a document. Create a new Web Intelligence document and save it.

Viewing a Web Intelligence document Detecting and refreshing prompts Drilling in a document Saving a Web Intelligence document Creating a Web Intelligence document

Learnin g objective
In this chapter you will learn how to program the following:

Open a Web Intelligence document. Select a report to view from the list of available reports. Set a pagination mode to display a specific page in full page mode. Set the callback script for image viewing Display the results in HTML

Before you start


Before you start this lesson, you need to know the Document ID or the storage token for the document that you will open. The document ID can be retrieved from the list of documents displayed when running the Chapter 2: Navigating through folders tutorial.

12 SDK Java Tutorial

Viewing a Web Intelligence document Opening a Web Intelligence document

Openin g a Web Intelligenc e document


The first time a document is opened in a user session, it must be opened using the Web Intelligence document ID; at this point a storage token is created. The storage token tracks the document state as it is edited by the user, and can be used later in the user session to open and reconstitute a document in a certain stage of editing . Note: Storage tokens are linked to an individual Re portEngi ne instance. It is not possible to open a document using a storage token created by a different instance of a Rep ortE ngin e. The JSP file retrieveReDoc.jsp retrieves a document ID or storage token passed to it in the request parameter docIdentifier. This Id is passed to a ReportEn gin instance which opens the document. e The following code is taken from retrieveReDoc.jsp. Example: Opening a Web Intelligence document.
if ( s rE try ! t n .e qu ls " )) a (" { //R trie ve the docum e ent using is sto e t rag to e . kn cdzDocum en = t cdzR epor tE ngine. getDocum entFrom St orageTok en ( strE try ); n .. . } // f a docum I ent id has been give n. els if (( strD ocId u als " ) e ! .eq ( ") { //Open the docum en using is ide ntfe. t t ii r cdzDocum ent= cdzR epor tE ngine. openDocu me t( I n n g r. pa e t (strD te e rs In ocId )) ; } }

SDK Java Tutorial 13

Viewing a Web Intelligence document Selecting a WebIntelligence report

Selectin g a WebIntelligenc e report


In the previous section a Web Intelligence document was opened. Web Intelligence documents may include more than one report, it is important to retrieve the report the user wishes to view. In retrieveReReport.jsp an int value pertaining to the report number the user wishes to see is retrieved from the HTTP parameters, if no value is set, the first report (index 0), is used by default. The report requested is retrieved from the list of reports available in the document. Example: Retrieving a single report from a Web Intelligence document.
S g trin in t strR ep ortIn ex = d g o nN llV etN u al ue(req e u iRe o p rt = In g r .p rs In te e a e st.g ar am etP eter(" rep rt"), o t(strR o rtIn e ); ep dx pots ) r (; iR o ep rt); "" 0 );

R epor ts cdzR ports = cdzDocum en etR e t.g e R eport cdzRep or = cd zR o t ep rts .g tIte ( e m

14 SDK Java Tutorial

Viewing a Web Intelligence document Setting a pagination mode

Settin g a paginatio n mode


Before displaying a report, the pagination mode is set to navigate through the report pages. The following code, taken from view_doc_HTML.jsp, shows how to set the pagination mode to page-by-page mode. Example: Setting the pagination mode
Strin g strPage = getNonNu llV e( re u alu q est. getParam ete a r("p g e", " ) ) "; //S t a re o e p rt to be vie wed in page-by-pa ge //P g a tionM a in ode. cdzR epor t.se a tP g inationM ode( Pagi nationM od e.Page ) ;

The code below shows how a report is opened to a specific page requested by the current user. Once the page has been set, the document has changed state (see Chapter 3: Opening a Web Intelligence document); a new storage token is retrieved so the user can navigate through report states, that is to say, undo or redo changes that have been made to the document. Example: Setting the report page and status navigation
Strin g strPage = getNonNu llV e( re u alu q est. getParam ete a r("p g e", " ) ) "; .. . PageNavi ga n cdzPageN vigation = tio a cdzR epor t.g ag eN etP avigat io (); n if (s trP ag u e.eq a ls(C_STR _PAGE_FIRST)){ cdzPageN av a ig tio n. i s( fr t ); //S t strE e ntry to so a new sto g ra e to e k n is cre ted a strE try n = "; " } .. . els if (strP g e a e .equals( C_STR_PAGE_PREVIOUS )){ cdzPageN av a ig tio n.p io us) rev (; // Remembe th t a new tok n is requ r a e ired strE try n = "; " } .. . if (strE ntry u als " ) .eq ( ") //G et st ora e to ken g strE try n = cdzDo cum ent.g etS rag eT to oken();

Note: The document cdzDocument is retrieved in retrieveReDoc.jsp, see Chapter 3: Selecting a WebIntelligence report for more information. Note: The variables C_STR_PAGE_FIRST, C_STR_PAGE_PREVIOUS etc. are declared in wistartpage.jsp.

SDK Java Tutorial 15

Viewing a Web Intelligence document Setting the image viewing callback

Settin g the image viewin g callback


The code below shows how to display a Web Intelligence report in HTML format. If a report contains charts they must be displayed as binary images. It is not possible to send binary data to client web browser using the text HTML stream. To display binary images it is necessary to create a callback script, this script sends image data to the client browser in a binary stream, this script is called from the HTML generated to view the report. The code in the following example is taken from view_image.jsp. Example: A callback script used to display images
respo nse .setC ontentTy pe("im ag e/ i "; gf ) S g trin s n ry = req ue t .g t Param trE t s e eter ("e try n " ); S g trin strIma geName = re u q es t.getParam ete r("im ag " e ); .. . Repor tEngine cdzRepor tEngine = (Repo rtE ngine )sessio n.g tA e ttri bute("R portE e ngi ne ) "; Docum entInsta nce cdzD ocument = cdzRe portE ngi ne.getD cumentFro mStorage To e (st rE try o kn n ); Image objImage = cdzD ocum ent. getIm age( strIm age Nam e); b te [] abyBin aryConte nt = ob Im y j age.get BinaryC ntent(); o Servl etO utput Stream objS rv e le tO utputS ream = t respo nse .getO utp tS u tr eam (); respo nse .setC ontentL ngth(aby BinaryC e on te t.le n n gt ) h; objS rvletO e ut putStrea m.w ( abyBinary Co te t); rite n n objS rvletO e ut putStrea m.f s ( ); lu h objS rvletO e ut putStrea m.c s ( ); lo e

The following code example from view_doc_HTML.jsp shows how to set an image callback script so charts can be displayed correctly when a report is viewed in HTML format. Example: Setting an image callback script
Image cdzIm cdzIm cdzIm Option cdzImageO ption = cdzDocume nt.g etIm ageO ptio n( ; ) ageO ptio n.setIm geC a allba ck("view _ im age.js p"; ) ageO ptio n.setIm geNameHo lder("im ge ) a a "; ageO ptio n.s tS e to rageToke nH older(" en " try );

16 SDK Java Tutorial

Viewing a Web Intelligence document Displaying the report in HTML

Displayin g the report in HTML


Before desplaying a report, the document is set to open a report in the requested format at a specific page. After an image callback has been set, a HTML view is now retrieved and sent to the client browser. Example: Retrieve and display a report page in HTML format.
HTMLView cdzHtml View = (HTMLView)cdzRep ort.g tV iew(Outp utFormatT ype.HTML ) e ; .. . <% // In o der to increa r se perfo a nce, c ll g tC n en a d rm a e ot t n parse th retu e rn ed HTML. Strin g strC ontent = cdzH tmlView. getC nten t( ; o ) // The follo in w g c d is w n oe ritte on the assu ptio m n that the head and body ta gs are not w ritt en in the com pact form (<HEAD/> and <BODY ). /> // S earch fo th HEAD tag a i bu s r e ttr te . int iP itionH os ea dA u tesB ttrib egin = strC n o te nt.in ex Of("< ea d")+ "< ead d h h ".len g th () ; int iP itionH os ea dA ttribu tesE nd = strC onte nt.index Of ( "> ", iP sitionH ad ttrib utesB o e A egi n) ; int iPos itionH ea dC ontent Begin = iP sitio nH o eadA ributesE nd + 1 tt ; int iPos itionH ea dC ontent End = s rC n n t o te t. indexOf( "</head> ", iP s tionHead ContentB eg ); oi in Strin g strH eadA trib te t u s = strC nte t.s b str g o n u in ( iP sitio nH o eadA ributesB eg , tt in iP sitio nH o eadA ributesE nd; tt ) Strin g strHeadCo nte t = strC n onte nt.s b tr us ing( iP sitio nHeadCon tentB o egi n, iP s tionHeadC ontentEn d) oi ; // S earch .. . %> fo r th B O D Y tag a i bu s e ttr te .

SDK Java Tutorial 17

Viewing a Web Intelligence document Displaying the report in HTML

18 SDK Java Tutorial

Detectin g an d refreshing promp ts

chapte r

Detecting and refreshing prompts Overview

Overview
This chapter describes how to detect prompts in a Web Intelligence document, and to retrieve and set the prompts contained within it. The following table helps you keep track of where you are in the tutorial. The current stage is highlighted. Stage Navigating through folders You learn how to... Navigate through repository folders to retrieve a list of Web Intelligence documents and universes. View, refresh and navigate through a Web Intelligence document. Retrieve a document that contains prompts, refresh and set the document prompts. Activate drill mode on a document, drill or filter on a dimension. Save a document. Create a new Web Intelligence document and save it.

Viewing a Web Intelligence document Detecting and refreshing prompts Drilling in a document Saving a Web Intelligence document Creating a Web Intelligence document

Learnin g objective
In this chapter you will learn how to program the following:

Detect prompts in a document. Retrieve a list of prompts to be filled. View and refresh the list of values (LOV). Set the prompts in a document.

Detectin g a prompt
In this tutorial, prompt detection, filling and setting is achieved by repeat passes through refresh.jsp and associated files. On the first pass, a document ID or storage token is passed to the jsp script, which opens the corresponding document using the ReportEn gin . If the current user has e the appropriate rights, prompts are detected by refreshing a document. Prompts

20 SDK Java Tutorial

Detecting and refreshing prompts Retrieving available prompts in the document

are detected by calling Docum en sta nce.getM us illP tIn tF r prompts are detected the method getProm ptsHtml in processTC_Prompts_methods.jsp is called.

om pts( ). If

The method getPromp tsHtml generates a form containing the list of prompts with their current values in HTML text boxes, and buttons permitting the user to view List Of Values (LOV) values assigned to a prompt. When prompt values are filled, the user is redirected to refresh.jsp, prompt values are passed via the parameter string. If the document contains nested prompts, getPrompts Html is called recursively until all prompts are filled.

Retrievin g availabl e prompt s in the document


Prompts are retrieved by calling cdzDocu men e Prom ts() , nested t.g t p prompts are contained in a List of Values (LOV) associated to the document. The following code shows how to retrieve both simple and nested prompts. Example: The following code is taken from viewTCDoc_promptsForm.jsp and processTC_Prompts_methods.jsp.
Prompts cdzPromp ts = n l l; u // f s Pr f I tr eix is PV, no prom pts have been fl e . il d if ( tr s P re .e fix q uals("PV ") ) { strL ovId = "; " // G the docum ents ro ot prom s. et pt cdzProm ts = cdz Docum p ent .getProm ts) p (; } els e { // G the lov id w et hose nested prom pts ne ed to be f d ille strL ovId = strLovId Lis u t.s b str g in ( strLovId Li tl s s. a tIn ex f( 'd O ' ) + 1); cdzProm ts = cdz Docum p ent .getLOV(s trL ovId, LovType. LOV_OBJECT).g e stedProm pt ( ; etN s) } .. . // t r t i eae through prom pts fo (in iProm r t pt Index = 0; iProm ptIndex < iPrompt Co n u t; iPromptI ndex++) { Prompt cdzPrompt = cdzPr om ts.g tItem r omptInde x) p e (iP ; PromptTy pe cdzPr omptType = cdzPr om pt.getT yp (); e

SDK Java Tutorial 21

Detecting and refreshing prompts Retrieving a list of values (LOV) for prompts

Retrievin g a list of values (LOV) for prompts


In the previous part of the tutorial, you retrieved the prompt. Now you will:

Retrieve the List Of Values (LOV) for the prompt Parse all values in the LOV

The user now has a list of values they can select from for the prompt. The following code is taken from processTC_Prompts_methods.jsp. Example: Retrieving LOV from a document
//R t rie e th L e v e ist Of Values (LOV) fo th pr om r e pt. Values cdzLov Values = cdzLov. getA al ue ( ; llV s) / P rs a / a e ll valu es in th e LOV. fo (int iV ueIndex = 0 r al ; iV alu eIndex < cdzL ovV alues.get Count(); iV alueI ndex++) { S g trin strL ov Valu e, strCom plet eLovValu e; / For a m / ulti column LOV. i (c dzLovVal ues.isM ltiColum s( ) f u n ) { RowVa lue objR owValue = cdzLo vV alues. getRowVal ue(iV alu eIn e ); dx strLo vV alue = objRowV alu .g tI e e tem (0); o jS ringB b t uff erCom ple teLovValu e.setL en gth0; () / D splay ea ch value /row a the c n a te a n / i s oc n tio o th f e //v l ue o ea ch colum a f n of the row. fo (int iRow ValueInd ex = 0; iRowValue Index < r objR wV o alue.g etC ount(); iRowVa lueIndex ++) .. .

} e e ls { }

strLo vV alue = cdzLovV alu es.get Value(iV alueInde x) ; strCo mpleteLo vV alue = strLovV lu ; a e

Settin g values to a prompt


Once a user has the list of values, one or more values for the prompt is selected using:
cdzPr om pt.ent erV alues (astrPro mp ele t tS c edV alues );

Once

the

user

has

entered

values,

call

the

Docume ntIn n sta

ce.setPro mp ts method to validate the user choice. You

can now retrieve the HTML document for display.

22 SDK Java Tutorial

Detecting and refreshing prompts Setting values to a prompt

Example: The following code is taken from processTC_Prompts_methods.jsp.


// S et the v es o the g en prompts alu f iv public void setP rom pts( ServletR quest obj Serv e letR eq e t, us Prompts cdzPromp ts in iPromptC ou t, S ing s , t n tr trP re ) fix { fo (in iProm r t pt Index = 0; iProm ptIndex < iPrompt Co n u t; iProm ptI ndex++) { Prompt cdzPrompt = cdzPr om ts.g p et Item r omptInde x) (iP ; Strin g strPrompt ParamName = s r efix + "." trP + S g .valueO (iProm trin f pt In ex d ); Strin [ astrPro mptSelec tedV g ] alues = ob erv etR jS l eques t.g tP r am e a eterV al ue ( s strProm tParamNa me; p ) // S lit p its v l ue ls a it in to an array i f needed if (astr Prom ptSe lectedV lues != nul) a l if (astr Pro p e lected a lu m tS V es.len g th == 1 ) astrProm ptSelect edV alues = sp a ue str Prom litV l s(a ptSel ectedV ue [ ] ; al s 0) if (astr Prom ptSe lectedV lues != nul) a l // E ter th sel ecte v n e d a lu s to the promp t. e cdzPromp t.en terV alu s s trPromptS electedV alu s e (a e );

//The

m thod set Prom e pts

(above)

is u f or a LOV as fo ows sed ll

Lov cdzL ov = cdz Docum ent .getLOV( strL v , o Id LovType. LOV_OBJECT ); // Set each nest ed prom pt Prompts cdzPromp tsNested = cdzLo v.g est etN int iPro mptNeste dCount = cdzProm ptsN ste e d setProm ts(req e st cdzP romptsNe ste , p u , d iPromptN estedCou nt s , trP re ix; f ) // The nested pr om pts ha ve been fille d cdzLov.s etN ested Prom pts( ); edPrompt s(; ) .getC oun t( ; )

SDK Java Tutorial 23

Detecting and refreshing prompts Setting values to a prompt

24 SDK Java Tutorial

Drillin g in a document

chapte r

Drilling in a document Overview

Overview
This chapter describes how to activate drill mode, then drill or filter on a dimension in a report. The following table helps keep track of where you are in the tutorial. The current stage is highlighted. Stage Navigating through folders You learn how to... Navigate through repository folders to retrieve a list of Web Intelligence documents and universes. View, refresh and navigate through a Web Intelligence document. Retrieve a document that contains prompts, refresh and set the document prompts. Activate drill mode on a document, drill or filter on a dimension. Save a document. Create a new Web Intelligence document and save it.

Viewing a Web Intelligence document Detecting and refreshing prompts Drilling in a document Saving a Web Intelligence document Creating a Web Intelligence document

Learnin g objective
In this chapter you will learn how to program the following:

Before drilling in a document Activate drill mode. Drill on a dimension. Apply a filter on a dimension value.

Before drilling
Before drilling in to a document certain operations have to be completed. The document has to be opened, contexts and prompts filled. It is also necessary to validate that the user has the right to drill in to documents. For information on opening documents and prompts see Chapter 3: Viewing a Web Intelligence document and Chapter 4: Detecting and refreshing prompts respectively.

26 SDK Java Tutorial

Drilling in a document Activating drill mode

Drill rights are part of a users Web Intelligence rights. In these tutorials the CeW ebInt ellig n e c eR ightID .DRILLMO right is validated when the user DE logs in (login.jsp) and added to the jsp session attribute "userRights". See rights_method.jsp:checkO bjectR ig ht to see how this is done. Before drilling in to a document, you must validate that the current user has the right to use the drill functionality. The following code is taken from view.jsp. Example: Validating the current users right to drill a document
// f (DRILL_MODE = f ls ), the docum I ae ent cannot //b d played e is Ha ta le sh b rig ts h = (H ashtab le)s s i on e t trib te es .g tA u ( "u serR igh ts ) "; boolean bC rill anD = ( Boolean ) ( rig ts h .g et("DRIL L_MODE") ).b o o lea nV lu a e(); if ( bCan rill) ! D response .sendRed ir c e t( "../ r o r_cantD illDocum en tm er r t.h l"

);

Activatin g drill mode


Drilling through a document is achieved using callback scripts to permit drilling and navigation through a Web Intelligence report. Drill options are used to indicate to the Rep ortEngine instance how to build drill links. For example, the names of the query string parameters and the URL to the page that will handle the drill action. The following code passes the current report to drill mode. The D rill Op n tio for the report is then set. The code is taken from retrieveDrillParams.jsp and ProcessTC_Drill.jsp respectively. Example: Enable the current report to pass in to drill mode and set the drill options.
retrieveDrillParams.jsp Dr lI f il no cd ri llIn zD fo = (D rillI nfo ) cdzR epor t.getNam ed te In rf ac (" ri llI f " ; e D no ) Dr a illB r cdzD ril lB ar = nul; l .. .

ProcessTC_Drill.jsp

//tu rn to A nalys is m ode cdzReport = cdzD ri l no .beginD il(; lI f r l) .. . cd D z rill In fo = (Dr n illI f o) cdzR epor t.getNam ed te In rf ac (" ri llI f " ; e D no ) .. . //S t th dill e e r op n tio Dr p illO t ion cdzD rillO pti on = cdz Drll no iIf .g tD e ril cdzD rill Op n tio .s etC a ckFrame( "view allB repo rt ) ";

lO tio p n(

);

SDK Java Tutorial 27

Drilling in a document Drilling on a dimension

S g strD llU trin ri rl = "re esh ? re o fr .jsp p rt= " + strR ep ortIn e ; dx cdzD illO tio n.s tC l lB r p e a ackScr ip trD t(s r illUl) r; s r illU trD rl = "viewTC Doc_ambi gu u ril lForm o sD .js p?rep ort =" + str Rep ortIn de ; x cdzD illO tio n.setA b iguousD illC a ck c t (s Dil r p m r allB S rip tr r lU rl); cdzD illO tio n.se lo ckH r p tB older (" r b d ill_ lo k c "); cdzD illO tio n.setFro mH r p older( "dill_r r f om "); cdzD illO tio n.s tDi llAction Ho e r p e r ld r("d ri l a t l_c io " n ); cdzD illO tio n.s t i r p eFl terH olde r( dill_ "r fi t r ) l e"; cdzD illO tio n.setToH old r(" r p e d rill_ " ; to ) cdzD illO tio n.s tH r p e ie rarchyHo ld r d e (" ri ll_ _ i erarch " ); to h y cdzD illO tio n.s tS r p e to rageToke nH older(" en y ); tr "

Drillin g on a dimension
When a document is displayed for drilling, the current user chooses a dimension on which to drill. When the drill action has been called, define the drill path and set the hierarchy to allow the drill action programatically. The following code is taken from processTC_Drill.jsp. Example: Drilling on a dimension
//D f in th drl e e e il pa th and execute the di l rl es l e if (strD rillA ti on n t h() != 0 c .le g ) { cd r illP zD ath = cd ri llIn o e zD f .g tD a th) rillP (; cdzD illP th r a . setB lock ID (strD ri llB c ); lo k D rill Elem ents cdzD ril lFrom lem ents = E cdzD illP th getFrom ); r a . ( Drill From Elem ent cdzD rillFrom lem E ent = (D lFromEle men ) cd zD ril t rillFro mElem ent s.a d ; d () fo r { (int iFro mIndex iFrom Index++) = 0; iF rom Index < iFromCou nt ;

cdzD illFrom lem r E ent.s etO bjectI D( astrD rillF m s[iFrom ro In de ]); x i (i From f Index < i i terC Fl ount) { cdzD illFrom lem t.se tF r r E en ilte ( astrD ri l i t l Fl ers[iF m In ex ro d ]); } i (iToC f ount != 0 ) { D rill Elem ents cdzD rill ToE en ts = lem cdzD illP th ge o r a . tT (); fo r { (int iToI ndex = 0 iT Ind ; o ex iToIn dex++) D rill ToElem ent c z ril dD < iToC ou t; n

lToEleme nt =

28 SDK Java Tutorial

Drilling in a document Retrieving and populating the Drill Bar

} } if (strD rillA ti on q al s("dow c .e u n")) { cdzD rill Path .set Actio n(D rillA tio c } cd D z rill In .ex cu D fo e te ril l( ; )

(D rillTo Elem t) cdzD en rill ToElemen ts d (); .a d cdzD rill ToElemen t.setO je ctID as Dil b ( tr r lT o s[iT In ex o d ]); // S tti ng th hierarch e e y id i mandato s ry cdzD rill ToElemen t.se ie tH r archyID as D ( tr r il lToH iera rch ies[iT oIn e ]); dx

nType.DOWN );

Retrievin g and populatin g the Drill Bar


The D lB is generated when the user passes to drill mode by clicking ril ar the drill hyperlink at the top of the report. The D rillB ar is populated when the user filters the document on a dimension value. You should refer to the Customizing Web Intelligence with REBean for more information on the DrillB r. a The following code is taken from viewTCDoc_HTML_display_toolBar.jsp. Example:
cdzD rill Bar = cd zD rillIn fo etD illBr ) .g r a( ; Dr ie ra h s illH rc ie cd ril lH zD ierarc hies = cd D z rill Info.get Dr ie ra h s () illH rc ie ; if (c zD rillH r arc ies d ie h != n ll ) u { int iD llH ri ierar chyC nt ou = cdzD rill Hie rc ra h ies.getC ou t( n ); fo (in iD r t rillH ierarchy In ex = 0;iD d rillH ierarch y Index < iD rill Hie rc ra h yC ount;i DrillH r ie archyInd ex++) { Dr ie rarchy cdzD illH rillH ierarch y = cdzD rill Hie rc ra h ie .g tI te (iD s e m ril lH ierarc hy ex Ind ); DrillD im en n sio s cdzD rill Dim ensions = cdzD rill Hie rc ra h y.g tD e ri llD ensi on ( ; im s) ou r t.pin tln ( getD rill Dim ensio nsH l(c dzD tm rillD me sio s, i n n cdzD rill Ba) ; r) }

} DrillD im en n sio s cdzD rill Dim ensio nsFree = cd D z rill Info et Fre D .g e ril lDimensi on ( ; s)

SDK Java Tutorial 29

Drilling in a document Retrieving and populating the Drill Bar

o t.p rin (g etD u tln rillD cdzD illBr ) r a) ;

im ension sHtml(cdz DrillD im ension sF re , e

Note: The function ge tD rillD mensions Htm is used to create a drop i l down combo box containing D Dim rill ensio ns that are not in the Dil lBa r. r

30 SDK Java Tutorial

Savin g a Web Intelligence document

chapte r

Saving a Web Intelligence document Overview

Overview
This chapter describes how to save a Web Intelligence document. The following table helps you keep track of where you are in the tutorial. The current stage is highlighted. Stage Navigating through folders You learn how to... Navigate through repository folders to retrieve a list of Web Intelligence documents and universes. View, refresh and navigate through a Web Intelligence document. Retrieve a document that contains prompts, refresh and set the document prompts. Activate drill mode on a document, drill or filter on a dimension. Save a document and set document properties. Create a new Web Intelligence document and save it.

Viewing a Web Intelligence document Detecting and refreshing prompts Drilling in a document Saving a Web Intelligence document Creating a Web Intelligence document

Learnin g objective
In this chapter you will learn how to program the following:

Save a Web Intelligence document. Reopen the document and set properties.

Savin g a documen t in Persona l and Corporat e categories


In the Central Management System, a document is stored in a folder and may be attached to a category or categories. In the previous tutorial Chapter 2: Navigating through folders, you were shown how to navigate through folders. The purpose of this tutorial is to:

Save the document in a corporate folder with a new name. Attach the new document to the users personal root category. Attach the new document to corporate categories

32 SDK Java Tutorial

Saving a Web Intelligence document Saving a document in Personal and Corporate categories

Modify the documents comments and keywords.

Note: This tutorial will not overwrite a document with the same name in the same folder. The following code is taken from save.jsp. Example: Save a document copy in a folder and attach specified categories.
IInfoO bj ec ts p so alC er n at eg ries = n ll; o u .. . // CeSec urity . Folder.P ERSONAL_ ID CATEGORY is t e pare t h n // fo e ld r fo ro ot p r erso nal cate go ry obje ct s Strin g sQuery = "SELECT SI_ID FROM CI_INFOOBJECTS W H ER E + (SI_N AM E l k i e '" + us erName + " ') A N D (SI_PA RENTID = " + CeSecu rity .F older.PE RSONAL_CA ID TEGORIES + " ) A N D SI_KIND = \ '" + CeKind. PERSONAL CAT + "'" \; perso al Categ ri es = (II nfo b c ts) iI f query(sQ ue y n o O je n. r ); .. . //R trie ve P e erso nal Cate gory Ve to c r objC ist atL = new Ve to ( ; c r ) ICategory iP erso nalC at = (IC atego ry)p erso nalC ateg or s e t( ) ie .g 0; In g r te e iCatID = new In eger (iP rso alC t e n at .g tID e () ); objC i st.a d atL d (i Ca ); tID .. . //R trie ve C e orpo rate c t egory a Ve to c r objC or pL atC ist = new Vect or ) (; .. . ICategory iCorpC at = (ICateg ory )ca g rie s.g t( ) te o e 0; In g r te e iCatCorp ID = new In g r ( iCorpCa t.g tID )) te e e ( ; objCatCo rp ist.a dd(iCatC orp ); L ID .. . //Save the docum en t cdzDocum ent.save As(strN me o a ,iF ld erID , (L t )o jC tL is b a ist ,(L t )o bjC or pL t) is atC is ; .. . //Open the docum en p t rev io sly saved u cdzDocum en = cd zReportE ng e.o enDocumen t(strN t in p am e, Strin .v alueO g f(i Docum ent .g tID e () ), " o o ra ", "wid ) c rp te "; //S t th p p r ties d in e e ro e ef ed by the u ser Pro e p rti es strD cProps = cdzDocu me t.g tP ro e o n e p rtie s(; ) strD ocPr op .s tP ro erty s e p ( Pro e p rti esType.K EY W O R D,strKeywo rd ) S s; strD ocPr op .s tP ro erty Pro e s e p ( p rti esType.DE SCRIPTION , strComme nt ) s; cdzDocum en e t.s tP ro e p rtie s(strD oc Pro s); p

SDK Java Tutorial 33

Saving a Web Intelligence document Saving a document in Personal and Corporate categories

34 SDK Java Tutorial

Creatin g a Web Intelligence document

chapte r

Creating a Web Intelligence document Overview

Overview
This chapter describes how to create and save a new Web Intelligence document. The following table helps you keep track of where you are in the tutorial. The current stage is highlighted. Stage Navigating through folders You learn how to... Navigate through repository folders to retrieve a list of Web Intelligence documents and universes. View, refresh and navigate through a Web Intelligence document. Retrieve a document that contains prompts, refresh and set the document prompts. Activate drill mode on a document, drill or filter on a dimension. Save a document and set document properties. Create a new Web Intelligence document and save it.

Viewing a Web Intelligence document Detecting and refreshing prompts Drilling in a document Saving a Web Intelligence document Creating a Web Intelligence document

Learnin g objective
In this chapter you will learn how to program the following:

Create a Web Intelligence document. Define parameters for the document. Save the newly created document in the CMS.

Creatin g a document
The following code example shows how to run the document viewer java applet in an HTML page. It contains a list of parameters that apply to the Web Intelligence server. In this tutuorial the java applet is used to create a new document. The following parameters are set to run the applet that are specific to document creation:

36 SDK Java Tutorial

Creating a Web Intelligence document Creating a document

CdzSession: a Repo rtEngine


ReportEn gin .c e re ateS e erv

server instance is created by calling . DocumentID: a string containing the unique ID for the target document. To create a document an empty string is passed. UniverseID: A string containing the CUID for the universe to be used to create a document. A CUID is a unique identifier for an object in the central management system (CMS). The UniverseID string is set in the following format UnivCUID=CUID value for universe. Save As: A link to the JSP page which generates a form used to gather information used to save the document.
rIn n e sta c

To create a new document, pass an empty string as the docID parameter. Before you save a document, the document does not exist in the CMS, thus, the document has no ID. When you save a new document in this tutorial, a save page appears. Enter the document title and description information. This information is sent back to the applet which in turns tells the Web Intelligence server to save the document. The server now creates an IInfoObje ct containing the document with the information that has been passed. The following code is taken from CreateWebiDoc.jsp. Example: Running the Web Intelligence applet
docum ent .w ln rite ( '<APPLET name="w ebiA pple t" + embed_size_ atr + ' t 'codebas e=" <%= req est .g etC n t Path u o tex () %>/ creating WebiDoc/ webiA ppl et" /' + 'archi ve= hin Cadenza. jar" ' "T + 'code= "com .bus inessob ec .w . tc.TCMain "> ' j ts p + '<param name=" Isa i" p value= <%= currP ath % >cd zS let" ></param >' " erv + '<param name=" Se e rv r" value= <%= reque st.g tS rverName() " e e % >"></ param >' + '<param nam e=" Protocol" value= "http"> / param < >' + '<param name=" Po rt" value= <%= reque st.g tS rv rP rt() " e e e o % >"></ param >' + '<param name=" Type" v lue="sig ned"></pa ram>' a + '<param name="We iS ss ion" b e value= <%= strW Session %>">< " I /par am>' + '<param name=" CdzS essi on" value= <%= insta nceID % >"></param >' " + '<param name=" Document ID" valu e="<%="" %>"> </par am>' + '<param name=" Un e iv rse ID" value="U nivCUID= <%=webiU niv rse e .g etCUID() %>"> </param >' + '<param name=" bRobot" valu "f alse"> /p aram e= < >' + '<param nam e=" bTraceIn LogFile" value= "f alse"> / param < >' + '<param name=" HelpR oot" value= <%= reque st.getC nte tP th () u s " o x a .s b t rin (1 g ) %>"> </param >'

SDK Java Tutorial 37

Creating a Web Intelligence document Saving a new document

+ '<p aram name="SaveA s" value ="<%= re qu est .g tC n tP ath e o tex () %> /c e tingWebi Do v ra c/sa e .jsp fo ? ld erID= <%=iF olderID % >&unvId =<%=sID % >"></param >' + '<p aram name="Lang" value ="<%= re qu s .g tA u et e ttrib t e( " n " la g ) % >"> < ar am>' /p + '</ APPLET>' ) ;

Savin g a new document


The save.jsp page included in this tutorial displays the save document user interface. Information retrieved from the interface is passed to createWebiDoc.jsp using the following javascript function:
windo w.o e e p n r .saveDoc um entC al l(v lu [0 a e lu [3 ],v lu [ 4],v lu e a e a e [5 a ],v lu e[ ] ; 6) ],v lu a e[ 1],v lu a e [2 a ],v

In createWebiDoc.jsp, the javascript function called in save.jsp is declared as follows:


fu ct io save Document Cal n n l ( t tl , d sc i e e , keywor d, fo e rID ld , corpC at pers Ca, r f reshOnOpen ) { , t e docum en p l ets 0.s aveDocume nt tt e, desc, t.a p [] ( il keyw ord, fo e rID co pC ld , r at, p rsC e at, r freshOnO pen e ) ;}

You can use the liveConnect technique to call an applet using javascript. See http://java.sun.com/products/plugin/1.3/docs/jsobject.html and http://www.sislands.com/javascript/week9/java/example.htm for more information.

38 SDK Java Tutorial

Index
C
categories 32 corporate 32 personal 32 categories example 33 CESDK navigating 7 searching 7 CMS query objects 8 searching 7

L
LOV prompt 22

N
navigating 7

P
pagination example 15 mode 15 prompt detecting 20 LOV 22 retrieving 22 retrieving example 22 retrieving 21 retrieving example 21 setting 22 setting example 23 values 22

D
document example opening 13 opening 13 saving 32 searching 7 documents listing 9 drill 27 activating 27 activating example 27 dimension 28 dimension example 28

R
report 14 display html 17 displaying 17 example 14 HTML 17 opening 14, 14

F
folders navigation 7, 8 retrieve current 8 retrieve subfolders 8

S
saving 33 searching 7

I
images 16 example callback 16 viewing 16

U
universe

DRAFT

<title of your book>

39

Index

searching 9

W
WebIntelligence opening 13 searching 7

40 <Business Objects JAVA SDK Tutorial>

DRAFT

S-ar putea să vă placă și