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 Display Modes
  #1 (permalink)  
Old 10-08-2009, 09:35 AM
Trained Alumni
 
Posts: 286
Default [SOLVED] Creating Multiple Buttons?

Hi,

I need to have this Zimlet have three buttons with three different actions. Right now this code just shows an OK button with a label of "Close", and when you click it the popup closes.

Code:
dlg.getButton(DwtDialog.OK_BUTTON).setText("Close");
    dlg.setButtonVisible(DwtDialog.CANCEL_BUTTON, false);
    // dlg.setButtonListener block is optional; you can use it to augment the default OK button handler 
    // (popdown, dispose) to do interesting things like set a flag somewhere that the user has been notified, etc. 
    // As it is below, it duplicates the default OK button handler.
    dlg.setButtonListener(DwtDialog.OK_BUTTON, new AjxListener(this, function() {
        dlg.popdown();
        dlg.dispose();
    }));
I need to have three buttons. One called "More Info" that opens a webpage, one called "Change Password" that opens a second webpage, and the third as it is now, just a button labeled "Close" that closes the dialog.

Thanks,
Matt
Reply With Quote
  #2 (permalink)  
Old 10-09-2009, 11:40 AM
Member
 
Posts: 11
Default

Create the extra buttons before you create the dialog, with something like this:

Code:
myzimlet.prototype.setupDialog = 
function() {
    var infoButtonId = Dwt.getNextId();
    this._infoButton = new DwtDialog_ButtonDescriptor(infoButtonId, "More Info");
    var chpassButtonId = Dwt.getNextId();
    this._chpassButton = new DwtDialog_ButtonDescriptor(chpassButtonId, "Change Password");

    this._dlg = new DwtDialog({parent: ..., title: '...', standardButtons: [DwtDialog.DISMISS_BUTTON], extraButtons: [this._infoButton, this._chpassButton]});

    this._dlg.setButtonListener(infoButtonId, new AjxListener(this, this.dlgButtonHandler, "info"));
    this._dlg.setButtonListener(chpassButtonId, new AjxListener(this, this.dlgButtonHandler, "chpass"));
    this._dlg.setButtonListener(chpassButtonId, new AjxListener(this, this.dlgButtonHandler, ""));
};

myzimlet.prototype.dlgButtonHandler = 
function(action) {
    this._dlg.popdown();
    this._dlg.dispose();
    switch (action) {
        case "info":
            window.open(infoURL, "More Info");
            break;
        case "chpass":
            window.open(chpassURL, "Change Password");
            break;
    }
};
Reply With Quote
Reply


Thread Tools
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.

Zimbrablog.com




 

Search Engine Optimization by vBSEO 3.1.0