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

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-08-2008, 05:29 AM
java_macchiato java_macchiato is offline
Junior Member
 
Join Date: Mar 2008
ZCS Version: Release 5.0.4_GA_2101.RHEL5_64_20080321141727 RHEL5_64 NETWORK edition
Posts: 9
java_macchiato is on a distinguished road
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
tdesorbaix tdesorbaix is offline
Senior Member
 
Join Date: Apr 2007
Location: Paris, France
ZCS Version: Release 5.0.4_GA_2101.RHEL4_20080321132418 CentOS4 NETWORK edition
Posts: 83
tdesorbaix is on a distinguished road
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
java_macchiato java_macchiato is offline
Junior Member
 
Join Date: Mar 2008
ZCS Version: Release 5.0.4_GA_2101.RHEL5_64_20080321141727 RHEL5_64 NETWORK edition
Posts: 9
java_macchiato is on a distinguished road
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
joshm joshm is offline
Junior Member
 
Join Date: Apr 2008
Posts: 6
joshm is on a distinguished road
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
tdesorbaix tdesorbaix is offline
Senior Member
 
Join Date: Apr 2007
Location: Paris, France
ZCS Version: Release 5.0.4_GA_2101.RHEL4_20080321132418 CentOS4 NETWORK edition
Posts: 83
tdesorbaix is on a distinguished road
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
uxbod's Avatar
uxbod uxbod is offline
Moderator
 
Join Date: Nov 2006
Location: Northampton, UK
ZCS Version: Release 5.0.7_GA_2450.RHEL5_20080630192737 CentOS5 NETWORK edition (Unsupported OS)
Posts: 1,335
uxbod is on a distinguished road
Send a message via MSN to uxbod
Default

ZimletWritingTip - Zimbra :: Wiki
__________________
Server | CentOS 5.1 | Dual Opteron 250 | Tyan K8W Mobo | 6GB RAM | 3WARE 9550-SX4 | 4 x Samsung 200GB SATA II |
Zimbra | Release Release 5.0.7_GA_2450.RHEL5_20080630192737 NETWORK edition running on Xen 3.2 CentOS 5.2 i386 VM |
Network | Cisco 877 Router - Cisco ASA 5505 FW - Cisco 1131AP |
Reply With Quote
  #7 (permalink)  
Old 04-17-2008, 04:38 AM
java_macchiato java_macchiato is offline
Junior Member
 
Join Date: Mar 2008
ZCS Version: Release 5.0.4_GA_2101.RHEL5_64_20080321141727 RHEL5_64 NETWORK edition
Posts: 9
java_macchiato is on a distinguished road
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
uxbod's Avatar
uxbod uxbod is offline
Moderator
 
Join Date: Nov 2006
Location: Northampton, UK
ZCS Version: Release 5.0.7_GA_2450.RHEL5_20080630192737 CentOS5 NETWORK edition (Unsupported OS)
Posts: 1,335
uxbod is on a distinguished road
Send a message via MSN to uxbod
Default

Correct, my mistake as that is using Tomcat and not Jetty. Apologies
__________________
Server | CentOS 5.1 | Dual Opteron 250 | Tyan K8W Mobo | 6GB RAM | 3WARE 9550-SX4 | 4 x Samsung 200GB SATA II |
Zimbra | Release Release 5.0.7_GA_2450.RHEL5_20080630192737 NETWORK edition running on Xen 3.2 CentOS 5.2 i386 VM |
Network | Cisco 877 Router - Cisco ASA 5505 FW - Cisco 1131AP |
Reply With Quote
  #9 (permalink)  
Old 04-17-2008, 05:46 AM
tdesorbaix tdesorbaix is offline
Senior Member
 
Join Date: Apr 2007
Location: Paris, France
ZCS Version: Release 5.0.4_GA_2101.RHEL4_20080321132418 CentOS4 NETWORK edition
Posts: 83
tdesorbaix is on a distinguished road
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
java_macchiato java_macchiato is offline
Junior Member
 
Join Date: Mar 2008
ZCS Version: Release 5.0.4_GA_2101.RHEL5_64_20080321141727 RHEL5_64 NETWORK edition
Posts: 9
java_macchiato is on a distinguished road
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
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2007 Beta error bersrker Zimbra Connector for Outlook 11 01-31-2008 06:25 AM
Admin interface fails after install of posix/samba zimlets Franck Zimlets 5 01-11-2008 04:34 AM
Domain Admin Error: Permission Denied shanson Administrators 3 05-29-2007 05:48 AM
Post instsallation problems Assaf Installation 14 01-29-2007 10:38 AM
Kickstart for automated installation and disaster recovery mubley Installation 19 01-10-2006 02:45 PM


freshmeat.net sourceforge.net The best Java IDE



 

Search Engine Optimization by vBSEO 3.0.0