Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: First Zimlet - Lessons Learned + Help with Tooltips

  1. #1
    java_macchiato is offline Intermediate Member
    Join Date
    Mar 2008
    Posts
    15
    Rep Power
    7

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

  2. #2
    tdesorbaix is offline Zimlet Guru & Moderator
    Join Date
    Apr 2007
    Location
    Paris, France
    Posts
    367
    Rep Power
    8

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

  3. #3
    java_macchiato is offline Intermediate Member
    Join Date
    Mar 2008
    Posts
    15
    Rep Power
    7

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

  4. #4
    joshm is offline Junior Member
    Join Date
    Apr 2008
    Posts
    7
    Rep Power
    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.

  5. #5
    tdesorbaix is offline Zimlet Guru & Moderator
    Join Date
    Apr 2007
    Location
    Paris, France
    Posts
    367
    Rep Power
    8

    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.

  6. #6
    uxbod's Avatar
    uxbod is offline Moderator
    Join Date
    Nov 2006
    Location
    UK
    Posts
    8,017
    Rep Power
    24

  7. #7
    java_macchiato is offline Intermediate Member
    Join Date
    Mar 2008
    Posts
    15
    Rep Power
    7

    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.

  8. #8
    uxbod's Avatar
    uxbod is offline Moderator
    Join Date
    Nov 2006
    Location
    UK
    Posts
    8,017
    Rep Power
    24

    Default

    Correct, my mistake as that is using Tomcat and not Jetty. Apologies

  9. #9
    tdesorbaix is offline Zimlet Guru & Moderator
    Join Date
    Apr 2007
    Location
    Paris, France
    Posts
    367
    Rep Power
    8

    Default

    You just have to use 'mailboxd' instead of 'tomcat'. I tested on a 5.0.4 and it work perfectly.

  10. #10
    java_macchiato is offline Intermediate Member
    Join Date
    Mar 2008
    Posts
    15
    Rep Power
    7

    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

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 21
    Last Post: 02-04-2010, 10:06 AM
  2. Outlook 2007 Beta error
    By bersrker in forum Zimbra Connector for Outlook
    Replies: 13
    Last Post: 07-17-2008, 07:38 AM
  3. Replies: 5
    Last Post: 01-11-2008, 05:34 AM
  4. Domain Admin Error: Permission Denied
    By shanson in forum Administrators
    Replies: 3
    Last Post: 05-29-2007, 05:48 AM
  5. Post instsallation problems
    By Assaf in forum Installation
    Replies: 14
    Last Post: 01-29-2007, 11:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •