HelloWorldZimlet

From Zimbra :: Wiki

Jump to: navigation, search

Building a Zimlet is not difficult. Anyone with a small knowledge of XML can start building his / her first Zimlet. Knowing Javascript is a plus, and you can write very powerful Zimlets if you are familiar with AJAX programming. You can still write Zimlets even if you are not familiar with Javascript language. Many of the Zimlet features can be declared in the XML description file, and it's possible to write a useful Zimlet in fully declarative manners.

Here is a step by step instruction of building and deploying a simple Zimlet. It matches the string "Hello World" in the emails, and create a popup balloon that says "Hello World Zimlet". All of these can be done with just a few lines of XML.

First, write the definition file for the Zimlet.

 $ cat com_zimbra_hello.xml
 <zimlet name="com_zimbra_hello" version="1.0" description="Hello World">
     <contentObject>
         <matchOn>
             <regex attrs="ig">Hello World</regex>
         </matchOn>
         <toolTip>Hello World Zimlet</toolTip>
     </contentObject>
 </zimlet>

Second, change the owner of the XML file to "zimbra".

Then build a zip bundle of the Zimlet.

 $ zip com_zimbra_hello.zip com_zimbra_hello.xml
   adding: com_zimbra_hello.xml (deflated 42%)

change the owner again to "zimbra".

Now the Zimlet can be deployed to ZCS.

 $ /opt/zimbra/bin/zmzimletctl deploy com_zimbra_hello.zip
 [] INFO: Deploying Zimlet com_zimbra_hello in LDAP.
 [] INFO: Installing Zimlet com_zimbra_hello on this host.
 [] INFO: Adding Zimlet com_zimbra_hello to COS default
 [] INFO: Enabling Zimlet com_zimbra_hello

Verify the Zimlet is indeed installed correctly.

$ /opt/zimbra/bin/zmzimletctl listZimlets
Installed Zimlet files on this host:
      com_zimbra_amzn
      com_zimbra_hello
      com_zimbra_phone
      com_zimbra_tracking
      com_zimbra_url
Installed Zimlets in LDAP:
      com_zimbra_amzn
      com_zimbra_hello
      com_zimbra_phone
      com_zimbra_tracking
      com_zimbra_url
Available Zimlets in COS:
  default:
      com_zimbra_amzn
      com_zimbra_hello
      com_zimbra_phone
      com_zimbra_tracking
      com_zimbra_url

Now the Zimlet is installed. From now on all the new login's will have this Zimlet. If you are already logged in, just hit reload, and this Zimlet will be loaded. Restart tomcat if needed in order to purge the cached COS and Account object in the server.

Hello World Zimlet in action
Personal tools