wdk tutorial 42

60
Documentum Web Development Kit Tutorial Version 4.2 April 2001 DOC3-WDKTUT-0401

Upload: alinapanait

Post on 24-Apr-2015

141 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Wdk Tutorial 42

Documentum Web Development Kit Tutorial

Version 4.2

April 2001

DOC3-WDKTUT-0401

*DOC3-WDKTUT-0401*

Page 2: Wdk Tutorial 42

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™, Documentum ftpIntegrator™, Documentum RightSite®, Documentum Administrator™, Documentum Developer Studio™, Documentum Web Development Kit™, Documentum Web Gear™, Documentum WebCache™, Documentum ContentCaster™, AutoRender Pro™, Documentum iTeam™, Documentum Reporting Gateway™, Documentum Content Personalization Services™, Documentum Site Delivery Services™, Documentum Content Authentication Services™, Documentum Dynamic Content Assembler™, Documentum DocControl Manager™, Documentum Corrective Action Manager™, Documentum eConnector™ for BEA WebLogic® (BEA and WebLogic are registered 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®, Documentum SmartSpace®, and Documentum ViewSpace® are trademarks or registered trademarks of Documentum, Inc. in the United States and throughout the world. All other company and product names are used for identification purposes only and may be trademarks of their respective owners.

Page 3: Wdk Tutorial 42

C O N T E N T S

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-3Fitting 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-10Enable 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-2Extra investigation: Add a menu item. . . . . . . . . . . . . . . . . . . . . . . . . 4-3

Add a Column to a View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3Before 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-2Display the custom properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2

Documentum Web Development Kit Tutorial iii

Page 4: Wdk Tutorial 42

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-9folderContents.jsp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-11

iv Documentum Web Development Kit Tutorial

Page 5: Wdk Tutorial 42

Documentum Web Development Kit Tutorial

P R E F A C E

Purpose of the Manual

This manual provides an introduction to the basic features of the Documentum Web Development Kit (WDK) using both conceptual information 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:

■ Installation and Release Notes

■ Online Help

■ API Documentation (Javadoc)

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

Intended Audience

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

■ Java Servlet Specification, version 2.2

■ JavaServer Pages Specification, version 1.1

Organization of the Manual

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

v

Page 6: Wdk Tutorial 42

Conventions

This manual uses the following conventions:

Chapter Contents

Chapter 1, What is the Web Development Kit?

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

Chapter 2, JavaServer Pages in the WDK

Describes how JavaServer Pages are used to drive WDK-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 WDK Components

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

Chapter 5, Displaying Properties of a Custom Object Type

Contains step-by-step examples of how to display the properties of a custom object type in the properties page 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 a value, 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 than once.

vi Documentum Web Development Kit Tutorial

Page 7: Wdk Tutorial 42

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 hypertext links. Table of contents page numbers are also clickable links, but they appear in 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 only work if the PDF files are all in the same directory and have the same file names 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 for more information.

Bug Lists and Documentation Online

Customers with a software support agreement can read our product documentation and, after commercial release of a product, view lists of fixed bugs on our Technical Support web pages. To view this information you must apply 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.

Documentum Web Development Kit Tutorial vii

Page 8: Wdk Tutorial 42

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 list includes all customer-related bugs that the current release corrects. For information about obtaining access to the Technical Support area of the Web site, refer to “Applying for Access” on page vii. You must have Adobe Acrobat Reader 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 product documentation at documentum.com. To view the documentation, you must have a user name and password, and Adobe Acrobat Exchange or Acrobat Reader 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.

viii Documentum Web Development Kit Tutorial

Page 9: Wdk Tutorial 42

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 paper manuals. To place an order, call the Documentation Order Line at (925) 600-6666. You can pay with a purchase order, check, or credit card.

Documentum Web Development Kit Tutorial ix

Page 10: Wdk Tutorial 42

x Documentum Web Development Kit Tutorial

Page 11: Wdk Tutorial 42

1

What is the Web Development Kit? 1

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

This chapter contains the following sections:

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

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

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

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

■ “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, HTML pages, JAR files, and any other resources that can be bundled together and deployed as a standalone application on a Java application server. Users launch and use the web application in a web browser.

With WDK, your web applications can include document management features such as checkout and checkin, workflows, lifecycles, and virtual documents.

The WDK consists of the following tools:

■ Java classes that conduct Docbase operations. These classes include:

Documentum Web Development Kit Tutorial 1–1

Page 12: Wdk Tutorial 42

What is the Web Development Kit?Compliance With Java Specifications

❒ Command classes that conduct Docbase operations.

❒ Content transfer classes that manage checkout, checkin, import, and export of documents and XML between clients and a Docbase. The content transfer classes install and use content transfer applets in the client browser.

The command classes and content transfer classes rely on the Documentum Foundation Classes (DFC) to provide basic Docbase functionality.

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

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

■ JavaServer Pages that provide Documentum functionality by instantiating objects 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 server and control its presentation and behavior on the client. You can customize these JSP pages as desired for your application.

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

■ Services that allow you to configure your application and its components with XML, which reduces the amount of time and programming expertise required to develop your application.

■ API documentation (Javadocs) for the WDK and DFC classes, and online help (Javahelp) that contains documentation for the JavaServer pages and application development tasks.

Compliance With Java Specifications

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

■ Java Servlet Specification, version 2.2

■ JavaServer Pages Specification, version 1.1

1–2 Documentum Web Development Kit Tutorial

Page 13: Wdk Tutorial 42

What is the Web Development Kit?Dependencies on Other Software

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:

■ An HTTP server, which can reside on your development machine or on a separate machine.

■ A Java application server, which communicates with the HTTP server and typically (but not always) resides on the same machine as the HTTP server. The Java application server must support both the Java Servlet Specification, version 2.2, and the JavaServer Pages Specification, version 1.1.

■ A Documentum eContent server and Docbase, which is accessed through a Docbroker and can reside on any machine.

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

To conduct the exercises in this tutorial, you need:

■ The server software described above.

■ A text editor on your development machine that reads and writes plain ASCII by default and does not reformat or automatically wrap lines that you type. You can optionally use a J2EE-compliant integrated development environment (IDE) for Java on your development machine.

Fitting the Pieces Together

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

Documentum Web Development Kit Tutorial 1–3

Page 14: Wdk Tutorial 42

What is the Web Development Kit?Fitting the Pieces Together

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 an application on your production server.

Deployment procedures differ among application servers. For deployment details, consult the documentation for your application server. For a detailed description of web applications and the WAR file format, refer to the Java Servlet 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 the application’s start page. Figure 1-1 illustrates these steps.

1. User launches a web browser and requests the application’s start page, for example, http://appserver/appname/wdkSpace/wdkSpace.jsp. Appserver is the name of your application server and appname is the name of your WDK-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 an HTML page, and it passes the request to the Java application server.

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

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

6. The Java application server sends the response (HTML + JavaScript) to the HTTP 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 the response.

1–4 Documentum Web Development Kit Tutorial

Page 15: Wdk Tutorial 42

What is the Web Development Kit?Fitting the Pieces Together

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

W eb server machine (hardware)

HTTP server (software)

Client machine (hardware)

Browser (software)

Java application server (software)

Get the JSP file

Compile the JSPinto a servlet

Run the servlet; generateHTML/JavaScript

Server machine(hardware)

Docbase

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

W AR file

wdkSpace.jsp

Java Virtual Machine(software)

1

2

3

5

6

7

4

Documentum Web Development Kit Tutorial 1–5

Page 16: Wdk Tutorial 42

What is the Web Development Kit?Summary

Summary

■ The WDK is a set of tools with which you can build a web application that has Documentum functionality.

■ A web application is a collection of pages, classes, and any other resources that constitute a standalone application on a Java application server. Web applications are described in the Java Servlet Specification, version 2.2.

■ To develop and deploy a web application with WDK, you need an HTTP server, a Java application server, and a Documentum eContent Server and Docbase.

1–6 Documentum Web Development Kit Tutorial

Page 17: Wdk Tutorial 42

2

JavaServer Pages in the WDK 2

WDK functionality is presented primarily via JavaServer Pages, also known as JSP pages. (The term “JSP pages” seems redundant, but this is the terminology used in the JavaServer Pages Specification.) You can think of a JSP page as the source code for a servlet whose sole function is to produce an HTTP response object 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 of objects in the Docbase. The request goes to the HTTP server, which passes it to the application server. The application server compiles the requested JSP into a servlet (in many cases, the JSP is already compiled) and runs the servlet using the information provided with the request. The output from the servlet is the response, which consists of HTML and JavaScript. This response is returned to the browser and displayed.

Detailed information on servlets and JSP pages is available in Java Servlet Specification, 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 the following sections:

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

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

■ “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:

Documentum Web Development Kit Tutorial 2–1

Page 18: Wdk Tutorial 42

JavaServer Pages in the WDKAnatomy of a Typical WDK Server Page

<%@ 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 use the following classes:

■ com.documentum.wc.env.jsp.DwJSPPageContext

DwJSPPageContext is the page context object, which binds to the WDK namespace and reads the application configuration file. Use the page context 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).

