Back Forum Reply New

SWF and RichFaces (ajax4jsf), ajax response not rendered/displayed

Hi,
I have trouble getting swf to work with ajax4jsf. As an example I have used the simple javaecho described in the richfaces manual:
file-access/de...JAXEchoProject

When I place this example in a page which participates in a flow then the ajax response is not rendered (so the submit works but the ajax response is not handled correctly). For the ajaxecho example above, the text entered in the inputtext is put in the bean but the response is not placed in the outputtext.

I also tested this outside of a flow (so went to the same page without starting a flow) and then it worked fine. So there is something happening in relation to flow handling by spring web flow.

Is there something special I need to do to configure ajax4jsf with swf? Are maybe the servlet filters interfering with eachother?

Below is the web.xml I am using.

Thanks for any help on this.

gr. Martin

lt;?xml version='1.0' encoding='UTF-8'?gt;
lt;web-app version=quot;2.5quot; xmlns=quot;xml/ns/javaeequot; xmlns:xsi=quot;2001/XMLSchema-instancequot;
xsi:schemaLocation=quot;xml/ns/javaee xml/ns/javaee/web-app_2_5.xsdquot;gt;

lt;!-- facelets --gt;
lt;context-paramgt;
lt;param-namegt;facelets.REFRESH_PERIODlt;/param-namegt;
lt;param-valuegt;2lt;/param-valuegt;
lt;/context-paramgt;

lt;context-paramgt;
lt;param-namegt;facelets.DEVELOPMENTlt;/param-namegt;
lt;param-valuegt;truelt;/param-valuegt;
lt;/context-paramgt;

lt;context-paramgt;
lt;param-namegt;javax.faces.STATE_SAVING_METHODlt;/param-namegt;
lt;param-valuegt;clientlt;/param-valuegt;
lt;/context-paramgt;

lt;context-paramgt;
lt;param-namegt;javax.faces.DEFAULT_SUFFIXlt;/param-namegt;
lt;param-valuegt;.xhtmllt;/param-valuegt;
lt;/context-paramgt;

lt;context-paramgt;
lt;descriptiongt;
Set this flag to true if you want the JavaServer Faces Reference Implementation to validate the XML in your
faces-config.xml resources against the DTD. Default value is false.
lt;/descriptiongt;
lt;param-namegt;com.sun.faces.validateXmllt;/param-namegt;
lt;param-valuegt;truelt;/param-valuegt;

lt;/context-paramgt;

lt;context-paramgt;
lt;descriptiongt;
Set this flag to true if you want the JavaServer Faces Reference Implementation to verify that all of the
application objects you have configured (components, converters, renderers, and validators) can be
successfully created. Default value is false.
lt;/descriptiongt;
lt;param-namegt;com.sun.faces.verifyObjectslt;/param-namegt;
lt;param-valuegt;truelt;/param-valuegt;
lt;/context-paramgt;

lt;!-- Spring --gt;
lt;context-paramgt;
lt;param-namegt;contextConfigLocationlt;/param-namegt;
lt;param-valuegt;
classpathrg//webflow/samples/sellitem/services-config.xml
/WEB-INF/elver/spring/webflow-config.xml /WEB-INF/elver/spring/spring-config.xml
lt;/param-valuegt;
lt;/context-paramgt;

lt;!-- Rich Faces --gt;
lt;context-paramgt;
lt;param-namegt;org.richfaces.SKINlt;/param-namegt;
lt;param-valuegt;blueSkylt;/param-valuegt;
lt;/context-paramgt;

lt;context-paramgt;
lt;param-namegt;org.ajax4jsf.COMPRESS_SCRIPTlt;/param-namegt;
lt;param-valuegt;falselt;/param-valuegt;
lt;/context-paramgt;

lt;!--
Richfaces integration with facelets, note with this FaceletViewHandler in faces-config
is not required anymore
--gt;
lt;context-paramgt;
lt;param-namegt;org.ajax4jsf.VIEW_HANDLERSlt;/param-namegt;
lt;param-valuegt;com.sun.facelets.FaceletViewHandlerlt;/param-valuegt;
lt;/context-paramgt;

lt;!-- Bootstraps the root Spring Web Application Context, responsible for deploying managed beans
defined in the configuration files above.  These beans represent the services used by the JSF application. --gt;
lt;listenergt;
lt;listener-classgt;org..web.context.ContextLoade  rListenerlt;/listener-classgt;
lt;/listenergt;

