Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Zimlets

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-08-2008, 05:29 AM
Intermediate Member
 
Posts: 15
Default First Zimlet - Lessons Learned + Help with Tooltips

Just finished my first Zimlet for a project and I wanted to share some experiences and some Gotcha's I discovered. While Zimbra is a nice product, the Zimlet creation process is, how shall I say, not very pleasant. I've been a professional developer for many years and have worked with all kinds of API's and on all kinds of projects. If Zimbra wants to see people developing Zimlets that are more than just toys, a couple things are critical:

1. Provide some documentation. Whatever is out there is not even close to sufficient. And half of it is contradictory.

2. Provide a way to test Zimlets in Zimbra that does not require hair pulling. Appending dev=1 is not sufficient (see below) and doing a "zmmailboxdctl restart" and all manner of odd deploying and undeploying a zimlet to try to get the cache to clear just makes you want to poke your eyes out.

3. Don't make changes that breaks existing Zimlets between releases. There is no better way to piss off open source developers than to change you API so it ruins their hard work. Especially if they are undocumented changes.

So, enough with the Rant. Let me share what I did to finally get some buttons added to the Compose Toolbar. I hope this saves somebody some time.

The short answer. This works in the current network version:
Code:
Com_My_Zimlet.prototype.init = function () {
	this._composerCtrl = AjxDispatcher.run("GetComposeController");

    if(!this._composerCtrl._toolbar) {
      // initialize the compose controller's toolbar
      this._composerCtrl._initializeToolBar();
    }
    this._toolbar = this._composerCtrl._toolbar;

    // Add button to toolbar
    ZmMsg.myLabel = "Does not work anyway";
    ZmMsg.myTooltip = "Would be nice to have";
    var op = {textKey: "myLabel", tooltipKey: "myTooltip", image: "MyZimletIcon"};
    var opDesc = ZmOperation.defineOperation(null, op);
    ZmOperation.addOperation(this._toolbar, opDesc.id, this._toolbar._buttons, 4);
    this._toolbar.addSelectionListener(opDesc.id, new AjxListener(this, this._myClickListener));

}
I know a lot of people followed the salesforce Zimlet example to do this. They use

Code:
this._composerCtrl = this._appCtxt.getApp(ZmZimbraMail.MAIL_APP).getComposeController();
to get the controller. THIS DOES NOT WORK for many reasons. One of the releases broke this. First, it is no longer "ZmZimbraMail.MAIL_APP". It is now "ZmApp.MAIL". Documentation would have been nice. Also this._appCtxt no longer exists for ZmZimletBase. You have to use appCtxt instead. I'm sure there is a reason this change was made, but I don't know it.

So you can change the line to
Code:
this._composerCtrl = appCtxt.getApp(ZmApp.MAIL).getComposeController();
Now you are getting close. This works perfectly in the current Open Source edition. It also works in the current Network Edition if you append ?dev=1 to the url before logging in. But, alas, once you remove the ?dev=1 you get some error about the composeController not existing.

So, finally, you get (thx to com_yahoo_yfinance)
Code:
this._composerCtrl = AjxDispatcher.run("GetComposeController")
This works in the Network, but I don't think in the Open Source. I'll have to double check.

So, now I've shared my experience. Maybe someone can help me to get tool tips and button labels working. Right now my button only shows an image.

This DOES NOT work:

Code:
ZmMsg.myLabel = "Does not work anyway";
    ZmMsg.myTooltip = "Would be nice to have";
    var op = {textKey: "myLabel", tooltipKey: "myTooltip", image: "MyZimletIcon"};
    var opDesc = ZmOperation.defineOperation(null, op);
    ZmOperation.addOperation(this._toolbar, opDesc.id, this._toolbar._buttons, 4);
Reply With Quote
  #2 (permalink)  
Old 03-10-2008, 04:15 AM
Zimlet Guru & Moderator
 
Posts: 288
Default

Thank you for those informations.
Just one thing to add very important :

4.Make the zimlet internationalizable. The actual zimlets are only done for USA.
Example: the zimlet yahoo maps (we find weird locations in USA) or the zimlet phone or sms (+1 added in the code to call USA automatically).
Reply With Quote
  #3 (permalink)  
Old 03-24-2008, 07:42 AM
Intermediate Member
 
Posts: 15
Default

I'll answer my own question about button labels and tooltips. This code works fine:

Code:
var op = {
text: "Label",
tooltip: "Tooltip", 
image: "MyZimletIcon"
};
var opDesc = ZmOperation.defineOperation(null, op);
ZmOperation.addOperation(this._toolbar, opDesc.id, this._toolbar._buttons, 4);
Reply With Quote
  #4 (permalink)  
Old 04-16-2008, 02:10 PM
Junior Member
 
Posts: 7
Default

I agree with you in that commentary that testing for zimlets and figuring out how to restart/waiting is hair pulling. Have you any updates to the zimlet test process? I just have a bash script that I wrote... but it doesn't change the fact that waiting for services to stop and start takes some time.

Also, if you are able to release your code, I'd love to poke through it and use it as a learning resoruce. Not sure if you're permitted or not.
Reply With Quote
  #5 (permalink)  
Old 04-17-2008, 12:42 AM
Zimlet Guru & Moderator
 
Posts: 288
Default

To test your zimlet without deploying-undeploying and restarting jetty, you just have to create a folder '_dev' in '/opt/zimbra/mailboxd/webapps/service/zimlet' then put your zimlet in it.

Then you just need to refresh your browser.
Reply With Quote
  #6 (permalink)  
Old 04-17-2008, 12:47 AM
Moderator
 
Posts: 7,929
Default

ZimletWritingTip - Zimbra :: Wiki
__________________
Reply With Quote
  #7 (permalink)  
Old 04-17-2008, 04:38 AM
Intermediate Member
 
Posts: 15
Default

My understanding is that the _dev directory is not applicable to version 5 or later. It is specific to 4.5. I at any rate have been unable to make this work in version 5.0.4 and the below Wiki entry seems to indicate why:

ZimletWritingTip - Zimbra :: Wiki

Can anyone who knows confirm or deny this.
Reply With Quote
  #8 (permalink)  
Old 04-17-2008, 04:40 AM
Moderator
 
Posts: 7,929
Default

Correct, my mistake as that is using Tomcat and not Jetty. Apologies
__________________
Reply With Quote
  #9 (permalink)  
Old 04-17-2008, 05:46 AM
Zimlet Guru & Moderator
 
Posts: 288
Default

You just have to use 'mailboxd' instead of 'tomcat'. I tested on a 5.0.4 and it work perfectly.
Reply With Quote
  #10 (permalink)  
Old 04-17-2008, 08:38 AM
Intermediate Member
 
Posts: 15
Default

confirmed!

create the directory _dev in

/opt/zimbra/mailboxd/webapps/service/zimlet

place the full zimlet folder for each zimlet you are working on it it seems to load them nicely.

This works much, much better than appending ?dev=1
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.