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

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 Search this Thread Display Modes
  #1 (permalink)  
Old 08-28-2009, 10:20 AM
Active Member
 
Posts: 34
Default Zimlet JSP using Zimbra's API

I use Zimbra Desktop, I create the dir _dev (ZimletWritingTip - Zimbra :: Wiki) and I can try my zimlet: everything is working.

But now I want to use JSP (using java libraries to access to mysql db); also through the JSP pages, is possible to access to the Zimbra fields.

Does anyone know how to invoke a JSP page as zimlet in Zimbra Desktop and how to instruct in the jsp page so I can read the Zimbra fields (specifcally who is logged at that time)?

Thanks
Reply With Quote
  #2 (permalink)  
Old 08-28-2009, 11:55 AM
raj raj is offline
Moderator
 
Posts: 759
Default

OLD: ZimletJSP - Zimbra :: Wiki
NEW: Zimlet JSP - Zimbra :: Wiki

this zimlet used JSP for stuff..you can read the JSP file to get the idea
Get or contribute Zimlets, UI themes, and languages in the Zimbra Gallery - Alfresco


Raj
__________________
i2k2 Networks
Dedicated & Shared Zimbra Hosting Provider
Reply With Quote
  #3 (permalink)  
Old 08-30-2009, 11:17 AM
Active Member
 
Posts: 34
Default

Quote:
Originally Posted by raj View Post
Thanks 4 the reply.

I've been able to execute a JSP:

a create a symbolic link from /home/<userdir>/public_html/zimbra to /home/<userdir>/zimbra
then a create in the _dev the dir org_munet_prova conteinig the files ciao.jsp newVideo.jsp org_munet_prova.xml zimlet.js

In details
org_munet_prova.xml:
Code:
<zimlet name="org_munet_prova" version="1.0" description="JSP_Zimlet">

<include>zimlet.js</include>
<handlerObject>Org_munet_prova</handlerObject>

<zimletPanelItem label="Prova JSP Zimlet" icon="My-panelIcon">
   <toolTipText>This is a super awesome zimlet that does something.</toolTipText>
   <contextMenu>
       <menuItem label="JSP Zimlet" id="JSPZimlet" icon="My-panelIcon">
           <canvas type="window" title="prova" width="700" height="500" />
           <actionUrl target="http://localhost/~mune" />
       </menuItem>
   </contextMenu>
 </zimletPanelItem>
</zimlet>
zimlet.js
Code:
function Org_munet_prova() {
}

Org_munet_prova.prototype = new ZmZimletBase();
Org_munet_prova.prototype.constructor = Org_munet_prova;

Org_munet_prova.init = function() {
};

// Called by the Zimbra framework when the panel item was double clicked
Org_munet_prova.prototype.doubleClicked = function() {
        this.singleClicked();
};

// Called by the Zimbra framework when the panel item was clicked
Org_munet_prova.prototype.singleClicked = function() {
        var url = this.getResource("ciao.jsp");
        window.oppwin = window.open(url," oppwin", "menubar=no,width=0.1px,height=0.1px");
};
and finally ciao.jsp which merely prints "hello world"
Code:
<!-- prova.jsp -->
<html>
<body>
  JSP -> <% out.println("Ciao Mondo!"); %>
</body>
</html>
BUT

if ciao.jsp uses the directive taglib
Code:
<!-- prova.jsp -->
<%@ taglib uri="/WEB-INF/zimbra.tld" prefix="z" %>
<html>
<body>
  JSP -> <% out.println("Ciao Mondo!"); %>
</body>
</html>
when the browser opens the JSP page i get
Code:
HTTP ERROR: 500

INTERNAL_SERVER_ERROR

RequestURI=/service/zimlet/_dev/org_munet_prova/ciao.jsp
Caused by:

java.lang.NullPointerException
	at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:234)
	at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:482)
	at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:562)
	at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1626)
	at org.apache.jasper.compiler.Parser.parse(Parser.java:165)
	at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:223)
	at org.apache.jasper.compiler.ParserController.parse(ParserController.java:124)
	at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:184)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:398)
	at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:477)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:371)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
	at com.zimbra.cs.zimlet.ZimletFilter.doFilter(ZimletFilter.java:204)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:716)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:406)
	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
	at org.mortbay.jetty.handler.RewriteHandler.handle(RewriteHandler.java:176)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
	at org.mortbay.jetty.Server.handle(Server.java:313)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
	at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
The problem is half solved
Reply With Quote
  #4 (permalink)  
Old 09-02-2009, 08:22 AM
Active Member
 
Posts: 34
Default

Quote:
Originally Posted by mune72 View Post
[...]
Code:
<!-- prova.jsp -->
<%@ taglib uri="/WEB-INF/zimbra.tld" prefix="z" %>
<html>
<body>
  JSP -> <% out.println("Ciao Mondo!"); %>
</body>
</html>
[...]
Anyone can tell me how to handle the Zimbra taglibrary?

Thanks
Reply With Quote
  #5 (permalink)  
Old 09-08-2009, 02:15 PM
Active Member
 
Posts: 34
Default

Quote:
Originally Posted by mune72 View Post
Anyone can tell me how to handle the Zimbra taglibrary?

Thanks
I give the answer to myself

Using the taglibrary is possible only on the server version of zimbra which has tomcat, and not on desktop one.

In the wiki page is said
Code:
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" %>
but in the desktop version...
Code:
find zimbra/ -name WEB* -print
zimbra/zdesktop/jetty/webapps/service/WEB-INF
zimbra/zdesktop/jetty/webapps/zimbra/WEB-INF
there isn't any .tld file
Code:
ls zimbra/zdesktop/jetty/webapps/service/WEB-INF
classes  lib  web.xml
So it has a bunch of reasons for complaing.
Reply With Quote
  #6 (permalink)  
Old 09-10-2009, 10:27 AM
Active Member
 
Posts: 34
Default

Still trying to access to zimbra's variables...

The framework was .xml -> .js -> .jsp

I read this page Zimlet JavaScript Class - Zimbra :: Wiki

So I modified my .js in this way
Code:
function Org_munet_prova() {
}

Org_munet_prova.prototype = new ZmZimletBase();
Org_munet_prova.prototype.constructor = Org_munet_prova;

Org_munet_prova.init = function() {
};

// Called by the Zimbra framework when the panel item was double clicked
Org_munet_prova.prototype.doubleClicked = function() {
	this.singleClicked();
};

// Called by the Zimbra framework when the panel item was clicked
Org_munet_prova.prototype.singleClicked = function() {
	// this.getUserProperty(“PropertyName”)
	var variabile = this.getUserPropertyInfo("websiteUrl")["value"];

	var url = this.getResource("ciao.jsp");
	window.oppwin = window.open(url, "oppwin", "menubar=no,width=0.1px,height=0.1px");
};
but with the line
Code:
var variabile = this.getUserPropertyInfo("websiteUrl")["value"];
doesn't work while commenting it out
Code:
//var variabile = this.getUserPropertyInfo("websiteUrl")["value"];
works.

Anybody can help? Thanks
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.