Results 1 to 3 of 3

Thread: scope problem

  1. #1
    Join Date
    Oct 2004
    Location
    Germany
    Posts
    143

    Default scope problem

    Hi,

    i have a problem with a object.

    the code:

    one simple object called calendar

    a FrormAction called CalendarFormAction

    an two JSPs one for entering the data and a second to show them.

    the Flow is simple:

    Code:
    <webflow id="calendar" start-state="setupForm">
    
    	<action-state id="setupForm">
    		<action bean="calendar.formAction"/>
    		<transition on="success" to="calendar.view"/>
    	</action-state>
    	
    	<view-state id="calendar.view" view="calendar.view">
    		<transition on="save" to="calendar.save"/>
    	</view-state>
    
    	<action-state id="calendar.save">
    		<action bean="calendar.formAction" method="onSave"/>
    		<transition on="success" to="calendar.show"/>
    	</action-state>
    
    	<end-state id="calendar.show" view="calendar.show"/>		
    
    </webflow>
    the beans config:

    Code:
    <beans>
    	<bean id="eventCalendarFrontController" name="/index.htm" class="org.springframework.web.flow.mvc.FlowController">
    		<property name="cacheSeconds"><value>0</value></property>
    	</bean>
    	<bean id="calendarFrontController" name="/calendar.htm" class="org.springframework.web.flow.mvc.FlowController">
    		<property name="cacheSeconds"><value>0</value></property>
    		<property name="flowExecutionManager">
    			<bean class="org.springframework.web.flow.execution.servlet.HttpServletFlowExecutionManager">
    				<property name="flow" ref="calendar.flow"/>
    			</bean>
    		</property>
    	</bean>
    	<bean id="calendar.flow" class="org.springframework.web.flow.config.FlowFactoryBean">
    		<property name="flowBuilder">
    			<bean class="org.springframework.web.flow.config.XmlFlowBuilder">
    				<property name="resource"><value>/WEB-INF/calendar-flow.xml</value></property>
    			</bean>
    		</property>
    	</bean>
    	
    	<bean id="calendar" class="de.mk.jsek.model.Calendar"/>
    
    	<bean id="calendar.formAction" class="de.mk.jsek.web.flow.CalendarFormAction">
     		<property name="formObjectName"><value>calendar</value></property>
    		<property name="formObjectClass"><value>de.mk.jsek.model.Calendar</value></property>
    		<property name="formObjectScopeAsString"><value>flow</value></property>
     		<property name="calendarDao"><ref bean="calendarDAOHibernate"/></property>
    	</bean>
    	<bean id="calendarDAOHibernate" class="de.mk.jsek.dao.hibernate.CalendarDAOHibernate"/>
    
    	<bean id="conversion.service" class="org.springframework.binding.convert.support.DefaultConversionService" autowire="byType"/>
    	<bean id="formatter.locator" class="org.springframework.binding.format.support.ThreadLocalFormatterLocator" autowire="byType"/>
    	<bean id="thread.cleanupBroadcaster" class="org.springframework.binding.thread.support.DefaultThreadCleanupBroadcaster"/>
    
    	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="prefix"><value>/WEB-INF/jsp/</value></property>
    		<property name="suffix"><value>.jsp</value></property>
    	</bean>
    
    </beans>
    now when i get the Object with this command at the CalendarFormAction Method onSave:



    Code:
    public Event onSave&#40;RequestContext context&#41; throws Exception &#123;
            Calendar calendar = &#40;Calendar&#41;context.getFlowScope&#40;&#41;.get&#40;"calendar"&#41;;
            context.getRequestScope&#40;&#41;.setAttribute&#40;"calendar", calendar&#41;;
            System.out.println&#40;"on saving Calendar "+ context.getRequestScope&#40;&#41;.getAttributeMap&#40;&#41;&#41;;
            System.out.println&#40;"on saving Calendar "+ context.getRequestScope&#40;&#41;.entrySet&#40;&#41;&#41;;
            System.out.println&#40;"on saving Calendar "+ context.getFlowScope&#40;&#41;.getAttributeMap&#40;&#41;&#41;;
            System.out.println&#40;"on saving Calendar "+ context.getFlowScope&#40;&#41;.entrySet&#40;&#41;&#41;;
            
            System.out.println&#40;"Calendar" +calendar.getName&#40;&#41;&#41;;
            return success&#40;&#41;;
        &#125;
    the calendar object are new. no data i entered at the jsp is inside.

    this is my first test of Spring WebFlow so can someone help me to find my mistake?

    thanks

    mfg Gideon

  2. #2
    Join Date
    Oct 2004
    Location
    Germany
    Posts
    143

    Default

    Hi,

    sorry for that post, i have found my mistake, i have forgot to bindAndValidate
    (i was to lazy implementing a validator)

    now it works perfect,

    mfg Gideon

  3. #3
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    The forum works as an excellent "rubber ducky": explaining a problem to someone, even a rubber duck (or yourself) often leads you to finding the solution :-)

    Erwin

Similar Threads

  1. Hibernate Long Session Per Flow?
    By akw in forum Web Flow
    Replies: 21
    Last Post: Dec 12th, 2005, 08:06 PM
  2. Replies: 4
    Last Post: Aug 26th, 2005, 01:35 PM
  3. Replies: 1
    Last Post: Jul 5th, 2005, 03:48 AM
  4. pagination and continuation problem in SWF
    By yfmoan in forum Web Flow
    Replies: 6
    Last Post: Jun 29th, 2005, 03:42 AM
  5. Lazy Load Problem when Doing UnitTest
    By yoshi in forum Data
    Replies: 7
    Last Post: Sep 29th, 2004, 10:00 AM

Posting Permissions

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