■ com.documentum.wc.env.DwPageSet

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

■ com.documentum.wc.env.DwAppSession

DwAppSession is the web application session object. The application session checks the login requirements. If the user has no active session, the login page specified in the config.xml for the application is presented. To create or acquire a DwAppSession, use the method DwJSPPageContext.acquireSession.

■ com.documentum.wc.env.DwApplication

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

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:

2–2 Documentum Web Development Kit Tutorial

Page 19: Wdk Tutorial 42

JavaServer Pages in the WDKHTML Generated by JSP

■ events.js, which contains functions that support cross-frame events and manage the propagation of events.

■ url.js, which contains functions that add, remove, and retrieve URL arguments.

■ history.js, which contains functions that that are used by the event handlers in 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 block and 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 is created from the JSP page) consists of HTML and JavaScript that is returned to the web browser. This HTML and JavaScript has two sources:

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

■ Dynamic HTML and JavaScript, which are generated by the Java code in the 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 is returned to the browser. As far as the web browser is concerned, it is simply static HTML and JavaScript to process and display.

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

Handling Errors

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

Documentum Web Development Kit Tutorial 2–3

Page 20: Wdk Tutorial 42

JavaServer Pages in the WDKHandling Errors

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 free session 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:

■ Catch the exception.

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

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

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

