Essential ATG Dynamo Training - Got atg Certified Relationship Management Developer?
This is not an official ATG site: ATG, Dynamo, Scenario Server and Personalization Server are trademarks or registered trademarks of Art Technology Group
Articles Exercises Resources Links Search

Add vCard and vCalendar Support

Overview

vCards are a standard way to exchange people's contact information. This sample shows you how to add vCard (and vCalendar) download support to any repository. A default configuration is provided which works for the standard DPS Profile repository. 

vCards can be imported automatically into Outlook contacts and Netscape:

The same servlet which provides vCards can also provide vCalendars. /servlets/vCalendarEvent and /servlets/vCalendarToDo are partly configured for to this end. The data to drive these servlets is not provided so the mapping repository configurations are left incomplete.

Additional code is provided to ensure that the save-as/open dialog in windows always functions correctly.

To install the demo download this zip file and extract the files under c:\atg\Dynamo5.1. You may need to modify the supplied /atg/dynamo/Configuration file if your dynamo is not installed in c:\atg\Dynamo5.1 to specify the correct document root.

To enable the functionality just start dynamo with the -m Training.vCalendar switch

Configuration

vCards

The sample configures an instance of vcalendar.VCFServlet the /servlets/vCard component. This is a servlet which will stream the vCard back to the client when requested.

The repository and the item type name are set to user and the ProfileAdapterRepository.

The footer and header string lists are left at their defaults: vcard version 2.1.

The property map specifies the following mappings:

The truncated address mapping reads as follows (without the line break):

;;homeAddress.address1 homeAddress.address2;homeAddress.city;homeAddress.state;
homeAddress.postalCode;homeAddress.country

The keys in the map are the vCard field names the specification can be found here The values are lists of repository properties separated by spaces or semicolons (ONLY!). The spaces and semicolons are written verbatim to the vCard file and may have significance, as in the work address in the example. Use of a single space allows you to concatenate repository items into a field. As in the N (name) example above. 

As you can see from the homeAddress example above values can also be of nested repository items, specified in the format property.subproperty. This syntax only supports subproperties of repository items, not of any other java type, neither are arrays are supported, in this release.

The /atg/dynamo/Configuration file has been modified with the following mappings in the dispatcherServiceMap:

This sets up the vCard, vCalendar event and todo support.

In order to get the vCard of profile id # 737 the following URL will invoke the servlet

http://localhost:8840/demo/vCard?id=737

In order to get the file to save as a vcf file on a windows machine the login name of the target user and the .vcf extension are added:

http://localhost:8840/demo/vCard/nick.vcf?id=737

This has the same result on the server but now the files is saved as a vcf file automatically on the client.

Additionally, the example jhtml files use embedded java code to write the calling URL into the page to bypass the URL re-writing. There is no need for the session id here and it can confuse the downloading client into thinking it's not a vcf file.

vCalendar

Almost identical to the vCard setup just with different headers and footers in the configuration for event and todo:

Example Usage

The simple example includes an index.jhtml page which displays all the users in the ProfileAdapterRepository. Then links each to the profile.jhtml page which displays more information about the selected user. The profile page includes the vCard link, both as a form post and a normal anchor tag

Clicking the vCard link prompts the user to save the vCard named as michael.vcf in this case

And we see that Michael's information has been successfully sent down as a vCard

 



Technical Training Advertise your Training Programs for Free! Los Angeles Web Design Shopping Cart Software  Form a Corporation