wdk tutorial 42

60
Documentum Web Dev elopment Kit Tutorial Version 4.2 April 2001 DOC3-WDKTUT-0401 * D O C 3 - W D K T U T - 0 4 0 1 *  

Upload: guru2228

Post on 12-Jul-2015

43 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 1/60

Documentum Web

Development KitTutorial

Version 4.2

April 2001

DOC3-WDKTUT-0401

* D O C 3 - W D K T U T - 0 4 0 1 *  

Page 2: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 2/60

Copyright © 2000, 2001Documentum, Inc.6801 Koll Center ParkwayPleasanton, CA 94566All Rights Reserved.

Documentum®, Documentum 4i™, Docbase™, Documentum eContent

Server™, Documentum Server

®

, Documentum Desktop Client™,Documentum Intranet Client™, Documentum WebPublisher™, DocumentumftpIntegrator™, Documentum RightSite®, Documentum Administrator™,Documentum Developer Studio™, Documentum Web Development Kit™,Documentum Web Gear™, Documentum WebCache™, DocumentumContentCaster™, AutoRender Pro™, Documentum iTeam™, DocumentumReporting Gateway™, Documentum Content Personalization Services™,Documentum Site Delivery Services™, Documentum Content Authentication

Services™, Documentum Dynamic Content Assembler™, DocumentumDocControl Manager™, Documentum Corrective Action Manager™,Documentum eConnector™ for BEA WebLogic® (BEA and WebLogic areregistered trademarks of BEA Systems), Documentum eConnector™ for JDBC,Documentum eConnector™ for CAD, Documentum eConnector™ for SAP™ (SAP is a trademark of SAP AG), Documentum eConnector™ for Lotus Notes® (Lotus Notes is a registered trademark of Lotus Development Corporation),DocInput™, Documentum DocViewer™, GMPharma™, Virtual Document

Manager™, Docbasic®

, Documentum WorkSpace®

, DocumentumSmartSpace®, and Documentum ViewSpace® are trademarks or registeredtrademarks of Documentum, Inc. in the United States and throughout theworld. All other company and product names are used for identificationpurposes only and may be trademarks of their respective owners.

Page 3: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 3/60

Documentum Web Development Kit Tutorial iii

Preface

1 What is the Web Development Kit?What WDK Is and What it Can Do . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1Compliance With Java Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2Dependencies on Other Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3

Fitting the Pieces Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6

2 JavaServer Pages in the WDKAnatomy of a Typical WDK Server Page . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1HTML Generated by JSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3Handling Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3

3 Developing an ApplicationPrepare Your Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1Plan the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2Create the Application Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3Locate the Tutorial Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5Create a Page. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5Add the Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7Add Event Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10

Enable Actions on Docbase Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12Extra Investigation: Use Cascading Style Sheets to Customize the Look of Your

Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13

4 Customizing WDK ComponentsModify a Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1

Before you begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1Remove the menu items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2

Extra investigation: Add a menu item. . . . . . . . . . . . . . . . . . . . . . . . . 4-3Add a Column to a View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3

Before you begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3Add the column to the view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4

5 Displaying Properties of a Custom Object TypeDisplay Custom Properties of a Custom Object Type . . . . . . . . . . . . . . . . . . . 5-1

Before you begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2

Display the custom properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2

C O N T E N T S

Page 4: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 4/60

iv Documentum Web Development Kit Tutorial

Extra Investigation: Searching for Properties of a Custom Object Type . . . . . . . . 5-3

A Solution CodewdkSkeletonPage.jsp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2wdkTutorial0_finished.jsp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3wdkTutorial1_finished.jsp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-4toolbarTutorial_finished.jsp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-5wdkTutorial2_finished.jsp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-7wdkTutorial3_finished.jsp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-9

folderContents.jsp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-11

Page 5: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 5/60

Documentum Web Development Kit Tutorial v

P R E F A C E

Purpose of the Manual

This manual provides an introduction to the basic features of theDocumentum Web Development Kit (WDK) using both conceptualinformation and hands-on examples.

For detailed WDK information, including installation instructions,information on developing and configuring web applications with the WDK,and reference material, see:

s Installation and Release Notes

s Online Help

s API Documentation (Javadoc)

All of these documents are available in the docs directory that resides in theWDK installation directory.

Intended Audience

This manual is designed for web developers and designers who will use theWDK to add Documentum functionality to web applications. It assumes thatyou are familiar with JavaServer Pages, web applications, JavaScript, andHTML. Numerous books that cover these topics are available commercially,and you can also consult the following documents at http://java.sun.com:

s  Java Servlet Specification, version 2.2

s

 JavaServer Pages Specification, version 1.1

Organization of the Manual

The following table describes the contents of the chapters and appendixes ofthis book.

Page 6: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 6/60

vi Documentum Web Development Kit Tutorial

Conventions

This manual uses the following conventions:

Chapter Contents

Chapter 1, What is the WebDevelopment Kit?

Describes the contents of the WDK and how it workswith your HTTP server and application server.

Chapter 2, JavaServer Pagesin the WDK

Describes how JavaServer Pages are used to driveWDK-based web applications.

Chapter 3, Developing an

Application

Contains step-by-step examples of how to build a

simple web application based on the WDK.

Chapter 4, Customizing WDKComponents

Contains step-by-step examples of how to customizea menu and a view.

Chapter 5, DisplayingProperties of a Custom ObjectType

Contains step-by-step examples of how to display theproperties of a custom object type in the propertiespage of WDK.

Appendix A, Solution Code Lists the solutions for each tutorial exercise.

Convention Description

➤ Represents a pop-up or pull-down menu.

Indicates the introduction to a procedure.

italics Represents a variable name for which you must provide avalue, or a defined term.

typewriter Represents code samples, user input, and computer output.

[] square brackets Indicates an optional argument.

{} braces (curly brackets)

Indicates an optional argument that can be repeated more thanonce.

Page 7: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 7/60

Documentum Web Development Kit Tutorial vii

Using Links in PDF Files

If you are reading this document as a Portable Display Format (PDF) file,cross-references and page numbers in the index are clickable blue hypertextlinks. Table of contents page numbers are also clickable links, but they appearin black.

Each server book contains many clickable cross-references to the other server

 books. Cross-references to manuals other than the one you are reading onlywork if the PDF files are all in the same directory and have the same filenames that they have on the server release CD.

➤ To follow a link:

1. Move the pointer over a linked area.

The pointer changes to a pointing finger when positioned over a link. The

finger pointer displays a W when moved over a Weblink.

2. Click to follow the link.

Note: To follow Web links, your Weblink preferences must specify a Web browser. See Setting Weblink preferences in your Adobe Acrobat Help formore information.

Bug Lists and Documentation Online

Customers with a software support agreement can read our productdocumentation and, after commercial release of a product, view lists of fixed

 bugs on our Technical Support web pages. To view this information you mustapply for access to the Technical Support area.

Applying for Access

➤ To apply for access:

1. In your browser, openhttp://www.documentum.com/

2. Choose the Customer Service ➤ Technical Support link.

Page 8: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 8/60

viii Documentum Web Development Kit Tutorial

3. Click the Request Access link.

4. Complete the form and submit it.

Documentum will respond to your request within two business days.

Fixed Bugs List

Within two weeks from the date of this release, Documentum places a list of

fixed bugs in the Technical Support area of documentum.com. The listincludes all customer-related bugs that the current release corrects. Forinformation about obtaining access to the Technical Support area of the Website, refer to “Applying for Access” on page vii. You must have Adobe AcrobatReader or Acrobat Exchange installed to view the lists of fixed bugs.

➤ To view the list of fixed bugs:

1. In your browser, openhttp://www.documentum.com/

2. Choose the Customer Service ➤ Support Logon link.

3. Log on to the Technical Support site.

4. In the Troubleshooting section, click Fixed Bugs Lists.

5. Click the product name link for a product’s bug list.

Product Documentation

Customers with a software support agreement can read our productdocumentation at documentum.com. To view the documentation, you musthave a user name and password, and Adobe Acrobat Exchange or AcrobatReader installed. To obtain a user name and password, refer to “Applying for

Access” on page vii.”➤ To view a document:

1. In your browser, openhttp://www.documentum.com/

2. Choose the Customer Service ➤ Support Logon link.

3. Log on to the Technical Support site.

4. In the left pane, click Documentation.

Page 9: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 9/60

Documentum Web Development Kit Tutorial ix

5. To list documents, select a sorting method in the List Documentation By field,

and click List.

6. Click the name of the document you wish to view.

Purchasing Bound Paper Manuals

Our product documentation is available for purchase as bound papermanuals. To place an order, call the Documentation Order Line at (925) 600-6666. You can pay with a purchase order, check, or credit card.

Page 10: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 10/60

x Documentum Web Development Kit Tutorial

Page 11: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 11/60

Documentum Web Development Kit Tutorial 1–1

1What is the WebDevelopment Kit? 1

This chapter provides a basic introduction to the Documentum WebDevelopment Kit (WDK), the development environment that it uses, and theweb applications that it allows you to build. There are no tutorial exercises inthis chapter, but this information is essential to understanding the WDK.

This chapter contains the following sections:

s “What WDK Is and What it Can Do” on page 1-1

s “Compliance With Java Specifications” on page 1-2

s “Dependencies on Other Software” on page 1-3

s “Fitting the Pieces Together” on page 1-3

s “Summary” on page 1-6

What WDK Is and What it Can Do

The WDK is a set of tools with which you can build custom web applications that include Documentum functionality and run on a Java application server.A web application is a collection of JavaServer Pages, servlets, classes, HTMLpages, JAR files, and any other resources that can be bundled together and

deployed as a standalone application on a Java application server. Userslaunch and use the web application in a web browser.

With WDK, your web applications can include document managementfeatures such as checkout and checkin, workflows, lifecycles, and virtualdocuments.

The WDK consists of the following tools:

s

 Java classes that conduct Docbase operations. These classes include:

Page 12: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 12/60

What is the Web Development Kit?Compliance With Java Specifications

1–2 Documentum Web Development Kit Tutorial

❒ Command classes that conduct Docbase operations.

❒ Content transfer classes that manage checkout, checkin, import, andexport of documents and XML between clients and a Docbase. Thecontent transfer classes install and use content transfer applets in theclient browser.

The command classes and content transfer classes rely on theDocumentum Foundation Classes (DFC) to provide basic Docbasefunctionality.

s  Java classes for models and views of Documentum objects, such as modelsand views of the folder hierarchy in a Docbase or the document hierarchyin a virtual document.

s  Java classes that manage configuration, context, menus, localization,events, and exceptions.

s  JavaServer Pages that provide Documentum functionality by instantiatingobjects based on the Java classes and creating standard user interfaces. JSP

pages can contain both server-side Java code and client-side HTML and JavaScript code, allowing you to generate dynamic content on the serverand control its presentation and behavior on the client. You can customizethese JSP pages as desired for your application.