2–4 Documentum Web Development Kit Tutorial

Page 21: Wdk Tutorial 42

3

Developing 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 to log in and out of a Docbase, view your Inbox, and browse Docbase contents.

The chapter contains the following sections:

■ “Prepare Your Environment” on page 3-1

■ “Plan the Application” on page 3-2

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

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

■ “Create a Page” on page 3-5

■ “Add the Toolbar” on page 3-7

■ “Add Event Handlers” on page 3-10

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

■ “Extra Investigation: Use Cascading Style Sheets to Customize the Look of Your 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 JSP pages 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 Documentum eContent server and Docbases are installed and configured. For more information, see “Dependencies on Other Software” on page 1-3. Although these software packages are not part of the WDK, the WDK relies on their correct configuration.

Documentum Web Development Kit Tutorial 3–1

Page 22: Wdk Tutorial 42

Developing an ApplicationPlan the Application

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 configuration of the WDK. The Documentum Web Development Kit Installation and Release Notes contains critical information for configuring WDK. Follow the instructions closely to deploy the wdkSpace sample application and test the installation.

Plan the Application

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

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

3–2 Documentum Web Development Kit Tutorial

Page 23: Wdk Tutorial 42

Developing an ApplicationCreate the Application Directory

Create the Application Directory

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

Before you begin, ensure that the wdkSpace sample application is deployed in exploded directory format. In exploded directory format, the .war file is expanded as a collection of files that use a directory structure. For instructions on deploying the wdkSpace sample application, see the Documentum Web Development Kit Installation and Release Notes.

Documentum Web Development Kit Tutorial 3–3

Page 24: Wdk Tutorial 42

Developing an ApplicationCreate the Application Directory

➤ To create the directory for the wdkTutorial application:

1. Create a new, empty web application and corresponding root directory named wdkTutorial. How you create a new web application and root directory depends on your application server and operating system. For specific instructions, refer to the documentation for your application server.

2. Copy the contents of the deployed wdkSpace sample application directory to your new wdkTutorial application directory. (Ensure that you copy from the deployed wdkSpace sample application, not the WDK installation location.) Your wdkTutorial application directory now has the following structure:

\wdkTutorialconfig.dtdconfig.xml\wdk\wdkSpace\WEB-INF

3. Rename the wdkSpace directory to wdkTutorial. This wdkTutorial subdirectory will contain the files that are specific to the wdkTutorial application. Your wdkTutorial application directory now has the following structure:

\wdkTutorialconfig.dtdconfig.xml\wdk\wdkTutorial\WEB-INF

4. Navigate to the css directory below the wdkTutorial directory. Rename the two files as follows:

■ Rename wdkSpace.css to wdkTutorial.css.

■ Rename wdkSpaceBase.css to wdkTutorialBase.css.

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

3–4 Documentum Web Development Kit Tutorial

Page 25: Wdk Tutorial 42

