-
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(RequestContext context) throws Exception {
Calendar calendar = (Calendar)context.getFlowScope().get("calendar");
context.getRequestScope().setAttribute("calendar", calendar);
System.out.println("on saving Calendar "+ context.getRequestScope().getAttributeMap());
System.out.println("on saving Calendar "+ context.getRequestScope().entrySet());
System.out.println("on saving Calendar "+ context.getFlowScope().getAttributeMap());
System.out.println("on saving Calendar "+ context.getFlowScope().entrySet());
System.out.println("Calendar" +calendar.getName());
return success();
}
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
-
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
-
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