s  JavaScript functions and event handlers that support the user interfaces inthe JSP pages. Some JavaScript functions reside in associated JSP pages,while others reside in files that contain only JavaScript.

s Services that allow you to configure your application and its componentswith XML, which reduces the amount of time and programming expertiserequired to develop your application.

s API documentation (Javadocs) for the WDK and DFC classes, and onlinehelp (Javahelp) that contains documentation for the JavaServer pages andapplication development tasks.

Compliance With Java Specifications

The tools in WDK conform to the following specifications, available at http:// java.sun.com:

s  Java Servlet Specification, version 2.2

s  JavaServer Pages Specification, version 1.1

Page 13: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 13/60

What is the Web Development Kit?Dependencies on Other Software

Documentum Web Development Kit Tutorial 1–3

To deploy and run a web application that is built on WDK, you require a Java

application server that supports both of these specifications.

Dependencies on Other Software

Before you develop a web application using WDK, you must install and

configure the following server software:s An HTTP server, which can reside on your development machine or on a

separate machine.

s A Java application server, which communicates with the HTTP server andtypically (but not always) resides on the same machine as the HTTP server.The Java application server must support both the Java ServletSpecification, version 2.2, and the JavaServer Pages Specification, version1.1.

s A Documentum eContent server and Docbase, which is accessed through aDocbroker and can reside on any machine.

These products are separate from the WDK. To install and configure theseproducts, refer to their installation instructions and documentation.

To conduct the exercises in this tutorial, you need:

s

The server software described above.s A text editor on your development machine that reads and writes plain

ASCII by default and does not reformat or automatically wrap lines thatyou type. You can optionally use a J2EE-compliant integrateddevelopment environment (IDE) for Java on your development machine.

Fitting the Pieces Together

As you develop your web application, you typically work with local files anda development server, and you revise and add files as the application evolves.When your web application is complete and ready to deploy on a productionapplication server, you use Java archive tools to package all of the files and

Page 14: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 14/60

What is the Web Development Kit?Fitting the Pieces Together

1–4 Documentum Web Development Kit Tutorial

resources into a single Web Archive (WAR) file. You then use the tools

provided by your Java application server to deploy the WAR file as anapplication on your production server.

Deployment procedures differ among application servers. For deploymentdetails, consult the documentation for your application server. For a detaileddescription of web applications and the WAR file format, refer to the JavaServlet Specification, version 2.2, available at http://java.sun.com.

After a web application is deployed on the application server, a user launches

the application by requesting the application’s start page in a web browser.The following steps describe what happens when a user requests theapplication’s start page. Figure 1-1 illustrates these steps.

1. User launches a web browser and requests the application’s start page, forexample, http://appserver/appname/wdkSpace/wdkSpace.jsp. Appserveris the name of your application server and appname is the name of yourWDK-powered application.

2. The browser sends this request to the HTTP server.

3. The HTTP server recognizes that this is a request for a JSP page, not anHTML page, and it passes the request to the Java application server.

4. The Java application server then retrieves the JSP page and compiles it intoa servlet if necessary. JSP pages are compiled the first time they are requested.The application server then saves the compiled servlet for use by subsequentrequests.

5. The Java application server runs the compiled servlet, executing theserver-side Java instructions and accessing the Docbase as necessary. Theservlet produces a response that consists solely of HTML and JavaScript.

6. The Java application server sends the response (HTML + JavaScript) to theHTTP server.

7. The HTTP server sends the response to the user ’s browser, which

processes any JavaScript in the response and displays the HTML in theresponse.

Page 15: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 15/60

What is the Web Development Kit?Fitting the Pieces Together

Documentum Web Development Kit Tutorial 1–5

Figure 1-1 Displaying an Application’s Start Page in a Browser

W eb server machine (hardware)

HTT P server (software)

Client machine (hardware)

Browser (software)

Java application server (software)

Get the JSP file

Compile the JSP

into a servlet

Run the servlet; generate

HTML/JavaScript

Server machine

(hardware)

Docbase

http://appserver/appname/wdkSpace/wdkSpace.jspAddress:

WAR file

wdkSpace.jsp

Java Virtual Machine

(software)

1

2

3

5

6

7

4

Page 16: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 16/60

What is the Web Development Kit?Summary

1–6 Documentum Web Development Kit Tutorial

Summary

s The WDK is a set of tools with which you can build a web application thathas Documentum functionality.

s A web application is a collection of pages, classes, and any other resourcesthat constitute a standalone application on a Java application server. Webapplications are described in the Java Servlet Specification, version 2.2.

s To develop and deploy a web application with WDK, you need an HTTPserver, a Java application server, and a Documentum eContent Server andDocbase.

Page 17: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 17/60

Documentum Web Development Kit Tutorial 2–1

2JavaServer Pages in theWDK 2

WDK functionality is presented primarily via JavaServer Pages, also known as JSP pages. (The term “ JSP pages” seems redundant, but this is the terminologyused in the JavaServer Pages Specification.) You can think of a JSP page as thesource code for a servlet whose sole function is to produce an HTTP responseobject from an HTTP request object. For example, a web browser requests a

 JSP page and includes any information that the JSP requires, such as IDs ofobjects in the Docbase. The request goes to the HTTP server, which passes it tothe application server. The application server compiles the requested JSP intoa servlet (in many cases, the JSP is already compiled) and runs the servletusing the information provided with the request. The output from the servletis the response, which consists of HTML and JavaScript. This response isreturned to the browser and displayed.

Detailed information on servlets and JSP pages is available in Java ServletSpecification, version 2.2, and the JavaServer Pages Specification, version 1.1.

These specifications are available at http://java.sun.com.

This chapter describes how JSP pages are used in the WDK. It contains thefollowing sections:

s “Anatomy of a Typical WDK Server Page” on page 2-1

s “HTML Generated by JSP” on page 2-3

s “Handling Errors” on page 2-3

Anatomy of a Typical WDK Server Page

Most JSP pages in the WDK have the following general structure:

1. Page language and page info directives, which typically specify the content

type, encoding, language, error page, and application name. For example:

Page 18: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 18/60

JavaServer Pages in the WDKAnatomy of a Typical WDK Server Page

2–2 Documentum Web Development Kit Tutorial

<%@ page contentType="text/html; charset=UTF-8"%>

<%@ page language="java" errorPage="/wdk/component/error/error.jsp"%>

<%@ page info="WDK Application"%>

2. Import the Java classes required by the page. Most JSP pages in the WDK usethe following classes:

s com.documentum.wc.env.jsp.DwJSPPageContext

DwJSPPageContext is the page context object, which binds to the WDKnamespace and reads the application configuration file. Use the pagecontext object to acquire all of the persistent objects needed for the page,

such as the web application (DwApplication), application session(DwAppSession), and page set (DwPageSet).

s com.documentum.wc.env.DwPageSet

DwPageSet is used to store state information for a group of pages that areused in a single business transaction. For example, the task manager pageset caches queue item IDs, work item IDs, the document list model, theobject ID of a selected document, and the package ID for that document.

s com.documentum.wc.env.DwAppSession

DwAppSession is the web application session object. The applicationsession checks the login requirements. If the user has no active session, thelogin page specified in the config.xml for the application is presented. Tocreate or acquire a DwAppSession, use the methodDwJSPPageContext.acquireSession.

s com.documentum.wc.env.DwApplication

DwApplication is the application object, which is used to create otherapplication-level objects or to get a URL to the root folder of theapplication.

3. Create the DwJSPPageContext object. For example:DwJSPPageContext wdkPageContext = newDwJSPPageContext(pageContext.getServletContext(), request, response, true);

4. The try block. Most of the code on each WDK server page is enclosed in a Java

try...catch block.

5. Create the application object, page set, and application session. For example:DwApplication app = DwApplication.getApplication();

DwPageSet pageSet = wdkPageContext.getPageSet();

DwAppSession appSession = wdkPageContext.acquireSession();

6.  Java code.

7. The HTML block, including any JavaScript. Most WDK server pages include

the following JavaScript files in the HTML block:

Page 19: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 19/60

JavaServer Pages in the WDKHTML Generated by JSP

Documentum Web Development Kit Tutorial 2–3

s events.js, which contains functions that support cross-frame events and

manage the propagation of events.s url.js, which contains functions that add, remove, and retrieve URL

arguments.

s history.js, which contains functions that that are used by the event handlersin WDK to call or return to a JSP page.

8. Release the application session:

wdkPageContext.releaseSession();

9. The catch block, which handles exceptions that were thrown in the try blockand ensures that the application session is released.

HTML Generated by JSP

The output of a JSP page (more accurately, the output of the servlet that that iscreated from the JSP page) consists of HTML and JavaScript that is returned tothe web browser. This HTML and JavaScript has two sources:

s Static HTML and JavaScript, which are hard-coded in the JSP page.

s Dynamic HTML and JavaScript, which are generated by the Java code inthe JSP page and by Java classes that are called by the JSP page.

These two sources are not distinguishable in the HTML and JavaScript that isreturned to the browser. As far as the web browser is concerned, it is simplystatic HTML and JavaScript to process and display.

This distinction between static and dynamic content supports a convenientseparation of roles on your web development team. A page design team candevelop the static elements, and a programming team can develop thedynamic elements.

Handling Errors

 Java classes in the WDK throw Java exceptions when critical errors occur, forexample, when a Docbase is not available. The code in the JSP page musthandle these exceptions, or page execution halts completely.

Page 20: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 20/60

JavaServer Pages in the WDKHandling Errors

2–4 Documentum Web Development Kit Tutorial

In the JSP pages in WDK, the code in the page is enclosed in a Java try...catch

 block. For example:try

{

page code

}

catch(Exception err)

{

error-handling code

}

At the end of the try block, release any established application session to freesession objects that are no longer in use. For example:

DwJSPPageContext.releaseSession();

In the catch block, handle any exceptions that were raised in the try block.Minimally, the catch block must:

s Catch the exception.

s Release the application session. For example,DwJSPPageContext.releaseSession();

s Set attributes on the request object. For example,request.setAttribute(“ErrorDescription”, “<error-text>”)

s Re-throw the caught exception, which triggers the intrinsic JSP/Servleterror handling mechanism. Control is then redirected to the active errorpage. The WDK error page is error.jsp, which uses the class

DwExceptionView to report the error.

Page 21: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 21/60

Documentum Web Development Kit Tutorial 3–1

3Developing an Application 3

This chapter describes how to create a simple application that uses

components of the Web Development Kit. The application will allow you tolog in and out of a Docbase, view your Inbox, and browse Docbase contents.

The chapter contains the following sections:

s “Prepare Your Environment” on page 3-1

s “Plan the Application” on page 3-2

s “Create the Application Directory” on page 3-3