lt;filtergt;
lt;display-namegt;RichFaces Filterlt;/display-namegt;
lt;filter-namegt;richfaceslt;/filter-namegt;
lt;filter-classgt;org.ajax4jsf.Filterlt;/filter-classgt;
lt;/filtergt;

lt;filter-mappinggt;
lt;filter-namegt;richfaceslt;/filter-namegt;
lt;ucl-patterngt;*.faceslt;/ucl-patterngt;
lt;/filter-mappinggt;

lt;!-- Guarantees that under all JSF exit conditions, the flow context will be cleaned up --gt;
lt;filtergt;
lt;filter-namegt;Flow System Cleanup Filterlt;/filter-namegt;
lt;filter-classgt;org..webflow.executor.jsf.Flo  wSystemCleanupFilterlt;/filter-classgt;
lt;/filtergt;

lt;!-- Filters all request to *.faces to the Flow System Cleanup Filter for guarenteed cleanup --gt;
lt;filter-mappinggt;
lt;filter-namegt;Flow System Cleanup Filterlt;/filter-namegt;
lt;ucl-patterngt;*.faceslt;/ucl-patterngt;
lt;/filter-mappinggt;

lt;!-- Faces Servlet --gt;
lt;servletgt;
lt;servlet-namegt;Faces Servletlt;/servlet-namegt;
lt;servlet-classgt;javax.faces.webapp.FacesServletlt;/servlet-classgt;
lt;load-on-startupgt;1lt;/load-on-startupgt;
lt;/servletgt;

lt;!-- Faces Servlet Mapping --gt;
lt;servlet-mappinggt;
lt;servlet-namegt;Faces Servletlt;/servlet-namegt;
lt;ucl-patterngt;*.faceslt;/ucl-patterngt;
lt;/servlet-mappinggt;
lt;/web-appgt;

Hi,
I think I have found a solution or workaround (I am not sure which of these it is). For anyone having the same issue, here is my solution:

Problem:
When an ajaxrequest is send to the server it is also picked by Spring web flow (by the swf FlowPhaseListener). Afaics based on the request web flow also forces/creates a response which one way or another replaces the ajax response. I am not sure how this occurs or why the ajax response 'disappears'.

Solution (or workaround):
The solution I have chosen is to prevent spring web flow from generating any response for an ajax request. The other parts (initialize flow execution etc.) is still executed. To implement this I have overridden the prepareResponse method of the swf FlowPhaseListener. You need your own phaselistener for this which needs to replace the jsf flow listener in the faces-config.xml.Code:
protected void prepareResponse(JsfExternalContext context, FlowExecutionHolder holder) {
if (AjaxRendererUtils.isAjaxRequest(context.getFacesContext())) {
// don't let web flow do anything!
return;
}
super.prepareResponse(context, holder);
}
Again I am not sure if this is really the best solution out there. For me it seems logical that swf should not act on ajax requests.

By overriding the prepareresponse other swf behavior stays the same (mainly restore and save flowexecution). I use a single key flow executor so the flow key stays stable for me. I am not sure if in another approach the flow key will change for each subsequent java request.

I hope this helps. If my solution has (hidden) drawbacks then ofcourse I am very interested to hear those!

gr. Martin

Hi,

I have the same problem with SWF 2.0 m3. Is there a solution for this problem with this version ?

Thanks for any help

Hi,
I have tested the last version 2.0m4 with richfaces and the behavior is the same.

Just a heads up that we will be doing extensive testing of integration between SWF 2.0 + Spring Faces and several of the major Ajax component libraries, including RichFaces, this week in preparation for the upcoming 2.0-RC1 release.  I have done some preliminary investigation and I expect we can get the integration working smoothly.  We will have full documentation in the final release on how to integrate with each of the libraries in question.

Thanks,

Jeremy


Originally Posted by jeremyg484Just a heads up that we will be doing extensive testing of integration between SWF 2.0 + Spring Faces and several of the major Ajax component libraries, including RichFaces, this week in preparation for the upcoming 2.0-RC1 release.  I have done some preliminary investigation and I expect we can get the integration working smoothly.  We will have full documentation in the final release on how to integrate with each of the libraries in question.

Thanks,

Jeremy

Hi Jeremy, ... can you point me to some resources about integration SWF with Ajax4JSF ??
¥
Back Forum Reply New