Zimlet JSP

From Zimbra :: Wiki

Jump to: navigation, search

A Zimlet JSP implements any server side data retrieval and manipulation for the actions to be performed on the client. The Zimlet JSP code may use any protocol or API needed to fetch data or act on a user’s selection.

For example, for a UPS package tracking Zimlet, a Zimlet JSP implementation may make a call to the UPS’ tracking information API with the matched tracking number in order to get package status and/or delivery information for displaying to the user. The tracking information would be returned to the client for possible display in a context object tool tip.

Contents

Custom Zimbra Tag Library

A Zimlet JSP implementation can include custom tags provided by the Zimbra Tag Library. Such tags can be used to build powerful server side plug-ins based on JSP, which complements the Zimlets by off-loading expensive tasks from the browser, providing better performance, and simplifying client-server communication. Many of the Zimbra resources are made available by Zimbra Tag Library. Refer to zimbra.tld for the details.

Available resources

  • message
  • conversation
  • contact
  • note
  • property
  • zimletconfig

In order to use the tags from Zimbra Tag Library, the tag library description file has to be declared at the top of JSP.

<%@ taglib uri="/WEB-INF/zimbra.tld" prefix="z" %>> Then the Zimbra custom tags can be used in the JSP.

Then the Zimbra custom tags can be used in the JSP


 <table border="1">
    <tr>
      <td>id</td>
      <td>subject</td>
      <td>from</td>
      <td>to</td>
      <td>cc</td>
      <td>bcc</td>
    </tr>
 <%
   String msgid;
   String[] msgids = { "488", "489", "405" };
     for (int i = 0; i < msgids.length; i++) {
         msgid = msgids[i];
 %>
    <tr>
      <td><%= msgid %></td>
      <td><z:message id='<%= msgid %>' field="subject"/></td>
      <td><z:message id='<%= msgid %>' field="from"/></td>
      <td><z:message id='<%= msgid %>' field="to"/></td>
      <td><z:message id='<%= msgid %>' field="cc"/></td>
      <td><z:message id='<%= msgid %>' field="bcc"/></td>
   </tr>
  <%
     }
  %>
     </table>

JSP support in 6.0 (CHANGED FROM 5.x)

Here's what you need to do to use the new taglib in zimlet jsp files.

ln -s /opt/zimbra/jetty/webapps/zimbra/WEB-INF/lib /opt/zimbra/jetty/webapps/zimlet/WEB-INF

ln -s /opt/zimbra/jetty/webapps/zimbra/WEB-INF/tags /opt/zimbra/jetty/webapps/zimlet/WEB-INF

ln -s /opt/zimbra/jetty/webapps/zimbra/WEB-INF/tlds /opt/zimbra/jetty/webapps/zimlet/WEB-INF

Copy five <env-entry> sections from /opt/zimbra/jetty/webapps/zimbra/WEB-INF/web.xml to /opt/zimbra/jetty/etc/zimlet.web.xml.in

The <env-entry> to copy are :

httpPort, httpsPort, mailUrl, adminUrl and trustedIps

After that restart jetty (zmmailboxdctl restart) and the tag libraries you reference in zimlet supplied jsp files will resolve correctly and start working.

Here's the caveat. Linking the jar files to zimlet webapp makes them available to all jsp files in zimlet webapp. You need to make sure that jsp files are well behaved. i.e. Don't try to use critical shared resources like db connection. Using ZClient/ZMailbox in JSP is safe, and that's the recommended way to access any mail items in jsp. When you upgrade or install patch to ZCS, you'll need to repeat the steps again.

The copying of <env-entry> to web.xml is awkward. We have filed a bug for this (bug 41046) so we don't have that dependency any more.

After we factor out the client side stuff from server side stuff and sever the dependency to zimbrastore.jar (bug 10704), we could make the tags available to zimlet webapp. Until then, the tag libraries are semi-public API that you are welcomed to use but you'll need to do some work to set it up and get it running.

See also

  • ZimletJSP contains outdated information about ZCS 4.5 and before.
Verified Against: Date Created: 7/16/2009
Article ID: http://wiki.zimbra.com/index.php?title=Zimlet_JSP Date Modified: 01/27/2011
Personal tools