s “Locate the Tutorial Files” on page 3-5

s “Create a Page” on page 3-5

s “Add the Toolbar” on page 3-7

s “Add Event Handlers” on page 3-10

s “Enable Actions on Docbase Contents” on page 3-12

s “Extra Investigation: Use Cascading Style Sheets to Customize the Look ofYour Application” on page 3-13

Prepare Your Environment

Before you begin the exercises in this chapter, you must install WDK and the

sofware on which it depends. You must also ensure that you can load JSPpages successfully. The following procedure describes all of these tasks.

➤ To prepare and test your web application environment:

1. Ensure that your HTTP server, Java application server, and DocumentumeContent server and Docbases are installed and configured. For moreinformation, see “Dependencies on Other Software” on page 1-3. Althoughthese software packages are not part of the WDK, the WDK relies on their

correct configuration.

D l i A li ti

Page 22: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 22/60

Developing an ApplicationPlan the Application

3–2 Documentum Web Development Kit Tutorial

2. To test your application server, load a JSP page in your browser. Most

application servers include sample JSP pages for testing purposes.3. Install the Web Development Kit and deploy the wdkSpace sample

application in exploded directory format. In exploded directory format, the.war file is expanded as a collection of files that use a directory structure.

The exercises in this manual rely on successful installation and configurationof the WDK. The Documentum Web Development Kit Installation and ReleaseNotes contains critical information for configuring WDK. Follow the

instructions closely to deploy the wdkSpace sample application and test theinstallation.

Plan the Application

In the following sections, you will create a simple application namedwdkTutorial. This application allows you to log in and browse availableDocbases, view your Documentum Inbox, and log out of a Docbase.

The user interface includes a Docbase tree frame on the left, a folder browsingframe on the right, and a toolbar frame across the top:

Developing an Application

Page 23: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 23/60

Developing an ApplicationCreate the Application Directory

Documentum Web Development Kit Tutorial 3–3

Create the Application Directory

In this section, you will create a new web application root directory namedwdkTutorial, and then you will copy files from the wdkSpace sampleapplication into the new wdkTutorial application root directory. Copying filesfrom the wdkSpace sample application will ensure that the WDK frameworkis available to the wdkTutorial application.

Before you begin, ensure that the wdkSpace sample application is deployed inexploded directory format. In exploded directory format, the .war file isexpanded as a collection of files that use a directory structure. For instructionson deploying the wdkSpace sample application, see the Documentum WebDevelopment Kit Installation and Release Notes.

Developing an Application

Page 24: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 24/60

Developing an ApplicationCreate the Application Directory

3–4 Documentum Web Development Kit Tutorial

➤ To create the directory for the wdkTutorial application:

1. Create a new, empty web application and corresponding root directory namedwdkTutorial. How you create a new web application and root directorydepends on your application server and operating system. For specificinstructions, refer to the documentation for your application server.

2. Copy the contents of the deployed wdkSpace sample application directory toyour new wdkTutorial application directory. (Ensure that you copy from thedeployed wdkSpace sample application, not the WDK installation location.)

Your wdkTutorial application directory now has the following structure:\wdkTutorial

config.dtd

config.xml

\wdk

\wdkSpace

\WEB-INF

3. Rename the wdkSpace directory to wdkTutorial. This wdkTutorial

subdirectory will contain the files that are specific to the wdkTutorialapplication. Your wdkTutorial application directory now has the followingstructure:

\wdkTutorial

config.dtd

config.xml

\wdk

\wdkTutorial

\WEB-INF4. Navigate to the css directory below the wdkTutorial directory. Rename the

two files as follows:

s Rename wdkSpace.css to wdkTutorial.css.

s Rename wdkSpaceBase.css to wdkTutorialBase.css.

5. If necessary, restart your application server to activate the wdkTutorialapplication.

Developing an Application

Page 25: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 25/60

Developing an ApplicationLocate the Tutorial Files

Documentum Web Development Kit Tutorial 3–5

Locate the Tutorial Files

The files that you will use in this tutorial are packaged in the archivesWDK_Tutorial_42_Files.zip (for Windows) andWDK_Tutorial_42_Files.tar.gzip (for Unix). These archives reside in the docsdirectory in your WDK installation directory.

Locate the archive for your system and extract its files to the

\wdkTutorial\wdkTutorial directory. (This is the wdkTutorial subdirectory,not the wdkTutorial main directory.)

Create a Page

In this section, you will create the first page of the wdkTutorial application byadding a title, style sheet references, and a frameset to an existing skeletalWDK server page.

If you encounter problems during the procedure, refer to the solution pagewdkTutorial0_finished.jsp.

➤ To create the page:

1. In a plain ASCII editor, open and examine the file wdkSkeletonPage.jsp. (In

the previous section, you extracted this file from an archive to your\wdkTutorial\wdkTutorial directory.)

The file wdkSkeletonPage.jsp contains the basic elements that are common tomost WDK server pages. For explanations of these elements, refer to“Anatomy of a Typical WDK Server Page” on page 2-1.

2. Save the file as wdkTutorial0.jsp.

3. To add the title, find the following line:

<title>TODO: Add title here</title>

Replace “TODO: Add title here” with “WDK 4.2 Tutorial Application” (omitthe quotes).

4. To specify the style sheets, add the following two lines immediately after thetitle line that you edited in Step 3:

Developing an Application

Page 26: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 26/60

p g ppCreate a Page

3–6 Documentum Web Development Kit Tutorial

<link rel='stylesheet' type='text/css' href='/css/wdkTutorialBase.css'>

<link rel='stylesheet' type='text/css' href='/css/wdkTutorial.css'>

These are the style sheets that you copied from wdkSpace sample applicationand renamed. They specify styles for both standard HTML elements and forthe custom style classes used by the Java classes in WDK.

5. To create the frameset, add the following lines between the </head> and </html> tags.

<frameset rows='30,*,0' border='0' framespacing='0' frameborder='no'>

<frame name='header' frameborder='no' marginwidth=0 marginheight=0 noresizescrolling='no'>

<frame name='view' frameborder='no' marginwidth=0 marginheight=0 noresize

scrolling='auto'

src='/wdkTutorial/wdk/component/browse/browse.jsp'>

<frame name='actions' scrolling='no' frameborder='0'>

</frameset>

This frameset contains three frames:

s An empty header frame. In a later section, you will add the toolbar in thisframe.

s A view frame that displays the WDK page browse.jsp. This page containstwo frames of its own: a frame on the left that allows you to displaymultiple Docbase hierarchies as a single tree, and a frame on the right thatdisplays the contents of the cabinets and folders in a Docbase.

s An actions frame that you will use in a subsequent section. The actionsframe is not visible.

6. Save wdkTutorial0.jsp and view it in a browser. Typically its URL is http://localhost/wdkTutorial/wdkTutorial/wdkTutorial0.jsp.

The top frame is empty, and the view frame displays a Docbase tree frame onthe left and a list of available docbases on the right. Your list of availableDocbases will differ from the list in the illustration.

Docbase browsing is not fully functional yet. If you click links in the page and

log in to a Docbase, you cannot view documents correctly and you cannot logout.

Developing an Application

Page 27: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 27/60

Add the Toolbar

Documentum Web Development Kit Tutorial 3–7

Add the Toolbar

In this section, you will create the page for the toolbar frame. The toolbar buttons will reside in an HTML table. You will then specify this page as thesource for the header frame in the page wdkTutorial0.jsp, and save it aswdkTutorial1.jsp.

If you encounter problems during the procedure, refer to the solution pagestoolbarTutorial_finished.jsp and wdkTutorial1_finished.jsp.

➤ To create the toolbar page:

1. Open the file wdkSkeletonPage.jsp and save it as toolbarTutorial.jsp. You willedit this file to create the toolbar page.

2. In the page import section, remove the imports of DwPageSet andDwApplication. Then add the import of DwCustToolbarInputButtonView.Your page import section is now:

<%@ page import="com.documentum.wc.env.jsp.DwJSPPageContext"%>

<%@ page import="com.documentum.wc.env.DwAppSession"%>

<%@ page import="com.documentum.wc.widget.DwCustToolbarInputButtonView"%>

DwCustToolbarInputButtonView is the class from which the toolbar buttonswill be created.

Developing an Application

Page 28: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 28/60

Add the Toolbar

3–8 Documentum Web Development Kit Tutorial

3. To create the view that will generate the toolbar buttons, add the following

line just before the try block:DwCustToolbarInputButtonView custToolbarButtonView = new

DwCustToolbarInputButtonView();

4. Remove the following lines from the try block. These lines are not required bythe toolbar page:

DwPageSet pageSet = wdkPageContext.getPageSet();

DwApplication app = wdkPageContext.getApplication();

5. In the same location as the two lines that you deleted, add the following line because the toolbar page needs to connect to the current application session.

DwAppSession appSession = DwAppSession.getAppSession();

6. In the <head> section, do the following:

a. Add a title and links to the style sheets as you did in wdkTutorial0.jsp:

<title>WDK 4.2 Tutorial Application</title>

<link rel='stylesheet' type='text/css' href='./css/wdkTutorialBase.css'>

<link rel='stylesheet' type='text/css' href='./css/wdkTutorial.css'>

Note: In this case, include the leading dot (.) in the path names of the stylesheets.

b. Change the event source name from wdkTutorial0 to toolbarTutorial.

c. Remove the following lines. They will not be used by the toolbar page.<script language="JavaScript" src="/wdkTutorial/wdk/component/history/

history.js"></script>

<script language="JavaScript" src="/wdkTutorial/wdkTutorial/

eventHandlers.js"></script>

7. After the </head> tag, create the HTML body and the table that will containthe toolbar buttons:

<body class="contentBackground" topmargin="0" leftmargin="10" rightmargin="0"

bottommargin="0" marginheight="0" marginwidth="0">

<table width="100%" border="0" cellpadding="0" cellspacing="0" height="30">

</table>

</body>

8. To create the toolbar buttons, add the following row and cells to the table.

<tr><td align=middle width="20%"><%=custToolbarButtonView.generateEventButton("Docbase","vie wDocbase", "", "")%></td><td align=middle width="20%">

<%=custToolbarButtonView.generateEventButton("Inbox", "viewInbox", "", "")%>

Developing an ApplicationAdd th T lb

Page 29: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 29/60

Add the Toolbar

Documentum Web Development Kit Tutorial 3–9

</td><td align=middle width="20%"><%=custToolbarButtonView.generateEventButton("Logout", "logout", "", "")%></td>

</tr>

Each toolbar button is created with the methodDwCustToolbarInputButtonView.generateEventButton, which takes fourparameters: the button label, the event name, and two optional parameters topass to the event.

9. Save toolbarTutorial.jsp and view it in a browser. (The URL is http://

localhost/wdkTutorial/wdkTutorial/toolbarTutorial.jsp, replacing localhostwith your server name if necessary.) You see the row of toolbar buttons:

