spring-projects / spring-webflow

Spring Web Flow
https://spring.io/projects/spring-webflow
Apache License 2.0
331 stars 234 forks source link

Provide support for Portlet 2.0 resource requests [SWF-1415] #601

Closed spring-operator closed 13 years ago

spring-operator commented 14 years ago

Rossen Stoyanchev opened SWF-1415 and commented

The FlowHandlerAdapter.handleResource() method currently has an implementation that is equivalent to the Portlet 2.0 GenericPortlet. This method should be changed to have processing similar to that of action requests. A good demonstration would be to add some Ajax requests with partial rendering to the portlet samples.


Affects: 2.2.1

6 votes, 6 watchers

spring-operator commented 14 years ago

Paul Bacsik commented

It would be fine if resources could be served as a webflow action and Portlet Events would be handled the same way.

spring-operator commented 13 years ago

Florian Huonder commented

Am I right in the assumtion that after completion of this issue I am able to use Primefaces 1.1 within a Portlet-Environment with Ajax? Meaning I am able register the PrimeFacesAjaxHandler somehow?

spring-operator commented 13 years ago

Rossen Stoyanchev commented

Support for resource requests has been checked in. If anyone wants to try it, it will be available in the next nightly snapshot on http://maven.springframework.org/snapshot.

JSP users can use the JSP tag to create a resource URL for Ajax requests:

<portlet:resourceURL var="changeSearchUrl">
    <portlet:param name="execution" value="${flowExecutionKey}" />
    <portlet:param name="_eventId" value="changeSearch" />
</portlet:resourceURL>

JSF users will likely need to use a library that supports the use of resource URLs. It would be great it anyone has any experience to share in this regard.

spring-operator commented 13 years ago

Michael Streubel commented

I wasn't able to follow your maven link. Anyway, I have a working extension of SWF and PrimeFaces (unfortunately 1.1, not 2.x) allowing for AJAX and PPR by means of resource requests. However, it will be hard to expose source code because it is not open source, however we can try to share thoughts.

spring-operator commented 13 years ago

Rossen Stoyanchev commented

Hi Michael, the maven link cannot be browsed directly but should be usable in a Maven repository element. There is a way to browser interface for the same repository. It is https://s3browse.springsource.com/browse/maven.springframework.org/snapshot/.

I would be interested to hear your experience of integrating SWF and PrimeFaces. If it makes sense feel free to open tickets in JIRA for what we could do further in Web Flow or you can also contact me directly.

spring-operator commented 13 years ago

Florian Huonder commented

Hi Michael, Rossen

The case that Michael describes is exactly what we need. We are facing the problem that we want a PrimeFaces 1.1 application (with webflow) to be able to make Ajax. We do not need a working example or something. I would be glad whan you could share some thoughts on your "how to".

Would be great to hear something from you.

Best regards, Florian

spring-operator commented 13 years ago

Michael Streubel commented

Well, first of all it was an indispensable precondition that the frameworks (SWF and PrimeFaces) don't get patched. Everything is a framework extension.

Perhaps you can glimpse the implementation strategy if I show you the basics of the SWF extension configuration:

    <webflow:flow-executor id="flowExecutor">
        <webflow:flow-execution-listeners>
            <webflow:listener ref="ajaxFlowExecutionListener" />
            <webflow:listener ref="facesContextListener"/>
        </webflow:flow-execution-listeners>
    </webflow:flow-executor>

   <webflow:flow-registry id="flowRegistry"
            flow-builder-services="primefacesFlowBuilderServices"
                ..............

    <webflow:flow-builder-services id="primefacesFlowBuilderServices" view-factory-creator="viewFactoryCreator"
                conversion-service="facesConversionService"/>

   <bean id="viewFactoryCreator" class="xxxxxx.portal.resources.spring.webflow.extension.PortletViewFactoryCreator"/>

   <bean id="ajaxFlowExecutionListener" class="xxxxxx.portal.resources.spring.webflow.extension.AjaxFlowExecutionListener"/>

and the main entry point: The FlowHandlerAdapter extension


   <bean id="handlerAdapter" class="xxxxxx.portal.resources.spring.webflow.extension.AjaxPortletFlowHandlerAdapter">
        <property name="flowExecutor" ref="flowExecutor"/>
        <property name="flowUrlHandler">
            <bean class="xxxxxx.portal.resources.spring.webflow.extension.DefaultPortletAjaxFlowUrlHandler"/>
        </property>
        <property name="ajaxPortletHandler">
            <bean class="xxxxxx.portal.resources.spring.webflow.extension.PrimeFacesAjaxPortletHandler"/>
        </property>

  </bean>

All that enables SWF to handle Portlet ResourceRequests in such a way that they get propagated down into a derivation of the PrimeFacesPhaseListener.

It must be guaranteed that the latter gets switched off in favour of its derivation which is able to handle ResourceResponses in contrast to its parent. Here comes into play the beauty of PrimeFaces' Ajax implementation which on the serverside is solely handled by this class.

Finally, the whole setup is completed by extensions of PrimeFaces components and its underlying JavaScript resources to the effect that they also are able to send JSR 286 ResourceRequests instead of ActionRequests.

All that was developed under PrimeFaces 1.1 and SWF 2.1.0 but definitely works well under SWF 2.2.1/2.3.0.