Developing an ApplicationLocate the Tutorial Files

Locate the Tutorial Files

The files that you will use in this tutorial are packaged in the archives WDK_Tutorial_42_Files.zip (for Windows) and WDK_Tutorial_42_Files.tar.gzip (for Unix). These archives reside in the docs directory 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 by adding a title, style sheet references, and a frameset to an existing skeletal WDK server page.

If you encounter problems during the procedure, refer to the solution page wdkTutorial0_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 to most 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” (omit the quotes).

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

Documentum Web Development Kit Tutorial 3–5

Page 26: Wdk Tutorial 42

Developing an ApplicationCreate a Page

<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 application and renamed. They specify styles for both standard HTML elements and for the 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 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>

This frameset contains three frames:

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

■ A view frame that displays the WDK page browse.jsp. This page contains two frames of its own: a frame on the left that allows you to display multiple Docbase hierarchies as a single tree, and a frame on the right that displays the contents of the cabinets and folders in a Docbase.

■ An actions frame that you will use in a subsequent section. The actions frame 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 on the left and a list of available docbases on the right. Your list of available Docbases 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 log out.

3–6 Documentum Web Development Kit Tutorial

Page 27: Wdk Tutorial 42

Developing an ApplicationAdd the Toolbar

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 the source for the header frame in the page wdkTutorial0.jsp, and save it as wdkTutorial1.jsp.

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

➤ To create the toolbar page:

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

2. In the page import section, remove the imports of DwPageSet and DwApplication. 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 buttons will be created.

Documentum Web Development Kit Tutorial 3–7

Page 28: Wdk Tutorial 42

Developing an ApplicationAdd the Toolbar

3. To create the view that will generate the toolbar buttons, add the following line just before the try block:

DwCustToolbarInputButtonView custToolbarButtonView = newDwCustToolbarInputButtonView();

4. Remove the following lines from the try block. These lines are not required by the 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 style sheets.

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 contain the 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","viewDocbase", "", "")%></td><td align=middle width="20%"><%=custToolbarButtonView.generateEventButton("Inbox", "viewInbox", "", "")%>

3–8 Documentum Web Development Kit Tutorial

Page 29: Wdk Tutorial 42

Developing an ApplicationAdd the Toolbar

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

</tr>

Each toolbar button is created with the method DwCustToolbarInputButtonView.generateEventButton, which takes four parameters: the button label, the event name, and two optional parameters to pass to the event.