The buttons are not yet functional. You will activate them in the “Add Event

Handlers” section.➤ To specify the toolbar page in the frameset of the application page:

1. Open the file wdkTutorial0.jsp and save it as wdkTutorial1.jsp.

2. In the JavaScript section, change the event source name from wdkTutorial0 towdkTutorial1.

3. Find the line that begins with <frame name='header' and add a src parameter

that specifies toolbarTutorial.jsp:

<frame name='header' frameborder='no' marginwidth=0 marginheight=0

noresize scrolling='no'

src='/wdkTutorial/wdkTutorial/toolbarTutorial.jsp'>

4. Save wdkTutorial1.jsp and view it in a browser. You see the toolbar in theheader frame:

Developing an ApplicationAdd Event Handlers

Page 30: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 30/60

Add Event Handlers

3–10 Documentum Web Development Kit Tutorial

Add Event Handlers

In this section, you will add event handlers to wdkTutorial1.jsp and save thepage as wdkTutorial2.jsp. The new event handlers will handle the events thatare fired by the toolbar buttons.

If you encounter problems during the procedure, refer to the solution pagewdkTutorial2_finished.jsp.

➤ To add the event handlers:

1. Open the file wdkTutorial1.jsp and save it as wdkTutorial2.jsp.

2. In the JavaScript section, change the event source name from wdkTutorial1 towdkTutorial2.

3. At the end of the JavaScript section, add a new, empty JavaScript element:

<script language="JavaScript">

</script>

4. Within the new JavaScript element, add the event handler for theviewDocbase event. This event is fired by the Docbases button in the toolbarpage.

Developing an ApplicationAdd Event Handlers

Page 31: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 31/60

Add Event Handlers

Documentum Web Development Kit Tutorial 3–11

/** Handle viewDocbase event from Docbase button on toolbar */

function eventHandler_viewDocbase( strSender, strFolderId)

{ var strUrl = strContextPath + "/wdk/component/browse/browse.jsp";

strUrl = urlAddExclusiveParam(strUrl, "folderId", strFolderId);

strUrl = urlMakeForcedReload(strUrl);

window.frames.view.location.href = strUrl;

setComponentFrame(window.frames.view.frames[1]);

}

5. Within the same JavaScript element, add the event handler for the viewInboxevent. This event is fired by the Inbox button in the toolbar page.

/** Handle viewInbox event from Inbox button on toolbar */

function eventHandler_viewInbox()

{

var strUrl = strContextPath + "/wdk/component/inbox/inbox.jsp";

strUrl = urlMakeForcedReload( strUrl );

window.frames.view.location.href = strUrl;

setComponentFrame(window.frames.view);

}

6. Within the same JavaScript element, add the event handler for the logout

event. This event is fired by the Logout button in the toolbar page.

/** Handle logout event from Logout button on toolbar */

function eventHandler_logout()

{

var strUrl = strContextPath + "/wdk/component/logout/logout.jsp";

strUrl = urlMakeForcedReload(strUrl);

window.location.href = strUrl;

}

7. Within the same JavaScript element, add the following function that ensurescorrect behavior when the browser window is resized in Netscape:

/** Handle resize of the browser window */

function handleResize()

{

if ( window.navigator.appName.toLowerCase() == "netscape" )

{

window.location.reload(false);

}

}

8. Add the parameters onResize and onLoad to the frameset element.

<frameset rows='30,*,0' border='0' framespacing='0'

frameborder='no' onResize='handleResize()'

onLoad="setComponentFrame(window.frames.view.folderDetail)">

Developing an ApplicationEnable Actions on Docbase Contents

Page 32: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 32/60

3–12 Documentum Web Development Kit Tutorial

The onResize parameter ensures correct behavior when the browserwindow is resized in Netscape. The onLoad parameter ensures that WDKcomponents (the login page, for example) are displayed in the frame on theright in the window. This is the folderDetail frame in browse.jsp, whichresides in the view frame of wdkTutorial2.jsp.

9. Save wdkTutorial2.jsp and view it in a browser. Test your toolbar buttons:

a. Click the Inbox button and log in when prompted. You see yourDocumentum Inbox.

b. Click the Docbases button. You return to the Docbase view. (You cannotview Docbase content successfully if you click the links to cabinets, folders,and documents in the Docbase. You will add this functionality in the nextsection.)

c. Click the Logout button and log out of the Docbase as prompted.

Enable Actions on Docbase Contents

In this section, you will enable actions on Docbase contents so that you canview, edit, and conduct other standard Documentum operations on thedocuments in a Docbase. You will start with wdkTutorial2.jsp, set up anevents dictionary, load the WDK action dispatcher page into the invisibleframe, and save the page as wdkTutorial3.jsp.

If you encounter problems during the procedure, refer to the solution pagewdkTutorial3_finished.jsp.

➤ To enable actions on Docbase contents:

1. Open the file wdkTutorial2.jsp and save it as wdkTutorial3.jsp.

2. In the JavaScript section, change the event source name from wdkTutorial2 to

wdkTutorial3.3. Add the following classes to the page import section:

<%@ page import="com.documentum.wc.env.docbase.DwDocbaseTypedDictionary"%><%@ page import="com.documentum.wc.widget.docbase.DwDocOpenLink Event"%>

You will use these classes to create a dictionary of events that are fired by linksto cabinets, folders, and documents in the Docbase. These links and eventsallow you to browse and navigate the Docbase.

Developing an ApplicationExtra Investigation: Use Cascading Style Sheets to Customize the Look of Your Application

Page 33: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 33/60

Documentum Web Development Kit Tutorial 3–13

4. After the line that begins with “DwApplication app”, create the dictionary:

// Set up an events dictionary used for edit/view linksDwDocbaseTypedDictionary eventsDictionary = (DwDocbaseTypedDictionary) app.get("Dictionary_Events");if (eventsDictionary == null){

// Build and populate the events dictionary.eventsDictionary = new DwDocbaseTypedDictionary();eventsDictionary.put("dm_folder", "viewFolder");DwDocOpenLinkEvent docOpenLinkEvent = new DwDocOpenLinkEvent();eventsDictionary.put("dm_document", docOpenLinkEvent);app.put("Dictionary_Events", eventsDictionary);

}

// Set up a readonly version of the events dictionary used for view linksDwDocbaseTypedDictionary eventsDictionaryReadonly = (DwDocbaseTypedDictionary)

app.get("Dictionary_Events_Readonly");if (eventsDictionaryReadonly == null){

// Build and populate the readonly events dictionary.eventsDictionaryReadonly = new DwDocbaseTypedDictionary();eventsDictionaryReadonly.put("dm_folder", "viewFolder");DwDocOpenLinkEvent docOpenLinkEventReadonly = new DwDocOpenLinkEvent();docOpenLinkEventReadonly.setReadOnly(true);eventsDictionaryReadonly.put("dm_document", docOpenLinkEventReadonly);app.put("Dictionary_Events_Readonly", eventsDictionaryReadonly);

}

5. Find the line that begins with <frame name='actions' and add a src parameterthat specifies actionDispatcherContainer.jsp:

<frame name='actions' src='/wdkTutorial/wdk/action/actionDispatcherContai ner.jsp'scrolling='no' frameborder='0'>

6. Save wdkTutorial3.jsp and view it in a browser. To test Docbase browsing,click a Docbase name, log in, navigate to a folder, select a document, andchoose View from the drop-down menu.

Extra Investigation: Use Cascading Style Sheetsto Customize the Look of Your Application

Cascading Style Sheets allow you to alter the look and feel of yourapplications significantly without changing any code in the page. This tutorialassumes that you are familiar with Cascading Style Sheets; detailedinformation is available at http://www.w3.org/Style/CSS.

In WDK, you can use Cascading Style Sheets to specify style property valuesfor:

s Standard style classes such as BODY, P, and A:link.

s Custom style classes that you create for your application.

Developing an ApplicationExtra Investigation: Use Cascading Style Sheets to Customize the Look of Your Application

Page 34: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 34/60

3–14 Documentum Web Development Kit Tutorial

s Style classes that are specific to WDK. Many of the widgets and UIelements in WDK use their own custom style classes. These WDK styleclasses are described in the “Custom Styles” section of the WDK OnlineHelp.

Your tutorial application (wdkTutorial3.jsp) uses the style sheet files thatreside in the css subdirectory of the wdkTutorial directory. You canexperiment by modifying the style property values in these style sheets, andyou can add more styles if desired.

Additionally, you can use the Branding section in the file config.xml tooverride WDK styles. For details, search for Branding in the WDK OnlineHelp.

4

Page 35: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 35/60

Documentum Web Development Kit Tutorial 4–1

4Customizing WDKComponents 4

This chapter describes two common ways to customize WDK components:

s Editing XML configuration files.

s Using methods provided by WDK classes.

You will modify the document menu by editing XML files, and you will add acolumn to a table view using a method of the DwTableView class.

This chapter contains the following sections:

s “Modify a Menu” on page 4-1

s “Add a Column to a View” on page 4-3

Modify a Menu

When you select a document in the tutorial application, you see a drop-downmenu from which you can select actions to conduct on the selected document,such as Checkout, View, and Edit. You can change the items on this menu bymaking simple edits to the XML files in the WDK configuration folder.

In this section, you will remove three items from the menu. An “extrainvestigation” section then describes how to add an item to the menu.

Before you begin

Open wdkTutorial3.jsp (or the solution file wdkTutorial3_finished.jsp). Log into a Docbase, open a folder or cabinet in the Docbase, and select a document.Click the drop-down menu above the list of documents and examine the

Customizing WDK ComponentsModify a Menu

Page 36: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 36/60

4–2 Documentum Web Development Kit Tutorial

available choices. Near the bottom of the menu, you see the items Send To,Start Workflow, and Attach Document Lifecycle. In the following procedure,you will remove these three items from the menu.

Remove the menu items

➤ To remove the three menu items:

1. Open the wdk directory that is a sibling of the wdkTutorial directory, and then

open the config directory. Make a backup copy of the filedocument_menus.xml, and save this backup copy in a location outside of theconfig directory.

2. Return to the config directory and open the file document_menus.xml forediting.

3. Remove the following lines from the file. These are the lines that correspondto the three menu items that you want to remove:

<menuitem>

<name><nlsid>MSG_SENDTO_MENU</nlsid></name>

<actionid>sendTo</actionid>

</menuitem>

<menuitem>

<name><nlsid>MSG_STARTWORKFLOW_MENU</nlsid></name>

<actionid>startWorkflow</actionid>

</menuitem>

<menuitem>

<name><nlsid>MSG_ATTACH_POLICY_MENU</nlsid></name>

<actionid>attachPolicy</actionid>

<disableifmultipleselections/>

</menuitem>

4. Save document_menus.xml.

