ZimletJSP

Revision as of 22:54, 14 March 2006 by Jylee (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Setup

In order to use Zimbra Tag Library, tag library description file (tld) needs to be declared in the JSP page. The tag library is installed in the "service" webapp in /opt/zimbra/tomcat/webapps/service. The JSP page needs to be installed in the same webapp in order to use Zimbra Tag Library. tld is found at /opt/zimbra/tomcat/webapps/service/WEB-INF/zimbra.tld with the local URL of /WEB-INF/zimbra.tld.

 <%@ taglib uri="/WEB-INF/zimbra.tld" prefix="z" %>

The following data types are available from Zimbra Tag Library.

  • message
  • conversation
  • contact
  • property
  • zimletconfig

<message>

Returns the header value of the message specified by id and field. Or returns the entire message as raw string.

Required attributes:

  • id
  • field

Usage:

 <z:message id="512" field="subject"/>
 <z:message id="512" field="raw"/>

<conversation>

Conversation is an array of messages. Individual message can be accessed using the index attribute.

Required attributes:

  • id
  • index
  • field

Usage:

 <z:conversation id="568" index="1" field="subject"/>

<contact>

Provides access to the fields of addressbook contact entries.

Required attributes:

  • id
  • field

Available fields:

  • birthday
  • callbackPhone
  • carPhone
  • company
  • companyPhone
  • department
  • email
  • email2
  • email3
  • fileAs
  • firstName
  • fullName
  • homeCity
  • homeCountry
  • homeFax
  • homePhone
  • homePhone2
  • homePostalCode
  • homeState
  • homeStreet
  • homeURL
  • initials
  • jobTitle
  • lastName
  • middleName
  • mobilePhone
  • namePrefix
  • nameSuffix
  • nickname
  • notes
  • office
  • otherCity
  • otherCountry
  • otherFax
  • otherPhone
  • otherPostalCode
  • otherState
  • otherStreet
  • otherURL
  • pager
  • workCity
  • workCountry
  • workFax
  • workPhone
  • workPhone2
  • workPostalCode
  • workState
  • workStreet
  • workURL

Usage:

 <z:contact id="315" field="email"/>

<property>

Can be used to get/set user properties for the Zimlet.

Required attribute:

  • zimlet

Usage:

First mode of usage is inline substitution

 <z:property zimlet="com_zimbra_ymap" name="url"/>

To set a property

 <z:property zimlet="com_zimbra_ymap" action="set" name="username" value="test"/>

To get all the properties in a Map

 <z:property zimlet="com_zimbra_ymap" action="list" var="propMap"/>

Then the iteration of the map will return all the properties

 <%
 Map prop = (Map) pageContext.getRequest().getAttribute("propMap");
 Iterator iter = prop.keySet().iterator();
 while (iter.hasNext()) {
     key = (String)iter.next();
     String val = (String)prop.get(key);
 }
 %>

<zimletconfig>

Used to access zimlet configuration.

Required attribute:

  • zimlet

Usage:

To get global config

 <z:zimletconfig zimlet="com_zimbra_bugz" name="url" scope="global"/>

To get config local to the host

 <z:zimletconfig zimlet="com_zimbra_bugz" name="url" scope="local"/>

When scope is omitted, it will first look at the site config, then global config and look for the first match.

 <z:zimletconfig zimlet="com_zimbra_bugz" name="url"/>

Returns all the config in a Map.

 <z:zimletconfig zimlet="com_zimbra_bugz" action="list" var="conf"/>
 <%
 Map conf = (Map) pageContext.getRequest().getAttribute("conf");
 Map gconf = (Map) conf.get("global");
 Map lconf = (Map) conf.get("local");
 iter = gconf.keySet().iterator();
 while (iter.hasNext()) {
     key = (String)iter.next();
     String val = (String)gconf.get(key);
 }

%>

Jump to: navigation, search