9. Save toolbarTutorial.jsp and view it in a browser. (The URL is http://localhost/wdkTutorial/wdkTutorial/toolbarTutorial.jsp, replacing localhost with 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 to wdkTutorial1.

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=0noresize scrolling='no'src='/wdkTutorial/wdkTutorial/toolbarTutorial.jsp'>

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

Documentum Web Development Kit Tutorial 3–9

Page 30: Wdk Tutorial 42

Developing an ApplicationAdd Event Handlers

Add Event Handlers

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

If you encounter problems during the procedure, refer to the solution page wdkTutorial2_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 to wdkTutorial2.

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 the viewDocbase event. This event is fired by the Docbases button in the toolbar page.

3–10 Documentum Web Development Kit Tutorial

Page 31: Wdk Tutorial 42

Developing an ApplicationAdd Event Handlers

/** 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 viewInbox event. 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 ensures correct 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)">

Documentum Web Development Kit Tutorial 3–11

Page 32: Wdk Tutorial 42

Developing an ApplicationEnable Actions on Docbase Contents

The onResize parameter ensures correct behavior when the browser window is resized in Netscape. The onLoad parameter ensures that WDK components (the login page, for example) are displayed in the frame on the right in the window. This is the folderDetail frame in browse.jsp, which resides 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 your Documentum Inbox.

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

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 can view, edit, and conduct other standard Documentum operations on the documents in a Docbase. You will start with wdkTutorial2.jsp, set up an events dictionary, load the WDK action dispatcher page into the invisible frame, and save the page as wdkTutorial3.jsp.

If you encounter problems during the procedure, refer to the solution page wdkTutorial3_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.DwDocOpenLinkEvent"%>

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

3–12 Documentum Web Development Kit Tutorial

Page 33: Wdk Tutorial 42

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

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 parameter that specifies actionDispatcherContainer.jsp:

<frame name='actions' src='/wdkTutorial/wdk/action/actionDispatcherContainer.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, and choose View from the drop-down menu.

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

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

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

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

■ Custom style classes that you create for your application.

Documentum Web Development Kit Tutorial 3–13

Page 34: Wdk Tutorial 42

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

■ Style classes that are specific to WDK. Many of the widgets and UI elements in WDK use their own custom style classes. These WDK style classes are described in the “Custom Styles” section of the WDK Online Help.

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

Additionally, you can use the Branding section in the file config.xml to override WDK styles. For details, search for Branding in the WDK Online Help.

3–14 Documentum Web Development Kit Tutorial

Page 35: Wdk Tutorial 42

4

Customizing WDK Components 4

This chapter describes two common ways to customize WDK components:

■ Editing XML configuration files.

■ Using methods provided by WDK classes.

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

This chapter contains the following sections:

■ “Modify a Menu” on page 4-1

■ “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-down menu 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 by making simple edits to the XML files in the WDK configuration folder.

In this section, you will remove three items from the menu. An “extra investigation” 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 in to 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

Documentum Web Development Kit Tutorial 4–1

Page 36: Wdk Tutorial 42

Customizing WDK ComponentsModify a Menu

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 file document_menus.xml, and save this backup copy in a location outside of the config directory.

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

3. Remove the following lines from the file. These are the lines that correspond to 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 in the Docbase, and select a document. Click the drop-down menu above the list of documents and examine the available choices. You no longer see the items Send To, Start Workflow, and Attach Document Lifecycle.

4–2 Documentum Web Development Kit Tutorial

Page 37: Wdk Tutorial 42

Customizing WDK ComponentsAdd a Column to a View

Extra investigation: Add a menu item

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

■ document_actions.xml specifies the possible actions to perform on a document.

■ 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 in document_actions.xml.

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

Add a Column to a View

To display a list of documents in a cabinet or folder, the server pages in WDK use 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 that displays the object type.

Before you begin

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

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

Documentum Web Development Kit Tutorial 4–3

Page 38: Wdk Tutorial 42

Customizing WDK ComponentsAdd a Column to a View

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

Add the column to the view

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

➤ To add the Type column to the view:

1. Open the wdk directory below the main wdkTutorial directory, open the component 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 the class 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 in folderContentsView. In the next step, you will add a line that specifies the new Type 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 strObjType = "{r_object_type}";

4–4 Documentum Web Development Kit Tutorial

Page 39: Wdk Tutorial 42

Customizing WDK ComponentsAdd a Column to a View

7. Save folderContents.jsp.

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

Documentum Web Development Kit Tutorial 4–5

Page 40: Wdk Tutorial 42

Customizing WDK ComponentsAdd a Column to a View

4–6 Documentum Web Development Kit Tutorial

Page 41: Wdk Tutorial 42

5

Displaying Properties of a Custom Object Type 5

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

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

■ “Extra Investigation: Searching for Properties of a Custom Object Type” on page 5-3

This chapter assumes that your Docbase already contains a custom object type with custom properties. Typically you use Documentum Developer Studio to create custom types and properties.

Display Custom Properties of a Custom Object Type

In WDK, when you display the properties of a selected document from the Docbase, you see the values for a default set of properties for the generic object type dm_document. If the document is of a custom object type, you do not see values for any of the custom properties that are associated with the custom object type. To display values for the properties of a custom object type, 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 custom document type in your Docbase. You can use any custom object type that resides in your Docbase.

Documentum Web Development Kit Tutorial 5–1

Page 42: Wdk Tutorial 42

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

Before you begin

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

■ The name of the object type.

■ The names two editable properties to display.

Open wdkTutorial3.jsp (or the solution file wdkTutorial3_finished.jsp). Log in to a Docbase and open a folder or cabinet in the Docbase that contains a document of your custom type. Select the document, and then choose Properties from the menu. You see properties for the dm_document type, but you 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 then open the config directory. Make a copy of the file document_properties.xml and name it customtype_properties.xml. (The name does not matter, but the extension 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 custom properties to this list.

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

■ 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 the properties page. For example, the label for a property named platform might be:

<label>Platform</label>

5–2 Documentum Web Development Kit Tutorial

Page 43: Wdk Tutorial 42

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

■ For properties that have repeating values, use <showallvalues> to specify whether to display all values.

■ 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 file wdkTutorial3_finished.jsp). Log in to a Docbase and open a folder or cabinet in the Docbase that contains a document of your custom type. Select the document, and then choose Properties from the menu. You now see the values of 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 search properties of custom object types. To search properties of custom types, modify the configuration file advanced_search.xml to include your custom type 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, you can use the wdkSpace sample application, which does provide searching.

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

Documentum Web Development Kit Tutorial 5–3

Page 44: Wdk Tutorial 42

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

5–4 Documentum Web Development Kit Tutorial

Page 45: Wdk Tutorial 42

A

Solution Code A

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

■ “wdkSkeletonPage.jsp” on page A-2

■ “wdkTutorial0_finished.jsp” on page A-3

■ “wdkTutorial1_finished.jsp” on page A-4

■ “toolbarTutorial_finished.jsp” on page A-5

■ “wdkTutorial2_finished.jsp” on page A-7

■ “wdkTutorial3_finished.jsp” on page A-9

■ “folderContents.jsp” on page A-11

Documentum Web Development Kit Tutorial A–1

Page 46: Wdk Tutorial 42

Solution CodewdkSkeletonPage.jsp

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("wdkTutorial0")</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;

}%>

A–2 Documentum Web Development Kit Tutorial

Page 47: Wdk Tutorial 42

Solution CodewdkTutorial0_finished.jsp

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("wdkTutorial0")</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;

}%>

Documentum Web Development Kit Tutorial A–3

Page 48: Wdk Tutorial 42

Solution CodewdkTutorial1_finished.jsp

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("wdkTutorial1")</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;

}%>

A–4 Documentum Web Development Kit Tutorial

Page 49: Wdk Tutorial 42

Solution CodetoolbarTutorial_finished.jsp

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.DwCustToolbarInputButtonView"%>

<%// 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("toolbarTutorial")</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.");

Documentum Web Development Kit Tutorial A–5

Page 50: Wdk Tutorial 42

Solution CodetoolbarTutorial_finished.jsp

throw err;}

%>

A–6 Documentum Web Development Kit Tutorial

Page 51: Wdk Tutorial 42

Solution CodewdkTutorial2_finished.jsp

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("wdkTutorial2")</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(){

Documentum Web Development Kit Tutorial A–7

Page 52: Wdk Tutorial 42

Solution CodewdkTutorial2_finished.jsp

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;

}%>

A–8 Documentum Web Development Kit Tutorial

Page 53: Wdk Tutorial 42

Solution CodewdkTutorial3_finished.jsp

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.DwDocbaseTypedDictionary"%><%@ page import="com.documentum.wc.widget.docbase.DwDocOpenLinkEvent"%>

<%// 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("wdkTutorial3")</script>

Documentum Web Development Kit Tutorial A–9

Page 54: Wdk Tutorial 42

Solution CodewdkTutorial3_finished.jsp

<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(){

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/actionDispatcherContainer.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;

}%>

A–10 Documentum Web Development Kit Tutorial

Page 55: Wdk Tutorial 42

Solution CodefolderContents.jsp

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.//*****************************************************************************//* Project: WDK//* File: folderContents.jsp//* 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.DwDocbaseTypedDictionary"%><%@ page import="com.documentum.wc.widget.DwTableView"%><%@ page import="com.documentum.wc.widget.docbase.DwFolderContentListModel"%><%@ page import="com.documentum.wc.widget.docbase.DwObjectNameCellRenderer"%><%@ page import="com.documentum.wc.widget.docbase.DwIconCellRenderer"%><%@ page import="com.documentum.wc.widget.docbase.DwObjectSelectCellRenderer"%>

<%@ 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";

Documentum Web Development Kit Tutorial A–11

Page 56: Wdk Tutorial 42

Solution CodefolderContents.jsp

String strHasNextPage = "false";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().getLoginUserName();

// 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);

A–12 Documentum Web Development Kit Tutorial

Page 57: Wdk Tutorial 42

Solution CodefolderContents.jsp

if(nPageSize >= nTotalItems){

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%");

Documentum Web Development Kit Tutorial A–13

Page 58: Wdk Tutorial 42

Solution CodefolderContents.jsp

folderContentsView.addFormattedColumn("LockOwner",lookup.getString(DwNLSwdkComponentContents.MSG_LOCK_OWNER), strLockedBy, "15%");

}

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);

A–14 Documentum Web Development Kit Tutorial

Page 59: Wdk Tutorial 42

Solution CodefolderContents.jsp

}

/*** 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("announceSelectedFolder")', 100);</script>

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

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

</frameset><%

}else

Documentum Web Development Kit Tutorial A–15

Page 60: Wdk Tutorial 42

Solution CodefolderContents.jsp

{%>

</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;

}%>

A–16 Documentum Web Development Kit Tutorial