5. Restart your application server to activate the changes to the XML file.

Once again, open wdkTutorial3.jsp (or the solution file

wdkTutorial3_finished.jsp). Log in to a Docbase, open a folder or cabinet inthe Docbase, and select a document. Click the drop-down menu above the listof documents and examine the available choices. You no longer see the itemsSend To, Start Workflow, and Attach Document Lifecycle.

Customizing WDK ComponentsAdd a Column to a View

Page 37: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 37/60

Documentum Web Development Kit Tutorial 4–3

Extra investigation: Add a menu item

In the config folder, the files document_actions.xml anddocument_menus.xml work together to configure the available menu itemsand the corresponding actions that they perform when a document is selected:

s document_actions.xml specifies the possible actions to perform on adocument.

s document_menus.xml specifies the menu items that are available when a

document is selected, and the corresponding action to perform.

The actionid values in document_menus.xml correspond to the id values indocument_actions.xml.

To add a new action and a corresponding new menu item, specify the newaction in document_actions.xml, and then specify the new menu item indocument_actions.xml. For detailed information on actions and menus, seethe WDK Online Help.

Add a Column to a View

To display a list of documents in a cabinet or folder, the server pages in WDKuse the class DwTableView. DwTableView provides methods that allow you to

specify the columns that are displayed in the table.

In this section, you will use a method of DwTableView to add a column thatdisplays the object type.

Before you begin

Open wdkTutorial3.jsp (or the solution file wdkTutorial3_finished.jsp). Log into a Docbase and open a folder or cabinet in the Docbase. In the table ofdocuments, you see the columns Name, Last Modified, and Lock Owner. Inthe following procedure, you will add a column named Type that displays theobject type.

Important! For simplicity and clarity, the following exercise asks you to editthe WDK server page folderContents.jsp. This is contrary to therecommended best practices to follow when you develop your own WDK-

Customizing WDK ComponentsAdd a Column to a View

Page 38: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 38/60

4–4 Documentum Web Development Kit Tutorial

powered web applications. When you develop your own applications, putcustom functionality solely in custom server pages. Edit the WDK serverpages solely to call your custom pages. If you edit the WDK server pagesdirectly, the resulting pages can be difficult to migrate to future versions ofWDK.

Add the column to the view

If you encounter problems during this procedure, refer to the solution pagefolderContents.jsp.

➤ To add the Type column to the view:

1. Open the wdk directory below the main wdkTutorial directory, open thecomponent subdirectory, and then open the contents subdirectory. Make a

 backup copy of the file folderContents.jsp.

2. Open folderContents.jsp for editing.

3. Locate the following line:

<jsp:useBean id="folderContentsView"

class="com.documentum.wc.widget.DwTableView" scope="session" />

This line creates folderContentsView, which is a table view bean based on theclass DwTableView. The next three lines set the model to use with the view(the model was created earlier on the page), specify how to align the rows,

and whether to display row dividers.

The subsequent set of statements specifies the columns infolderContentsView. In the next step, you will add a line that specifies the newType column.

4. Between the lines for Name and Modification Date, insert the following line:

folderContentsView.addFormattedColumn("Type", "Type", strObjType, "15%");

5. In the line that specifies the Name column, change “55%” to “40%”.

6. Add a line that obtains values for strObjType:

a. Scroll up to the section with the comment “Define useful format strings.”

b. Add the following line:

String s trObjType = "{r_object_type}";

Customizing WDK ComponentsAdd a Column to a View

Page 39: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 39/60

Documentum Web Development Kit Tutorial 4–5

7. Save folderContents.jsp.

Once again, open wdkTutorial3.jsp (or the solution filewdkTutorial3_finished.jsp). Log in to a Docbase and open a folder or cabinetin the Docbase. In the table of documents, you now see the new Type columnthat displays the object type of each document.

Customizing WDK ComponentsAdd a Column to a View

Page 40: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 40/60

4–6 Documentum Web Development Kit Tutorial

5

Page 41: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 41/60

Documentum Web Development Kit Tutorial 5–1

5Displaying Properties of aCustom Object Type 5

This chapter describes how to display the properties of a custom object type inthe properties page of the WDK. It contains the following sections:

s “Display Custom Properties of a Custom Object Type” on page 5-1

s “Extra Investigation: Searching for Properties of a Custom Object Type” onpage 5-3

This chapter assumes that your Docbase already contains a custom object type

with custom properties. Typically you use Documentum Developer Studio tocreate custom types and properties.

Display Custom Properties of a Custom Object

Type

In WDK, when you display the properties of a selected document from theDocbase, you see the values for a default set of properties for the genericobject type dm_document. If the document is of a custom object type, you donot see values for any of the custom properties that are associated with thecustom object type. To display values for the properties of a custom objecttype, you must create a new XML configuration file that specifies the custom

object type and the custom properties to display.

In this section, you will create a new XML configuration file for a customdocument type in your Docbase. You can use any custom object type thatresides in your Docbase.

Displaying Properties of a Custom Object TypeDisplay Custom Properties of a Custom Object Type

Page 42: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 42/60

5–2 Documentum Web Development Kit Tutorial

Before you begin

Collect the following information for the custom object type that you want touse in the procedure:

s The name of the object type.

s The names two editable properties to display.

Open wdkTutorial3.jsp (or the solution file wdkTutorial3_finished.jsp). Log into a Docbase and open a folder or cabinet in the Docbase that contains adocument of your custom type. Select the document, and then chooseProperties from the menu. You see properties for the dm_document type, butyou do not see any of the properties of your custom type.

Display the custom properties

➤ To display the custom properties in the properties page:

1. Open the wdk directory that is a sibling of the wdkTutorial directory, and thenopen the config directory. Make a copy of the file document_properties.xmland name it customtype_properties.xml. (The name does not matter, but theextension must be .xml.)

2. Open customtype_properties.xml for editing.

3. Change the value of <type> from dm_document to the name of your custom

type.

4. Examine the section <attributes><editablegroups><group><attributelist>.You see that five attributes are specified by default: object_name, title, subject,keywords, and authors. In the next step, you will add your two customproperties to this list.

5. Following the format of the five existing attribute elements, add two moreattribute elements that specify the two custom properties that you want to

display. Notes:

s Omit the <nlsid> element within <label>, and specify the label directly.This is the label to display next to the value of the property in theproperties page. For example, the label for a property named platformmight be:

<label>Platform</label>

Displaying Properties of a Custom Object TypeExtra Investigation: Searching for Properties of a Custom Object Type

Page 43: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 43/60

Documentum Web Development Kit Tutorial 5–3

s For properties that have repeating values, use <showallvalues> to specifywhether to display all values.

s To display repeating values in a drop-down select box, use:

<displaycontrol>select</displaycontrol>

6. Save customtype_properties.xml.

7. Restart your application server to activate the changes to the XML file.

Once again, open wdkTutorial3.jsp (or the solution filewdkTutorial3_finished.jsp). Log in to a Docbase and open a folder or cabinetin the Docbase that contains a document of your custom type. Select thedocument, and then choose Properties from the menu. You now see the valuesof properties of your custom type.

Extra Investigation: Searching for Properties of a

Custom Object Type

By default, the search page in WDK does not provide the ability to searchproperties of custom object types. To search properties of custom types,modify the configuration file advanced_search.xml to include your customtype and properties. This process is similar to the procedure that you just

completed.

To use advanced_search.xml, your application must have search functionality.The tutorial application does not include search functionality. However, youcan use the wdkSpace sample application, which does provide searching.

For detailed information, see the topic “Custom Search Forms” in the WDKOnline Help.

Displaying Properties of a Custom Object TypeExtra Investigation: Searching for Properties of a Custom Object Type

Page 44: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 44/60

5–4 Documentum Web Development Kit Tutorial

A

Page 45: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 45/60

Documentum Web Development Kit Tutorial A–1

ASolution Code A

This chapter contains listings of the following completed files that are used inthis tutorial. The files are listed in the order in which they are used in the

tutorial procedures.

s “wdkSkeletonPage.jsp” on page A-2

s “wdkTutorial0_finished.jsp” on page A-3

s “wdkTutorial1_finished.jsp” on page A-4

s “toolbarTutorial_finished.jsp” on page A-5

s “wdkTutorial2_finished.jsp” on page A-7

s “wdkTutorial3_finished.jsp” on page A-9

s “folderContents.jsp” on page A-11

Solution CodewdkSkeletonPage.jsp

Page 46: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 46/60

A–2 Documentum Web Development Kit Tutorial

wdkSkeletonPage.jsp

<%@ page contentType="text/html; charset=UTF-8" %><%@ page language="java" errorPage="/wdk/component/error/error.jsp"%><%@ page info="WDK 4.2 Tutorial Application" %>

<%@ page import="com.documentum.wc.env.jsp.DwJSPPageContext"%><%@ page import="com.documentum.wc.env.DwPageSet"%><%@ page import="com.documentum.wc.env.DwAppSession"%><%@ page import="com.documentum.wc.env.DwApplication"%>

<%// Establish the context for this page.

DwJSPPageContext wdkPageContext = new DwJSPPageContext(pageContext.getServletContext(), request,response, true);

try{

DwPageSet pageSet = wdkPageContext.getPageSet();DwApplication app = wdkPageContext.getApplication();

String strContextPath = request.getContextPath();

%>

<html>

<head><title>TODO: Add title here</title>

<script language="JavaScript"> var strContextPath = "/wdkTutorial";</script>

<script language="JavaScript" src="../wdk/env/events.js"></script><script language="JavaScript">setEventSourceName("wdkTutori al0")</script>

<script language="JavaScript" src="../wdk/env/url.js"></script><script language="JavaScript" src="../wdk/env/urlArguments.js"></script>

<script language="JavaScript" src="../wdk/component/history/history.js"></script ><script language="JavaScript" src="../wdkTutorial/eventHandlers.js"></script>

</head>

</html><%

// Release the lock on the page.wdkPageContext.releaseSession();

}catch(Exception err){

// Release the lock on the page.wdkPageContext.releaseSession();request.setAttribute ("ErrorDescription", "Tutorial application failed.");throw err;

}%>

Solution CodewdkTutorial0_finished.jsp

Page 47: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 47/60

Documentum Web Development Kit Tutorial A–3

wdkTutorial0_finished.jsp

<%@ page contentType="text/html; charset=UTF-8" %><%@ page language="java" errorPage="/wdk/component/error/error.jsp"%><%@ page info="WDK 4.2 Tutorial Application" %>

<%@ page import="com.documentum.wc.env.jsp.DwJSPPageContext"%><%@ page import="com.documentum.wc.env.DwPageSet"%><%@ page import="com.documentum.wc.env.DwAppSession"%><%@ page import="com.documentum.wc.env.DwApplication"%>

<%// Establish the context for this page.

