Results 1 to 3 of 3

Thread: Problem switching modes in SWF2 + Jetspeed 2

  1. #1

    Default Problem switching modes in SWF2 + Jetspeed 2

    Hi there,

    I'm developing a simple portlet using the sample application to start but I don't manage to switch the portlet mode using the icon displayed by jetspeed.

    My conf:

    portlet.xml

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <portlet-app
    	xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
    	version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
    
    	<portlet>
    		<portlet-name>swf-booking-mvc</portlet-name>
    		<display-name>Spring Webflow Booking MVC</display-name>
    
    		<portlet-class>
    			org.springframework.web.portlet.DispatcherPortlet
    		</portlet-class>
    
    		<init-param>
    			<name>contextConfigLocation</name>
    			<value>
    				/WEB-INF/config/hotelbooking-portlet-config.xml
    			</value>
    		</init-param>
    
    		<init-param>
    			<name>viewRendererUrl</name>
    			<value>/WEB-INF/servlet/view</value>
    		</init-param>
    
    		<expiration-cache>0</expiration-cache>
    
    		<supports>
    			<mime-type>text/html</mime-type>
    			<portlet-mode>view</portlet-mode>
    			<portlet-mode>edit</portlet-mode>
    		</supports>
    
    		<portlet-info>
    			<title>Spring Webflow Booking MVC</title>
    		</portlet-info>
    
    	</portlet>
    
    </portlet-app>
    mvc + wf config:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:webflow="http://www.springframework.org/schema/webflow-config"
           xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
               http://www.springframework.org/schema/webflow-config
               http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd">
    
    	<!-- Maps portlet modes to handlers -->	
    	<bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
    		<property name="portletModeMap">
    			<map>
    				<entry key="view">
    					<bean class="org.springframework.webflow.samples.booking.ViewFlowHandler"/>
    					
    				</entry>
    				<entry key="edit">
    					<bean class="org.springframework.webflow.samples.booking.edit.EditFlowHandler"/>
    				</entry>
    			</map>
    		</property>
    	</bean>
    
    	<!-- Maps logical view names selected by the url filename controller to .jsp view templates within the /WEB-INF directory -->	
    	<bean id="internalJspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="prefix" value="/WEB-INF/" />
    		<property name="suffix" value=".jsp" />
    	</bean>
    	
    	<!-- Enables FlowHandlers -->
    	<bean class="org.springframework.webflow.mvc.portlet.FlowHandlerAdapter">
    		<property name="flowExecutor" ref="flowExecutor"/>
    	</bean>
    
    	<!-- Executes flows: the central entry point into the Spring Web Flow system -->
    	<webflow:flow-executor id="flowExecutor">
    		<webflow:flow-execution-listeners>
    			<webflow:listener ref="jpaFlowExecutionListener" />
    		</webflow:flow-execution-listeners>
    	</webflow:flow-executor>
    	
    	<!-- The registry of executable flow definitions -->
    	<webflow:flow-registry id="flowRegistry">
    		<webflow:flow-location path="/WEB-INF/flows/edit/edit.xml" />
    		<webflow:flow-location path="/WEB-INF/flows/view/view.xml" />
    	</webflow:flow-registry>	
    		
    	<!-- Installs a listener that manages JPA persistence contexts for flows that require them -->
    	<bean id="jpaFlowExecutionListener" class="org.springframework.webflow.persistence.JpaFlowExecutionListener">
    		<constructor-arg ref="entityManagerFactory" />
    		<constructor-arg ref="transactionManager" />
    	</bean>
    		
    </beans>
    ViewFlowHandler.java

    Code:
    package org.springframework.webflow.samples.booking;
    
    import org.apache.log4j.Logger;
    import org.springframework.webflow.mvc.portlet.AbstractFlowHandler;
    
    public class ViewFlowHandler extends AbstractFlowHandler {
    
    	private Logger logger = Logger.getLogger(this.getClass());
        public String getFlowId() {
        	return "view";
        }
    
    }
    EditFlowHandler.java

    Code:
    package org.springframework.webflow.samples.booking.edit;
    
    import org.apache.log4j.Logger;
    import org.springframework.webflow.mvc.portlet.AbstractFlowHandler;
    
    public class EditFlowHandler extends AbstractFlowHandler {
    
    	private Logger logger = Logger.getLogger(this.getClass());
        public String getFlowId() {  
    	return "edit";
        }
    
    }
    As you see there are two flowhandlers mapped to each mode, however in the trace I get when I click the edit icon I see:

    log:
    Code:
    2009-03-24 16:05:21 [DEBUG] [org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping.getHandlerInternal(AbstractMapBasedHandlerMapping.java:70)] 
    Key [edit] -> handler [org.springframework.webflow.samples.booking.edit.EditFlowHandler@1646de5]
    
    2009-03-24 16:05:21 [DEBUG] [org.springframework.web.portlet.DispatcherPortlet.getHandlerAdapter(DispatcherPortlet.java:965)] 
    Testing handler adapter [org.springframework.webflow.mvc.portlet.FlowHandlerAdapter@d22860]
    
    
    2009-03-24 16:05:21 [DEBUG] [org.springframework.webflow.conversation.impl.ContainedConversation.lock(ContainedConversation.java:67)] 
    Locking conversation 2
    
    2009-03-24 16:05:21 [DEBUG] [org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository.getFlowExecution(DefaultFlowExecutionRepository.java:95)] 
    Getting flow execution with key 'e2s1'
    
    2009-03-24 16:05:21 [DEBUG] [org.springframework.webflow.definition.registry.FlowDefinitionRegistryImpl.getFlowDefinition(FlowDefinitionRegistryImpl.java:58)] 
    Getting FlowDefinition with id 'view'
    ... As appears right above, although it receives the key "edit" mapped to the EditFlowHandler it finally gets the FlowDefinition with id "view"... ???????

    Any idea of what's wrong?

    Thanks!
    Last edited by spring-like-jose; Mar 24th, 2009 at 10:25 AM.

  2. #2

    Default

    According to the reference "The portlet container passes the execution key from the previous flow when switching to a new mode. Even if the mode is mapped to a different FlowHandler the flow execution will resume the previous execution". So I guess there's no way of making it work with the default jetspeed buttons. Am I right?

    So I've tried to change it using a link like this:

    Code:
    <portlet:actionURL var="actionUrl" portletMode="edit">
    </portlet:actionURL>
    <a href="${actionUrl}">
    	Go to edit mode
    </a>
    ...but it doesn't work either. Debugging the wf code I've noticed that when it processes the action in FlowHandlerAdapter.handleAction(ActionRequest request, ActionResponse response, Object handler) it throws and exception because it doesn't find the flowExecutionKey... That's odd 'cause according to the reference ("One way to start a new flow is to create a URL targeting the mode without the execution key") it should start the new flow.

    What's the correct way to change the mode then??

    Please help!!
    Last edited by spring-like-jose; Mar 25th, 2009 at 11:24 AM.

  3. #3
    Join Date
    Nov 2004
    Posts
    24

    Default

    Hi Spring like Jose,

    Have you managed to find a solution for this problem? I'm facing the same problem.

    Regards,

    Marc

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •