# LAB-5569: ODFDOM - Changing ODF documents using the new opensourced multi-tiered API

Expected Duration: 100 minutes
Contacts: Svante Schubert Steffen Grund

Introduction | Exercise 0 | Exercise 1 | Exercise 2 | Exercise 3 | Exercise 4 | Summary
Introduction OpenOffice.org NetBeans ODFDOM Optional configuration ### Exercise 0: Install and Configure Lab Environment For JavaOne attendees using the lab machines provided, the steps in Exercise 0 are done for you as part of the login process. So please proceed to Exercise 1. Install OpenOffice.org Go to the OpenOffice.org download page and download the latest version. Follow the OpenOffice.org install instructions. For exercise 4, additionally download and install the OpenOffice.org SDK. Also follow the OpenOffice.org SDK install instructions. Install and Configure NetBeans Go to the NetBeans download page and download the latest (at least 6.5.1) NetBeans version. Make sure that Glassfish V2.1 (or newer) support is included. Follow the NetBeans' install instructions. Start NetBeans: either click on the NetBeans icon or open a shell, go to the NetBeans installation directory and type `netbeans`. In NetBeans, make sure that the Maven plugin is installed and enabled. Go to Tools - Plugins - Installed. If the Maven plugin is in this list and marked as active, everything is ok. It should look like Figure-01. Figure-01: Correctly installed Maven plugin If this is not the case, you have to download and install the Maven plugin. Click on the "Available Plugins" tab. Enter `maven` in the search field. Mark the Maven plugin in the list and click on "Install". Follow the steps of the installation. At the end, click "Close" to close the window. Figure-02: Install the Maven plugin For exercise 4, an addional plugin for NetBeans is needed. It is available in the NetBeans Beta update center. Open "Tools - Plugins" and download and install the "OpenOffice.org API plugin for Netbeans". All steps work accordingly to the Maven plugin above. Refer to http://plugins.netbeans.org for more information on NetBeans plugins, and to http://wiki.services.openoffice.org for more information on the OpenOffice.org plugin for NetBeans. Notice that you may have to configurte the plugin with the installed OpenOffice.org and OpenOffice.org SDK. Confer http://wiki.services.openoffice.org Download and Install the ODFDOM Note: you do not have to download ODFDOM. The authors of this lab have included a compiled and working version of ODFDOM in the lab: odfdom.jar The reason for this is that the API of ODFDOM is a work in progress and may not be compatible with the code presented in the exercises. We do encourage the download of the latest version, though, to benefit from additions and bugfixes. Download the source code of the ODFDOM. This is available in a Mercurial repository. The following instructions explain everything on the NetBeans side. Confer ODFDOM build environment using NetBeans IDE In NetBeans, open "Versioning - Mercurial - Clone Other...". Enter the following Repository URL: `https://odftoolkit.org/hg/odfdom~developer`. Click "Next >" Figure-03: Download ODFDOM 1 The following paths are already ok, so click "Next >" again. Figure-04: Download ODFDOM 2 Enter "<lab_root>/odfdom" as Parent Directory. Note: "/home/javaone2009" is only a placeholder. Click "Finish". You may have to wait a little bit until Mercurial finishes. Figure-05: Download ODFDOM 3 When cloning the project has finished, you may get the message box shown in Figure-06 - depending on your system. Click on "Yes" to ignore Mercurial's own files. If the settings here are already done on your machine, go directly to the next point. Figure-06: Download ODFDOM finished Finally, the maybe irritating message shown in Figure-07 will appear. Click on "Open Project..." This will open the project and set it as Main project. Figure-07: Open ODFDOM project If you run into a reference problem as displayed in Figure-08, that is a known bug in the NetBeans platform (and already fixed in NetBeans 6.7). This problem occurs when you have Java 6 installed, because the ODFDOM has Java 5 as official baseline. Fortunately there is a workaround available. Figure-08: Reference Problem Open the project's properties by right clicking on the project. Click on "Properties". Note that "Resolve Reference Problems..." is only helpful when there is also Java 5 available on your system. Figure-09: Open Project Properties Go to the "Libraries" category. Notice the missing Java platform. Figure-10: Open Project Properties Simply select one of the available Java platforms, make sure it is "JDK 1.5". Click "OK" Figure-11: Select the correct platform You will be asked to regenereate build-impl.xml. Click on "Regenerate" Figure-12: Regenerate build-impl.xml Optional configuration The following configuration steps are not mandatory to do the exercises, but they may help in working with ODFDOM. The authors of the lab strongly encourage to do the following to make working with the lab easier. Add the javadoc of ODFDOM to NetBeans. Open "Tools - Library" Click on "New Library..." Figure-13: Library Manager Enter "ODFDOM" as name. Click "OK" next. Figure-14: Create new Library In the still open Library Manager dialog, the new library is added. Click on "Add JAR/Folder"and choose "<lab_root>/resources/odfdom/jars/odfdom.jar" Figure-15: Library Mabager Back again, click on "Javadoc" and then on "Add Zip/Folder". Choose the folder "<lab_root>/resources/odfdom/javadoc" Figure-16: Library Manager Click "OK" now to close the dialog. When you type a "." after a variable or class name from the odfdom.jar package, NetBeans will open the Javadoc in a popup window. Example: Figure-17: Javadoc Example Now you are all set to proceed to the exercises! Back to top Next exercise