DwJSPPageContext wdkPageContext = new DwJSPPageContext(pageContext.getServletContext(), request,response, true);

try{

DwPageSet pageSet = wdkPageContext.getPageSet();DwApplication app = wdkPageContext.getApplication();

String strContextPath = request.getContextPath();

%>

<html>

<head><title>WDK 4.2 Tutorial Application</title>

<link rel='stylesheet' type='text/css' href='/css/wdkTutorialBase.css'><link rel='stylesheet' type='text/css' href='/css/wdkTutorial.css'>

<script language="JavaScript"> var strContextPath = "/wdkTutorial";</script>

<script language="JavaScript" src="../wdk/env/events.js"></script><script language="JavaScript">setEventSourceName("wdkT utorial0")</script>

<script language="JavaScript" src="../wdk/env/url.js"></script>

<script language="JavaScript" src="../wdk/env/urlArguments.js"></script><script language="JavaScript" src="../wdk/component/history/history.js">< /script><script language="JavaScript" src="../wdkTutorial/eventHandlers.js"></script>

</head>

<frameset rows='30,*,0' border='0' framespacing='0' frameborder='no'><frame name='header' frameborder='no' marginwidth=0 marginheight=0 noresize scrolling='no'><frame name='view' frameborder='no' marginwidth=0 marginheight=0 noresize scrolling='auto'

src='/wdkTutorial/wdk/component/browse/browse.jsp'><frame name='actions' scrolling='no' frameborder='0'>

</frameset>

</html><%

// Release the lock on the page.wdkPageContext.releaseSession();

}catch(Exception err){

// Release the lock on the page.wdkPageContext.releaseSession();request.setAttribute ("ErrorDescription", "Tutorial application failed.");throw err;

}%>

Solution CodewdkTutorial1_finished.jsp

Page 48: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 48/60

A–4 Documentum Web Development Kit Tutorial

wdkTutorial1_finished.jsp

<%@ page contentType="text/html; charset=UTF-8" %><%@ page language="java" errorPage="/wdk/component/error/error.jsp"%><%@ page info="WDK 4.2 Tutorial Application" %>

<%@ page import="com.documentum.wc.env.jsp.DwJSPPageContext"%><%@ page import="com.documentum.wc.env.DwPageSet"%><%@ page import="com.documentum.wc.env.DwAppSession"%><%@ page import="com.documentum.wc.env.DwApplication"%>

<%// Establish the context for this page.

DwJSPPageContext wdkPageContext = new DwJSPPageContext(pageContext.getServletContext(), request,response, true);

try{

DwPageSet pageSet = wdkPageContext.getPageSet();DwApplication app = wdkPageContext.getApplication();

String strContextPath = request.getContextPath();

%>

<html>

<head><title>WDK 4.2 Tutorial Application</title>

<link rel='stylesheet' type='text/css' href='/css/wdkTutorialBase.css'><link rel='stylesheet' type='text/css' href='/css/wdkTutorial.css'>

<script language="JavaScript"> var strContextPath = "/wdkTutorial";</script>

<script language="JavaScript" src="../wdk/env/events.js"></script><script language="JavaScript">setEventSourceName("wdkTutori al1")</script>

<script language="JavaScript" src="../wdk/env/url.js"></script>

<script language="JavaScript" src="../wdk/env/urlArguments.js"></script><script language="JavaScript" src="../wdk/component/history/history.js"></script ><script language="JavaScript" src="../wdkTutorial/eventHandlers.js"></script>

</head>

<frameset rows='30,*,0' border='0' framespacing='0' frameborder='no'><frame name='header' frameborder='no' marginwidth=0 marginheight=0 noresize scrolling='no'

src='/wdkTutorial/wdkTutorial/toolbarTutorial_finished.jsp'><frame name='view' frameborder='no' marginwidth=0 marginheight=0 noresize scrolling='auto'

src='/wdkTutorial/wdk/component/browse/browse.jsp'><frame name='actions' scrolling='no' frameborder='0'>

</frameset>

</html><%

// Release the lock on the page.wdkPageContext.releaseSession();

}catch(Exception err){

// Release the lock on the page.wdkPageContext.releaseSession();request.setAttribute ("ErrorDescription", "Tutorial application failed.");throw err;

}%>

Solution CodetoolbarTutorial_finished.jsp

Page 49: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 49/60

Documentum Web Development Kit Tutorial A–5

toolbarTutorial_finished.jsp

<%@ page contentType="text/html; charset=UTF-8" %><%@ page language="java" errorPage="/wdk/component/error/error.jsp"%><%@ page info="WDK 4.2 Tutorial Application" %>

<%@ page import="com.documentum.wc.env.jsp.DwJSPPageContext"%><%@ page import="com.documentum.wc.env.DwAppSession"%><%@ page import="com.documentum.wc.widget.DwCustTool barInputButtonView"%>

<%// Establish the context for this page.

DwJSPPageContext wdkPageContext = new DwJSPPageContext(pageContext.getServletContext(), request,response, true);

DwCustToolbarInputButtonView custToolbarButtonView = new DwCustToolbarInputButtonView();

try{

DwAppSession appSession = DwAppSession.getAppSession();String strContextPath = request.getContextPath();

%>

<html>

<head><title>WDK 4.2 Tutorial Application</title><link rel='stylesheet' type='text/css' href='./css/wdkTutorialBase.css'><link rel='stylesheet' type='text/css' href='./css/wdkTutorial.css'>

<script language="JavaScript"> var strContextPath = "/wdkTutorial";</script>

<script language="JavaScript" src="../wdk/env/events.js"></script><script language="JavaScript">setEventSourceName("tool barTutorial")</script>

<script language="JavaScript" src="../wdk/env/url.js"></script><script language="JavaScript" src="../wdk/env/urlArguments.js"></script>

</head><body class="contentBackground" topmargin="0" leftmargin="10" rightmargin="0" bottommargin="0"

marginheight="0" marginwidth="0"><table width="100%" border="0" cellpadding="0" cellspacing="0" height="30"><tr>

<td align=middle width="20%"><%=custToolbarButtonView.generateEventButton("Docbase","viewDocbase", "", "")%></td><td align=middle width="20%"><%=custToolbarButtonView.generateEventButton("Inbox", "viewInbox", "", "")%></td><td align=middle width="20%"><%=custToolbarButtonView.generateEventButton("Logout", "logout", "", "")%></td>

</tr></table></body>

</html><%

// Release the lock on the page.wdkPageContext.releaseSession();

}catch(Exception err){

// Release the lock on the page.wdkPageContext.releaseSession();

request.setAttribute ("ErrorDescription", "Tutorial application failed.");

Solution CodetoolbarTutorial_finished.jsp

Page 50: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 50/60

A–6 Documentum Web Development Kit Tutorial

throw err;}

%>

Solution CodewdkTutorial2_finished.jsp

dkT t i l2 fi i h d j

Page 51: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 51/60

Documentum Web Development Kit Tutorial A–7

wdkTutorial2_finished.jsp

<%@ page contentType="text/html; charset=UTF-8" %><%@ page language="java" errorPage="/wdk/component/error/error.jsp"%><%@ page info="WDK 4.2 Tutorial Application" %>

<%@ page import="com.documentum.wc.env.jsp.DwJSPPageContext"%><%@ page import="com.documentum.wc.env.DwPageSet"%><%@ page import="com.documentum.wc.env.DwAppSession"%><%@ page import="com.documentum.wc.env.DwApplication"%>

<%// Establish the context for this page.

DwJSPPageContext wdkPageContext = new DwJSPPageContext(pageContext.getServletContext(), request,response, true);

try{

DwPageSet pageSet = wdkPageContext.getPageSet();DwApplication app = wdkPageContext.getApplication();

String strContextPath = request.getContextPath();

%>

<html>

<head><title>WDK 4.2 Tutorial Application</title>

<link rel='stylesheet' type='text/css' href='/css/wdkTutorialBase.css'><link rel='stylesheet' type='text/css' href='/css/wdkTutorial.css'>

<script language="JavaScript"> var strContextPath = "/wdkTutorial";</script>

<script language="JavaScript" src="../wdk/env/events.js"></script><script language="JavaScript">setEventSourceName("wdkT utorial2")</script>

<script language="JavaScript" src="../wdk/env/url.js"></script>

<script language="JavaScript" src="../wdk/env/urlArguments.js"></script><script language="JavaScript" src="../wdk/component/history/history.js">< /script><script language="JavaScript" src="../wdkTutorial/eventHandlers.js"></script>

<script language="JavaScript">

/** Handle viewDocbase event from Docbase button on toolbar */function eventHandler_viewDocbase( strSender, strFolderId){var strUrl = strContextPath + "/wdk/component/browse/browse.jsp";

strUrl = urlAddExclusiveParam(strUrl, "folderId", strFolderId);strUrl = urlMakeForcedReload(strUrl);window.frames.view.location.href = strUrl;setComponentFrame(window.frames.view.frames[1]);

}

/** Handle viewInbox event from Inbox button on toolbar */function eventHandler_viewInbox(){

var strUrl = strContextPath + "/wdk/component/inbox/inbox.jsp";strUrl = urlMakeForcedReload( strUrl );window.frames.view.location.href = strUrl;setComponentFrame(window.frames.view);

}

/** Handle logout event from Logout button on toolbar */function eventHandler_logout()

{

Solution CodewdkTutorial2_finished.jsp

t U l t C t tP th + "/ dk/ t/l t/l t j "

Page 52: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 52/60

A–8 Documentum Web Development Kit Tutorial

var strUrl = strContextPath + "/wdk/component/logout/logout.jsp";strUrl = urlMakeForcedReload(strUrl);

window.location.href = strUrl;

}

/** Handle resize of the browser window */function handleResize(){

if ( window.navigator.appName.toLowerCase() == "netscape" ){window.location.reload(false);}

}

</script>

</head>

<frameset rows='30,*,0' border='0' framespacing='0' frameborder='no' onResize='handleResize()'onLoad="setComponentFrame(window.frames.view.folderDetail)">

<frame name='header' frameborder='no' marginwidth=0 marginheight=0 noresize scrolling='no'src='/wdkTutorial/wdkTutorial/toolbarTutorial_finished.jsp'>

<frame name='view' frameborder='no' marginwidth=0 marginheight=0 noresize scrolling='auto'src='/wdkTutorial/wdk/component/browse/browse.jsp'>

<frame name='actions' scrolling='no' frameborder='0'></frameset>

</html><%

// Release the lock on the page.

wdkPageContext.releaseSession();}catch(Exception err){

// Release the lock on the page.wdkPageContext.releaseSession();request.setAttribute ("ErrorDescription", "Tutorial application failed.");throw err;

}%>

Solution CodewdkTutorial3_finished.jsp

wdkTutorial3 finished jsp

Page 53: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 53/60

Documentum Web Development Kit Tutorial A–9

