voyent
Null pointer exception calling EL function  XML
Forum Index -> General Help
Author Message
smohr

Joined: 17/Mar/2008 00:00:00
Messages: 3
Offline


This is my first foray into the EL world so I'm not entirely sure this problem has anything to do with ICEfaces but I'm leaning that way.

I created aproject in MyEclipse with ICEfaces integration and am trying a simple EL example to invoke a function.

Code:
 web.xml
 
 <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 version="2.4"
 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
 id="myeclWeb">
 	
 <jsp-config>
   <taglib>
     <taglib-uri>http://myUri</taglib-uri>
     <taglib-location>/WEB-INF/tags.tld</taglib-location>
   </taglib>
 </jsp-config>
 


Code:
 tags.tld
 
 <taglib xmlns="http://java.sun.com/xml/ns/j2ee" version="2.0">
   <tlib-version>1.0</tlib-version>
   <short-name>MyTagLib</short-name>
   <uri>http://myUri</uri>
   <function>
     <name>GetInt</name>
     <function-class>com.myproject.web.beans.HomeBean</function-class>
       <function-signature>int getInt(int)</function-signature>
   </function>
 </taglib>
 


Code:
 Home.jspx
 
 <?xml version="1.0" encoding="ISO-8859-1" ?>
 <jsp:root version="1.2" 
 	xmlns:jsp="http://java.sun.com/JSP/Page"
 	xmlns:f="http://java.sun.com/jsf/core"
 	xmlns:h="http://java.sun.com/jsf/html"
 	xmlns:ice="http://www.icesoft.com/icefaces/component"
 	xmlns:mytag="http://myUri">
 
 ....
 
 <ice:outputText value="${mytag:getInt(1)}" />
 


Code:
 HomeBean.java
 
 public static int getInt(int i)
 {
   return 999;
 }
 


Nothing fancy. I know the EL parser is kicking in because ${3*3} is correctly resolving as 9 in my test page.
When I call my own function, however, I'm getting this exception:

Code:
 javax.faces.FacesException: Problem in renderResponse: /Home.jspx @56,55 value="${mytag:getInt(1)}" java.lang.NullPointerException cannot be cast to javax.el.ELException
 	com.icesoft.faces.facelets.D2DFaceletViewHandler.renderResponse(D2DFaceletViewHandler.java:329)
 	com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:153)
 	com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
 	com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
 	com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
 	com.icesoft.faces.webapp.http.core.PageServer$1.respond(PageServer.java:26)
 	com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:147)
 	com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet$ThreadBlockingRequestResponse.respondWith(ThreadBlockingAdaptingServlet.java:36)
 	com.icesoft.faces.webapp.http.core.PageServer.service(PageServer.java:31)
 	com.icesoft.faces.webapp.http.core.SingleViewServer.service(SingleViewServer.java:46)
 	com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer$Matcher.serviceOnMatch(PathDispatcherServer.java:50)
 	com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:19)
 	com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
 	com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:29)
 	com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:110)
 	com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:35)
 	com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
 	com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
 	com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:97)
 	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
 	org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
 
 


As far as I can tell my syntax is fine - it's just gagging on my custom function.

In faces-config.xml, I also see
Code:
 <application>
   <view-handler>
   com.icesoft.faces.facelets.D2DFaceletViewHandler
   </view-handler>
 </application>
 


which is what enables the EL processing (or rather, removing it makes EL expressions appear as their literal text).

Is there something I need to do differently in my project setup to make EL and the ICEfaces Facelet handler play nice?


Thanks for any advice (and/or tutorial links) anyone can provide.
Ragnarok

Joined: 27/Jan/2008 00:00:00
Messages: 12
Offline


Im having the same problem... any solution??
philip.breau


Joined: 08/May/2006 00:00:00
Messages: 2989
Offline


Hi,

Facelets is a replacement for JSP, so no JSP functionality will work. Check out this tutorial for creating custom EL functions with Facelets.

Philip

.
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team