voyent
Problem integrating icefaces in myfaces/facelets app  XML
Forum Index -> General Help
Author Message
alendl

Joined: 19/Feb/2007 00:00:00
Messages: 20
Offline


Hi,
I am trying to integrate ICEfaces-1.6.0-DR4 in an existing myfaces+facelets web-application. We don't want to transform the entire app, but extend (or replace) some pages where we need extra functionality (like the expandable table).
I only want to handle few pages with ICEfaces and all other pages with the JSF default mechanism (myfaces), but that does not work as expected.

If ICEfaces handles all requests to existing standard pages, I receive JavaScript errors about the form object being null.

I have tried splitting up the handling between ICEFaces and myfaces. The following exception is thrown

Code:
 Servlet.service() for servlet faces threw exception
 java.lang.ClassCastException: org.apache.myfaces.context.servlet.ServletFacesContextImpl incompatible with com.icesoft.faces.context.BridgeFacesContext
 	at com.icesoft.faces.facelets.D2DFaceletViewHandler.renderResponse(D2DFaceletViewHandler.java:267)
 	at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:150)
 	at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:367)
 	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
 	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
 	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
 	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
 	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
 	at java.lang.Thread.run(Thread.java:797)
 


I have read through all reference documentation and tips I have found, including Integrating ICEfaces With Existing Applications and followed instructions therein. I have tried to adapt the timezone7 demo, but without success.

The following configuration settings are used in my application. I will only quote relevant parts.