wdkTutorial3_finished.jsp

<%@ page contentType="text/html; charset=UTF-8" %><%@ page language="java" errorPage="/wdk/component/error/error.jsp"%><%@ page info="WDK 4.2 Tutorial Application" %>

<%@ page import="com.documentum.wc.env.jsp.DwJSPPageContext"%><%@ page import="com.documentum.wc.env.DwPageSet"%><%@ page import="com.documentum.wc.env.DwAppSession"%><%@ page import="com.documentum.wc.env.DwApplication"%><%@ page import="com.documentum.wc.env.docbase.DwDoc baseTypedDictionary"%><%@ page import="com.documentum.wc.widget.docbase.Dw DocOpenLinkEvent"%>

<% // Establish the context for this page.DwJSPPageContext wdkPageContext = new DwJSPPageContext(pageContext.getServletContext(), request,

response, true);

try{

DwPageSet pageSet = wdkPageContext.getPageSet();DwApplication app = wdkPageContext.getApplication();

// Set up an events dictionary used for edit/view linksDwDocbaseTypedDictionary eventsDictionary = (DwDocbaseTypedDictionary)

app.get("Dictionary_Events");

if (eventsDictionary == null){

// Build and populate the events dictionary.eventsDictionary = new DwDocbaseTypedDictionary();eventsDictionary.put("dm_folder", "viewFolder");DwDocOpenLinkEvent docOpenLinkEvent = new DwDocOpenLinkEvent();eventsDictionary.put("dm_document", docOpenLinkEvent);app.put("Dictionary_Events", eventsDictionary);

}

// Set up a readonly version of the events dictionary used for view linksDwDocbaseTypedDictionary eventsDictionaryReadonly =

(DwDocbaseTypedDictionary)app.get("Dictionary_Events_Readonly");

if (eventsDictionaryReadonly == null){// Build and populate the readonly events dictionary.eventsDictionaryReadonly = new DwDocbaseTypedDictionary();eventsDictionaryReadonly.put("dm_folder", "viewFolder");DwDocOpenLinkEvent docOpenLinkEventReadonly = new DwDocOpenLinkEvent();docOpenLinkEventReadonly.setReadOnly(true);

eventsDictionaryReadonly.put("dm_document", docOpenLinkEventReadonly);app.put("Dictionary_Events_Readonly", eventsDictionaryReadonly);

}

String strContextPath = request.getContextPath();

%>

<html>

<head><title>WDK 4.2 Tutorial Application</title>

<link rel='stylesheet' type='text/css' href='/css/wdkTutorialBase.css'><link rel='stylesheet' type='text/css' href='/css/wdkTutorial.css'>

<script language="JavaScript"> var strContextPath = "/wdkTutorial";</script>

<script language="JavaScript" src="../wdk/env/events.js"></script><script language="JavaScript">setEventSourceName("wdkT utorial3")</script>

Solution CodewdkTutorial3_finished.jsp

<script language="JavaScript" src="../wdk/env/url.js"></script>

Page 54: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 54/60

A–10 Documentum Web Development Kit Tutorial

p g g p / / / j / p<script language="JavaScript" src="../wdk/env/urlArguments.js"></script><script language="JavaScript" src="../wdk/component/history/history.js"></script ><script language="JavaScript" src="../wdkTutorial/eventHandlers.js"></script>

<script language="JavaScript">

/** Handle viewDocbase event from Docbase button on toolbar */function eventHandler_viewDocbase( strSender, strFolderId){var strUrl = strContextPath + "/wdk/component/browse/browse.jsp";

strUrl = urlAddExclusiveParam(strUrl, "folderId", strFolderId);strUrl = urlMakeForcedReload(strUrl);window.frames.view.location.href = strUrl;setComponentFrame(window.frames.view.frames[1]);}

/** Handle viewInbox event from Inbox button on toolbar */function eventHandler_viewInbox(){

var strUrl = strContextPath + "/wdk/component/inbox/inbox.jsp";strUrl = urlMakeForcedReload( strUrl );window.frames.view.location.href = strUrl;setComponentFrame(window.frames.view);

}

/** Handle logout event from Logout button on toolbar */function eventHandler_logout(){

var strUrl = strContextPath + "/wdk/component/logout/logout.jsp";strUrl = urlMakeForcedReload(strUrl);

window.location.href = strUrl;}

/** Handle resize of the browser window */function handleResize(){

if ( window.navigator.appName.toLowerCase() == "netscape" ){window.location.reload(false);}

}

</script>

</head>

<frameset rows='30,*,0' border='0' framespacing='0' frameborder='no' onResize='handleResize()'onLoad="setComponentFrame(window.frames.view.folderDetail)">

<frame name='header' frameborder='no' marginwidth=0 marginheight=0 noresize scrolling='no'src='/wdkTutorial/wdkTutorial/toolbarTutorial_finished.jsp'>

<frame name='view' frameborder='no' marginwidth=0 marginheight=0 noresize scrolling='auto'src='/wdkTutorial/wdk/component/browse/browse.jsp'>

<frame name='actions' src='/wdkTutorial/wdk/action/actionDispatcherContain er.jsp'scrolling='no' frameborder='0'>

</frameset>

</html><%

// Release the lock on the page.wdkPageContext.releaseSession();

}catch(Exception err){

// Release the lock on the page.wdkPageContext.releaseSession();request.setAttribute ("ErrorDescription", "Tutorial application failed.");throw err;

}%>

Solution CodefolderContents.jsp

folderContents jsp

Page 55: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 55/60

Documentum Web Development Kit Tutorial A–11

folderContents.jsp

<%@ page contentType="text/html; charset=UTF-8" %><%@ page language="java" errorPage="/wdk/component/error/error.jsp"%><%@ page info="Documentum Web Development Kit 4.2" %><%//*****************************************************************************//*(c) Copyright Documentum, Inc. 2000-2001. All rights reserved.//* May not be used without prior written agreement signed//* by a Documentum corporate officer.//*****************************************************************************//* Projec t: WDK/ /* F il e: f ol de rC on ten ts .j sp

//* Description://*//* This page contains event handlers to update the folder header and folder//* body.//*//* Optional Request Parameters//* -------------------//* objectId Object ID of the folder to display contents//* currentpos Current viewing position of the folder contents. Defaults is 1//* pagesize Number of objects to display per page. Defaults to 10//*****************************************************************************%>

<%@ page import="java.util.Vector"%>

<%@ page import="com.documentum.fc.client.IDfClient"%><%@ page import="com.documentum.fc.client.DfClient"%><%@ page import="com.documentum.fc.common.IDfId"%><%@ page import="com.documentum.fc.common.DfId"%>

<%@ page import="com.documentum.wc.env.DwApplication"%><%@ page import="com.documentum.wc.env.DwAppSession"%><%@ page import="com.documentum.wc.env.jsp.DwJSPPageContext"%><%@ page import="com.documentum.wc.env.DwPageSet"%>

<%@ page import="com.documentum.wc.env.docbase.DwDoc baseTypedDictionary"%><%@ page import="com.documentum.wc.widget.DwTableView"%>

<%@ page import="com.documentum.wc.widget.docbase.Dw FolderContentListModel"%><%@ page import="com.documentum.wc.widget.docbase.Dw ObjectNameCellRenderer"%><%@ page import="com.documentum.wc.widget.docbase.Dw IconCellRenderer"%><%@ page import="com.documentum.wc.widget.docbase.Dw ObjectSelectCellRenderer"%>

<%@ page import="com.documentum.wc.nls.DwNLSwdkComponentContents"%><%@ page import="com.documentum.wc.nls.DwNLSDateFormats"%><%@ page import="com.documentum.wc.util.IDwStyleSheetConstants"%>

<%// Establish the context for this page.DwJSPPageContext wdkPageContext = new DwJSPPageContext(pageContext.getServletContext(), request,response, true);

// Get lookup objectDwNLSwdkComponentContents lookup = new DwNLSwdkComponentContents();DwNLSDateFormats dfLookup = new DwNLSDateFormats();

try{

// Establish context.DwPageSet pageSet = wdkPageContext.getPageSet();

// Parse URL arguments.String objectId = request.getParameter("objectId");

String strPageSize = "10";

String strCurrentPos = "0";

Solution CodefolderContents.jsp

String strHasNextPage = "false";St i t H P i P "f l "

Page 56: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 56/60

A–12 Documentum Web Development Kit Tutorial

String strHasPreviousPage = "false";int nTotalItems = 0;

String strDocbaseName = "";String strUser = "";

if((objectId != null) &&(objectId.length() > 0)){

IDfClient client = DfClient.getLocalClient();IDfId idobj = new DfId(objectId);strDocbaseName = client.getDocbaseNameFromId(idobj);

// Set the current docbaseDwAppSession appSession = wdkPageContext.acquireSession(strDocbaseName);if (appSession == null) return;DwPageSet appPageSet = wdkPageContext.getPageSet();

// get user name for this docbasestrUser = appSession.getDocbaseSession().getDfSession().get LoginUserName();

// create a folder contents model(create it every time)DwFolderContentListModel folderContentsModel

=(DwFolderContentListModel)pageSet.create("folderContentsModel",DwFolderContentListModel.class.getName());

folderContentsModel.setFolderId(objectId);

// create a list to keep track of multiple selections(list of object id strings)Vector multipleSelectionList =(Vector) pageSet.create("multipleSelectionList",

Vector.class.getName());

// get number of folder content items.nTotalItems = folderContentsModel.getCountOfItemsInFolder();

// get the current viewing position in the folder contentsint nCurrentPos = -1;strCurrentPos = request.getParameter("currentpos");if(strCurrentPos != null && strCurrentPos.length() > 0){

nCurrentPos = Integer.parseInt(strCurrentPos);}else{

strCurrentPos = "1";

nCurrentPos = 1;}

// if there are no folder content items display the current position as 0.if(nTotalItems == 0){

strCurrentPos = "0";nCurrentPos = 0;

}

// determine the page size to use, 10 by default.strPageSize = request.getParameter("pagesize");if(strPageSize == null || strPageSize.length() == 0){

strPageSize =(String) pageSet.get("selectedSize");if(strPageSize == null || strPageSize.length() == 0){

strPageSize = "10";}

}

int nPageSize = Integer.parseInt(strPageSize);

// save the page size setting.pageSet.put("selectedSize", strPageSize);

folderContentsModel.setPageSize(nPageSize);

Solution CodefolderContents.jsp

if(nPageSize >= nTotalItems){

Page 57: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 57/60

Documentum Web Development Kit Tutorial A–13

{strCurrentPos = "1";nCurrentPos = 1;

}

// set the current position in the folder contents modelfolderContentsModel.setCurrentPosition(nCurrentPos);

// find out if there are next and previous pages.boolean fHasNextPage = folderContentsModel.hasNextPage();if(fHasNextPage){

strHasNextPage = "true";}boolean fHasPreviousPage = folderContentsModel.hasPreviousPage();if(fHasPreviousPage)

{strHasPreviousPage = "true";

}

// Define useful format stringsString strLockIcon = "{LockIcon(Property(r_lock_owner))}";String strIcon =

"{Icon(Property(r_object_id),Property(r_object_type),Property(a_content_type),16,closed,Property(r_is_virtual_doc),Property(r_link_cnt),Property(r_assembled_from_id),Property(r_has_frzn_assembly))}";

String strModifiedDate = "{Date(Property(r_modify_date),'"+dfLookup.getString(DwNLSDateFormats.DF_BASIC_DAY_MONTH_YEAR)+"')}";

String strLockedBy = "{r_lock_owner}";String strObjType = "{r_object_type}";

// define the object selection column (checkboxes)DwObjectSelectCellRenderer objectSelectRenderer = new DwObjectSelectCellRenderer();objectSelectRenderer.setEvent("objectSelectedInFolderBody");objectSelectRenderer.setEnableMultipleSelect(true);

// Define the selectable icon columnDwIconCellRenderer iconRenderer = new DwIconCellRenderer();iconRenderer.setEventDictionary(

(DwDocbaseTypedDictionary) appPageSet.get ( "Dictionary_Events" ) );iconRenderer.setIcon(strIcon);

// Define the name columnDwObjectNameCellRenderer nameRenderer = new DwObjectNameCellRenderer();

nameRenderer.setEventDictionary((DwDocbaseTypedDictionary) appPageSet.get ( "Dictionary_Events" ) );

nameRenderer.setShowFormat(true);nameRenderer.setShowSubject(true);

// create a table view for the contents (create it every time but store in session scope// for folderColumnHeaders and folderbody frames)if ( pageContext.getAttribute("folderContentsView", PageContext.SESSION_SCOPE) != null ){

session.removeAttribute("folderContentsView");}

%><jsp:useBean id="folderContentsView" class="com.documentum.wc.widget.DwTableView"

scope="session" /><jsp:setProperty name="folderContentsView" property="model" value="<%= folderContentsModel %>"

/><jsp:setProperty name="folderContentsView" property="rowAlignment" value="<%=

DwTableView.ROW_ALIGN_MIDDLE %>" /><jsp:setProperty name="folderContentsView" property="rowDividerVisibility" value="true" />

<%folderContentsView.addRenderedColumn("objectSelect", objectSelectRenderer, "5%");folderContentsView.addFormattedColumn("LockIcon", "", strLockIcon, "5%");folderContentsView.addRenderedColumn("Icon", iconRenderer, "5%");folderContentsView.addRenderedColumn("Name",

lookup.getString(DwNLSwdkComponentContents.MSG_NAME) , nameRenderer, "40%");folderContentsView.addFormattedColumn("Type", "Type", strObjType, "15%");folderContentsView.addFormattedColumn("ModificationDate",

lookup.getString(DwNLSwdkComponentContents.MSG_LAST_ MODIFIED), strModifiedDate, "15%");

Solution CodefolderContents.jsp

folderContentsView.addFormattedColumn("LockOwner",lookup.getString(DwNLSwdkComponentContents.MSG LOCK OWNER), strLockedBy, "15%");

Page 58: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 58/60

A–14 Documentum Web Development Kit Tutorial

oo up.getSt g( S d Co po e tCo te ts. SG_ OC _O ), st oc ed y, 5% );}

String strContextPath = request.getContextPath();

// url to reload this pageString strFolderContentsUrl = strContextPath + "/wdk/component/contents/folderContents.jsp";

// url to folderPrevNextString strPrevNextUrl = pageSet.makeUrl(strContextPath + "/wdk/component/contents/

folderPrevNext.jsp?currentpos=" + strCurrentPos + "&totalnumitems=" + nTotalItems + "&hasnextpage=" +strHasNextPage + "&haspreviouspage=" + strHasPreviousPage);

// Unlock the pagewdkPageContext.releaseSession();

%>

<html><head>

<!--************************************************************************--><!--*(c) Copyright Documentum, Inc. 2000-2001. All rights reserved. --><!--* May not be used without prior written agreement signed --><!--* by a Documentum corporate officer. --><!--************************************************************************--><title><%=lookup.getString(DwNLSwdkComponentContents.MSG_FOLDER_CONTENTS)%></title><link rel='stylesheet' type='text/css' href='<%=strContextPath + "/" +

DwApplication.getApplication().getStyleSheet("Branding.StyleSheets.Framework",IDwStyleSheetConstants.STYLE_BASIC)%>'>

<script language="JavaScript" src="<%= strContextPath %>/wdk/env/events.js"></script><script language="JavaScript">setEventSourceName("folderContents")</script ><script language="JavaScript" src="<%= strContextPath %>/wdk/env/url.js"></script><script language="JavaScript">

/*** Handle an object selection in the folder header** @param strSelectedObjectId the object id of the selected object*/

function eventHandler_objectSelectedInFolderHeader(sender, strSelectedObjectId){

// update folder body in case it previously had an object selectionvar strUrl = '<%=pageSet.makeUrl(strContextPath + "/wdk/component/contents/

folderBody.jsp")%>';strUrl = urlAddExclusiveParam(strUrl, "objectId", "<%=objectId%>");strUrl = urlAddExclusiveParam(strUrl, "pagesize", "<%=strPageSize%>");

strUrl = urlAddExclusiveParam(strUrl, "currentpos", "<%=strCurrentPos%>");strUrl = urlMakeForcedReload(strUrl);window.body.location.replace(strUrl);

// update menu area with menu for selected objectvar strUrl2 = '<%=pageSet.makeUrl(strContextPath + "/wdk/component/contents/

folderHeader.jsp")%>';strUrl2 = urlAddExclusiveParam(strUrl2, "folderId", "<%=objectId%>");strUrl2 = urlAddExclusiveParam(strUrl2, "menuObjectId", strSelectedObjectId);strUrl2 = urlMakeForcedReload(strUrl2);window.header.location.replace(strUrl2);

}

/**

* Handle an object selection in the folder body** @param strSelectedObjectId the object id of the selected object*/

function eventHandler_objectSelectedInFolderBody(sender, strSelectedObjectId){

// update folder header in case it previously had an folder object selection// update menu area with menu for selected objectvar strUrl = '<%=pageSet.makeUrl(strContextPath + "/wdk/component/contents/

folderHeader.jsp")%>';strUrl = urlAddExclusiveParam(strUrl, "folderId", "<%=objectId%>");strUrl = urlAddExclusiveParam(strUrl, "menuObjectId", strSelectedObjectId);strUrl = urlMakeForcedReload(strUrl);

window.header.location.replace(strUrl);

Solution CodefolderContents.jsp

}

Page 59: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 59/60

Documentum Web Development Kit Tutorial A–15

/*** Handle change in the page size to show at one time** @param strPageSize new page size*/

function eventHandler_pageSize(sender, strPageSize){

// reload folder contents frame set with new page sizevar strUrl = "<%=pageSet.makeUrl(strFolderContentsUrl)%>";strUrl = urlAddExclusiveParam(strUrl, "objectId", "<%=objectId%>");strUrl = urlAddExclusiveParam(strUrl, "currentpos", "<%=strCurrentPos%>");strUrl = urlAddExclusiveParam(strUrl, "pagesize", strPageSize);strUrl = urlMakeForcedReload(strUrl);window.location.replace(strUrl);

}

/*** Show next page of folder contents** @param strNewPos new current pos when go to next page*/

function eventHandler_nextPage(sender, strNewPos){

// reload folder contents frame set with new current posvar strUrl = "<%=pageSet.makeUrl(strFolderContentsUrl)%>";strUrl = urlAddExclusiveParam(strUrl, "objectId", "<%=objectId%>");strUrl = urlAddExclusiveParam(strUrl, "pagesize", "<%=strPageSize%>");strUrl = urlAddExclusiveParam(strUrl, "currentpos", strNewPos);strUrl = urlMakeForcedReload(strUrl);window.location.replace(strUrl);

}

/*** Shows the previous page of folder contents** @param strNewPos new current pos when go to previous page*/

function eventHandler_previousPage(sender, strNewPos){

// reload folder contents frame set with new current posvar strUrl = "<%=pageSet.makeUrl(strFolderContentsUrl)%>";strUrl = urlAddExclusiveParam(strUrl, "objectId", "<%=objectId%>");

strUrl = urlAddExclusiveParam(strUrl, "pagesize", "<%=strPageSize%>");strUrl = urlAddExclusiveParam(strUrl, "currentpos", strNewPos);strUrl = urlMakeForcedReload(strUrl);window.location.replace(strUrl);

}

// update user / docbase name status feedbackfireGlobalEvent("updateUserDocbaseStatus", "<%=strUser%>", "<%=strDocbaseName%>");

</script><%

if((objectId == null) ||(objectId.length() == 0)){

%><!-- If a specific objectId wasn't given, display a blank page and -->

<!-- send out a request to see if anyone knows what should be --><!-- shown. The setTimeout is important in order to avoid getting an --><!-- IE "spinning globe" problem. --><script language='JavaScript'>

setTimeout('fireGlobalEvent("announceSelect edFolder")', 100);</script>

</head><frameset rows='*' framespacing='0' border="0" frameborder='no'>

<frame noresize scrolling='no'src="<%= strContextPath %>/wdk/component/background/contentBackground.jsp">

</frameset><%

}

else

Solution CodefolderContents.jsp

{%>

/h d

Page 60: Wdk Tutorial 42

5/12/2018 Wdk Tutorial 42 - slidepdf.com

http://slidepdf.com/reader/full/wdk-tutorial-42-55a35a4ba3db1 60/60

A–16 Documentum Web Development Kit Tutorial

</head><!-- Generate a header and body frameset to show the folder contents. -->

<frameset rows='110,*,35' border='0' framespacing='0' frameborder='no'><frame name='header' frameborder='no' marginwidth=0 marginheight=0 noresize scrolling='no'

src='<%=pageSet.makeUrl(strContextPath + "/wdk/component/contents/folderHeader.jsp?folderId=" + objectId)%>'>

<frame name='body' frameborder='no' marginwidth=0 marginheight=0 noresize scrolling='auto'src='<%=pageSet.makeUrl(strContextPath + "/wdk/component/contents/folderBody.jsp")%>'>

<frame name='prevNext' frameborder='no' marginwidth=0 marginheight=0 noresize scrolling='no'src='<%=strPrevNextUrl%>' >

</frameset><%

}%></html>

<%}catch(Exception err){

// Unlock the pagewdkPageContext.releaseSession();request.setAttribute("ErrorDescription",

lookup.getString(DwNLSwdkComponentContents.MSG_FOLDER_CONTENTS_FAILED));throw err;

}%>