web.xml
Code:
   <context-param>
     <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
     <param-value>.xhtml</param-value>
   </context-param>
 
   <context-param>
     <param-name>com.icesoft.faces.concurrentDOMViews</param-name>
     <param-value>true</param-value>
   </context-param>
 
   <listener>
 	<listener-class>com.icesoft.faces.util.event.servlet.ContextEventRepeater</listener-class>
   </listener>
 
   <!-- Faces Servlet -->
   <servlet>
     <servlet-name>faces</servlet-name>
     <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
     <load-on-startup> 1 </load-on-startup>
   </servlet>
 
   <!-- Persistent Faces Servlet -->
   <servlet>
     <servlet-name>Persistent Faces Servlet</servlet-name>
     <servlet-class>com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet</servlet-class>
     <load-on-startup> 1 </load-on-startup>
   </servlet>
 
   <!-- Blocking Servlet -->
   <servlet>
     <servlet-name>Blocking Servlet</servlet-name>
     <servlet-class>com.icesoft.faces.webapp.xmlhttp.BlockingServlet</servlet-class>
     <load-on-startup> 1 </load-on-startup>
   </servlet>
 
   <!-- Persistent Faces Servlet Mappings -->
   <servlet-mapping>
     <servlet-name>Persistent Faces Servlet</servlet-name>
     <url-pattern>/xmlhttp/*</url-pattern>
   </servlet-mapping>
 
   <servlet-mapping>
     <servlet-name>Persistent Faces Servlet</servlet-name>
     <url-pattern>*.iface</url-pattern>
   </servlet-mapping>
   
   <!-- JavaServer Faces Servlet Mapping -->
   <servlet-mapping>
 	<servlet-name>faces</servlet-name>
 	<url-pattern>*.faces</url-pattern>
   </servlet-mapping>
   <servlet-mapping>
 	<servlet-name>faces</servlet-name>
 	<url-pattern>/faces/*</url-pattern>
   </servlet-mapping>
 
   <!-- Blocking Servlet Mapping -->
   <servlet-mapping>
     <servlet-name>Blocking Servlet</servlet-name>
     <url-pattern>/block/*</url-pattern>
   </servlet-mapping>
   ...
 


As you can see, the plan is to let the standard mechanisms handle .faces and ICEfaces should handle requests to .iface URLs.

faces-config.xml
Code:
 	...
 	<!--<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>-->
 	<view-handler>
 		com.icesoft.faces.facelets.D2DFaceletViewHandler
 	</view-handler>
 	...
 

The standard facelet view handle has been replaced with the ICEfaces handler.

I am quite sure that I have used the right jar files (icefaces-facelets.jar, just-ice.jar or icefaces.jar, ...)

Thanks in advance
ted.goddard

Joined: 26/Oct/2004 00:00:00
Messages: 874
Offline



The following parameter will cause the ICEfaces ViewHandler to process only those pages with a .iface extension:

<context-param>
<param-name>com.icesoft.faces.delegateNonIface</param-name>
<param-value>true</param-value>
</context-param>
[Email]
alendl

Joined: 19/Feb/2007 00:00:00
Messages: 20
Offline


thanx for your quick reply!

after adding the "com.icesoft.faces.delegateNonIface" parameter I get a NullPointerException when calling a page with .iface and a file download dialogue (!) with .faces :(

Code:
ERROR [Persistent Faces Servlet]      - Servlet.service() for servlet Persistent Faces Servlet threw exception
 java.lang.NullPointerException
 	at com.icesoft.faces.webapp.http.servlet.ServletExternalContext.dispatch(ServletExternalContext.java:324)
 	at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
 	at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:142)
 	at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:142)
 	at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:367)
 	at com.icesoft.faces.webapp.http.core.PageServer$1.respond(PageServer.java:26)
 	at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:125)
 	at com.icesoft.faces.webapp.http.core.PageServer.service(PageServer.java:31)
 	at com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:16)
 	at com.icesoft.faces.webapp.http.servlet.MultiViewServlet.service(MultiViewServlet.java:56)
 	at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
 	at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
 	at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:89)
 	at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:35)
 	at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
 	at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
 	at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:59)
 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

ted.goddard

Joined: 26/Oct/2004 00:00:00
Messages: 874
Offline



This may be a bug; do you only see the exception when the page contains a fileUpload component?
[Email]
alendl

Joined: 19/Feb/2007 00:00:00
Messages: 20
Offline


Unfortunately no... the error has nothing to do with a file-upload tag.

The first page (called with .iface) is the one from the timzone demo and the second one is a simple myfaces/facelet page with an h:form tag and h:inputText element.

It also doesn't make any difference whether I use the icefaces.jar or just-ice.jar.

Is there something wrong with my config in the web.xml?

Code:
...
 <context-param>
     <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
     <param-value>server</param-value>
   </context-param>
 
   <context-param>
     <param-name>facelets.DEVELOPMENT</param-name>
     <param-value>true</param-value>
   </context-param>
 
   <context-param>
     <param-name>javax.faces.application.CONFIG_FILES</param-name>
     <param-value>/WEB-INF/faces-config.xml</param-value>
   </context-param>
 
   <context-param>
     <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
     <param-value>.xhtml</param-value>
   </context-param>
 
   <context-param>
     <param-name>com.sun.faces.validateXml</param-name>
     <param-value>true</param-value>
   </context-param>
 
   <context-param>
     <param-name>com.sun.faces.verifyObjects</param-name>
     <param-value>true</param-value>
   </context-param>
 
   <context-param>
     <param-name>com.icesoft.faces.concurrentDOMViews</param-name>
     <param-value>true</param-value>
   </context-param>
   
   <context-param> 
 	<param-name>com.icesoft.faces.delegateNonIface</param-name> 
 	<param-value>true</param-value> 
 	</context-param> 
 
   <listener>
 	<listener-class>com.icesoft.faces.util.event.servlet.ContextEventRepeater</listener-class>
   </listener>
 
   <!-- Faces Servlet -->
   <servlet>
     <servlet-name>faces</servlet-name>
     <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
     <load-on-startup> 1 </load-on-startup>
   </servlet>
 
   <!-- Persistent Faces Servlet -->
   <servlet>
     <servlet-name>Persistent Faces Servlet</servlet-name>
     <servlet-class>com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet</servlet-class>
     <load-on-startup> 2 </load-on-startup>
   </servlet>
 
   <!-- Blocking Servlet -->
   <servlet>
     <servlet-name>Blocking Servlet</servlet-name>
     <servlet-class>com.icesoft.faces.webapp.xmlhttp.BlockingServlet</servlet-class>
     <load-on-startup> 2 </load-on-startup>
   </servlet>
 
   <!-- Persistent Faces Servlet Mappings -->
   <servlet-mapping>
     <servlet-name>Persistent Faces Servlet</servlet-name>
     <url-pattern>/xmlhttp/*</url-pattern>
   </servlet-mapping>
 
   <servlet-mapping>
     <servlet-name>Persistent Faces Servlet</servlet-name>
     <url-pattern>*.iface</url-pattern>
   </servlet-mapping>
   
   <!-- JavaServer Faces Servlet Mapping -->
 	<servlet-mapping>
 		<servlet-name>faces</servlet-name>
 		<url-pattern>*.faces</url-pattern>
 	</servlet-mapping>
 	<servlet-mapping>
 		<servlet-name>faces</servlet-name>
 		<url-pattern>/faces/*</url-pattern>
 	</servlet-mapping>
 
   <!-- Blocking Servlet Mapping -->
   <servlet-mapping>
     <servlet-name>Blocking Servlet</servlet-name>
     <url-pattern>/block/*</url-pattern>
   </servlet-mapping>
 ...
ted.goddard

Joined: 26/Oct/2004 00:00:00
Messages: 874
Offline



It's still a bit puzzling; have you tried with the Sun RI JSF implementation? ViewID mapping is one area where the Sun RI and MyFaces differ.
[Email]
alendl

Joined: 19/Feb/2007 00:00:00
Messages: 20
Offline


Yes, I've already tried it with the Sun RI JSF implementation and it also doesn't work as expected.

You've got me at a loss :(

May you (or someone else) please have a look at the simple example attached (just a small modification of the timezone demo)?

With the "delegateNonIface" param the timezone page is displayed, but the clock does not tick and calling "test.faces" (the test.xhtml JSF page) doesn't work at all.

Big thanks in advance...
 Filename timezone_test.war [Disk] Download
 Description war file with source included (without jar-files)
 Filesize 75 Kbytes
 Downloaded:  175 time(s)

ted.goddard

Joined: 26/Oct/2004 00:00:00
Messages: 874
Offline



I haven't had a chance to try your sample application yet, but perhaps the ICEfaces ViewHandler has nothing suitable to delegate to. The following might help:

Code:
   <application>
       <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
   </application>
   <application>
  	<view-handler>com.icesoft.faces.facelets.D2DFaceletViewHandler</view-handler>
   </application>
 
[Email]
alendl

Joined: 19/Feb/2007 00:00:00
Messages: 20
Offline


using both handlers does also not work:

Code:
SEVERE: Error Rendering View[/timezone.xhtml]
 java.lang.IllegalStateException: getOutputStream() has already been called for this response
 	at org.apache.catalina.connector.Response.getWriter(Response.java:599)
 	at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:195)
 	at com.sun.facelets.FaceletViewHandler.createResponseWriter(FaceletViewHandler.java:410)
 	at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:574)
 	at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:142)
 	at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:367)
 	at com.icesoft.faces.webapp.http.core.PageServer$1.respond(PageServer.java:26)
 	at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:125)



I can't believe that the requirement of using both frameworks is so hard to accomplish. It is descripted in the ICEfaces devguide in just a few sentences (and that's exactly what I'm looking for):

JSF Integration

In most cases, the goal of adding ICEfaces to a JSF application will be to transform the entire application into an AJAX application, but there may be reasons for converting only parts over to ICEfaces. To handle some pages with ICEfaces and other pages with the JSF default mechanism, add the ICEfaces Servlet mappings for the ".iface" extension (as described in Configuration Reference of this document) but do not remove the "Faces Servlet" mapping or Servlet initialization. Pages served through the default Faces Servlet are to be handled without ICEfaces. Then, to ensure that Direct-to-DOM renderers are applied to ICEfaces pages only, include "just-ice.jar" rather than "icefaces.jar" in your web application libraries. This .jar file contains a version of ICEfaces configured with a ViewHandler that will process only those pages with a ".iface" extension and a RenderKit that will not override the standard JSF components (such as <h:commandLink />) with Direct-to-DOM renderers. In this configuration, ICEfaces pages must contain only standard core JSF tags ("f:" tags) and ICEfaces tags ("ice:" tags).  


ted.goddard

Joined: 26/Oct/2004 00:00:00
Messages: 874
Offline


I can't believe that the requirement of using both frameworks is so hard to accomplish. It is descripted in the ICEfaces devguide in just a few sentences.
 


It is hard to believe that something like this would be tricky, but JSF ViewHandler extensibility is complex, the delegation feature of ICEfaces had not been used specifically with Facelets before, and ICEfaces 1.6DR4 contained a bug (now fixed http://jira.icefaces.org//browse/ICE-1586 as a result of investigating your problem and a problem in another thread http://www.icefaces.org/JForum/posts/list/4469.page).

The two ViewHandlers really are necessary because the default JSF ViewHandler is not suitable for rendering Facelets; therefore the ICEfaces Facelets ViewHandler must be able to delegate to the Facelets ViewHandler.

Note that you will need a redirect to move from a non-ICEfaces page to an ICEfaces page:

Code:
     <navigation-rule>
                 <from-view-id>/test.xhtml</from-view-id>
                 <navigation-case>
                         <from-outcome>test</from-outcome>
                         <to-view-id>/timezone.iface</to-view-id>
                         <redirect/>
                 </navigation-case>
         </navigation-rule>
  


I've attached a full .war file that works in my testing (including an ICEfaces build containing debug code; please obtain an svn checkout for a better version).
 Filename timezone_test.war [Disk] Download
 Description
 Filesize 3282 Kbytes
 Downloaded:  168 time(s)

[Email]
alendl

Joined: 19/Feb/2007 00:00:00
Messages: 20
Offline


Thank you very much for your great support. I originally thought integrating ICEfaces in existing jsf (+facelets) applications is the most common use case... :)

I've just tried your attached war file and it seams to work as expected. I'll get the latest version from svn and do some further testing...

Thanks again!
ted.goddard

Joined: 26/Oct/2004 00:00:00
Messages: 874
Offline


alendl wrote:
Thank you very much for your great support. I originally thought integrating ICEfaces in existing jsf (+facelets) applications is the most common use case... :)
 


Pre-existing Facelets projects are not nearly as common as pre-existing JSP projects (at least not yet).
[Email]
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team