View Full Version : XMLFLowBuilder and event identification
jocsch
Apr 19th, 2005, 08:04 AM
Hi,
after reading through the docs I think it must be possible to create own transitions. But I cant figure out how. Especially if I use the XMLFlowBuilder.
Through all our struts application html:image buttons are used to submit the forms. That results into a URL that looks like: nextButton.x=17&nextButton.y=3
It would be quite cool to parse for (1)Button.x= and have (1) as the name for the transition.
Is this possible?
Markus
jocsch
Apr 19th, 2005, 08:31 AM
OK, found it on my own. Just for the record:
<bean id="sellItem" class="org.springframework.web.flow.config.FlowFactoryBea n">
<property name="flowBuilder">
<bean class="org.springframework.web.flow.config.XmlFlowBuilder">
<property name="resource" value="/WEB-INF/sellItem-flow.xml"/>
<property name="transitionCriteriaCreator">
<!-- Enable transition criteria expressed as OGNL expressions. -->
<bean class="org.springframework.web.flow.support.OgnlTransitio nCriteriaCreator"/>
</property>
</bean>
</property>
</bean>
jocsch
Apr 19th, 2005, 09:11 AM
Ups. I was too fast with my reply. I found out how to change the transitioncriteria, but it doesn't solve my issue because it seems only to listen for _eventID.
Hm, any chance to solve my initial problem? Or doesn't it make sense in this context. I don't want to set the _eventID via javascript to distinguish between the different buttons.
klr8
Apr 19th, 2005, 10:47 AM
Using image buttons is already supported, but you need to 'name' your button differently:
<INPUT type="image" name="_eventId_next" ... >
Check this link for more info (searchForParameter method):
http://www.springframework.org/docs/webflow-pr2-api/org/springframework/web/flow/execution/ExternalEvent.html
Erwin
jocsch
Apr 19th, 2005, 12:01 PM
Do I have to configure anything special for that? I get the following exception if I just change the name of the button:
849722 [P1-7] WARN org.apache.struts.action.RequestProcessor - Unhandled Exception thrown: class org.springframework.web.flow.NoMatchingTransitionE xception
849722 [P1-7] WARN xyz - /register.html?_flowExecutionId=D15ADADC-B632-01C4-93B4-672B0BE2D2C9&page=1&_eventId_numbers.x=12&_eventId_numbers.y=0:
org.springframework.web.flow.NoMatchingTransitionE xception: No transition found for event 'numbers.y' in state 'step1View' of flow 'register' -- valid transitional criteria are set[next, numbers] -- likely programmer error, check the set of TransitionCriteria for this state
at org.springframework.web.flow.TransitionableState.t ransitionFor(TransitionableState.java:139)
at org.springframework.web.flow.FlowExecutionStack.si gnalEvent(FlowExecutionStack.java:275)
at org.springframework.web.flow.execution.FlowExecuti onManager.handle(FlowExecutionManager.java:244)
at org.springframework.web.flow.struts.FlowAction$Str utsFlowExecutionManager.handle(FlowAction.java:191 )
at org.springframework.web.flow.struts.FlowAction.doE xecuteAction(FlowAction.java:148)
at org.springframework.web.struts.TemplateAction.exec ute(TemplateAction.java:177)
at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:421)
at com.test.xyz.webapp.struts.CustomBindingRequestPro cessor.process(CustomBindingRequestProcessor.java: 115)
at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doGet(Actio nServlet.java:397)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:595)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:688)
at org.mortbay.jetty.servlet.ServletHolder.handle(Ser vletHolder.java:427)
at org.mortbay.jetty.servlet.WebApplicationHandler$Ca chedChain.doFilter(WebApplicationHandler.java:822)
at net.sf.acegisecurity.util.FilterChainProxy$Virtual FilterChain.doFilter(FilterChainProxy.java:300)
at net.sf.acegisecurity.intercept.web.FilterSecurityI nterceptor.invoke(FilterSecurityInterceptor.java:8 4)
at net.sf.acegisecurity.intercept.web.SecurityEnforce mentFilter.doFilter(SecurityEnforcementFilter.java :181)
at net.sf.acegisecurity.util.FilterChainProxy$Virtual FilterChain.doFilter(FilterChainProxy.java:311)
at net.sf.acegisecurity.ui.AbstractProcessingFilter.d oFilter(AbstractProcessingFilter.java:372)
at net.sf.acegisecurity.util.FilterChainProxy$Virtual FilterChain.doFilter(FilterChainProxy.java:311)
at net.sf.acegisecurity.context.HttpSessionContextInt egrationFilter.doFilter(HttpSessionContextIntegrat ionFilter.java:217)
at net.sf.acegisecurity.util.FilterChainProxy$Virtual FilterChain.doFilter(FilterChainProxy.java:311)
at net.sf.acegisecurity.util.FilterChainProxy.doFilte r(FilterChainProxy.java:179)
at net.sf.acegisecurity.util.FilterToBeanProxy.doFilt er(FilterToBeanProxy.java:125)
at org.mortbay.jetty.servlet.WebApplicationHandler$Ca chedChain.doFilter(WebApplicationHandler.java:813)
at org.mortbay.jetty.servlet.WebApplicationHandler.di spatch(WebApplicationHandler.java:494)
at org.mortbay.jetty.servlet.ServletHandler.handle(Se rvletHandler.java:569)
at org.mortbay.http.HttpContext.handle(HttpContext.ja va:1482)
at org.mortbay.jetty.servlet.WebApplicationContext.ha ndle(WebApplicationContext.java:624)
at org.mortbay.http.HttpContext.handle(HttpContext.ja va:1434)
at org.mortbay.http.HttpServer.service(HttpServer.jav a:896)
at org.mortbay.http.HttpConnection.service(HttpConnec tion.java:814)
at org.mortbay.http.HttpConnection.handleNext(HttpCon nection.java:981)
at org.mortbay.http.HttpConnection.handle(HttpConnect ion.java:831)
at org.mortbay.http.SocketListener.handleConnection(S ocketListener.java:244)
at org.mortbay.util.ThreadedServer.handle(ThreadedSer ver.java:366)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadP ool.java:534)
klr8
Apr 19th, 2005, 02:09 PM
You don't have to configure anything for it, but there is a very stupid bug in the searchForParameter() method...
I fixed it and added a unit test that verifies correct behaviour.
You can either wait for the PR3 release (which is only a couple of days away), or grab the latest & greatest from CVS (note that you need Spring 1.2 RC2).
Erwin
2min4roughing
Jul 20th, 2005, 02:16 PM
I'm using PR4 and am a not able to get a state transition to occur when using an image for the submit button on my form.
Here's my flow:
<webflow id="dbconntool" start-state="prepareSearchForm">
<action-state id="prepareSearchForm">
<action bean="searchConnectionsAction" method="setupForm"/>
<transition on="success" to="showSearchForm"/>
</action-state>
<view-state id="showSearchForm" view="swf/search">
<transition on="submit" to="validateSearchForm"/>
</view-state>
<action-state id="validateSearchForm">
<action bean="searchConnectionsAction" method="bindAndValidate"/>
<transition on="success" to="searchConnections"/>
<transition on="error" to="prepareSearchForm"/>
</action-state>
<action-state id="searchConnections">
<action bean="searchConnectionsAction" method="processForm"/>
<transition on="success" to="displayConnections"/>
<transition on="error" to="prepareSearchForm"/>
</action-state>
<end-state id="displayConnections" view="swf/listConnections"/>
</webflow>
I'm simply start a new flow and the flow executes through to the first view state, "showSearchForm".
I followed the instructions in this thread with modifications given in the ServletEvent javadoc in PR4. Here's the HTML for the image button:
<input type="image" name="_mapped_eventId" value="submit" src="/assets/images/common/buttons/yl_submit_v1_en.gif" alt="Search by username">
When I click the submit image button, the debug output from SWF indicates that the ServletEvent is considered a start event and the flow is restarted. The debug output shows the event has parameters representing the mouse click: "_mapped_eventId.x" and "_mapped_eventId.y".
What am I doing wrong? Should I create my own TransitionCriteria and register it with the view state?
TIA,
Jason Southern
Keith Donald
Jul 20th, 2005, 03:53 PM
Jason,
It should be:
<INPUT type="image" name="_eventId_submit" ... >
.. where submit is the actual event id...
Are you also passing in the ${flowExecutionId} as a parameter? You need to do this to ensure you tell the flow execution manager which executing flow you are participating in...
Keith
Keith Donald
Jul 20th, 2005, 04:04 PM
I've further refined the docs for ServletEvent:
/**
* Obtain this event's id from the parameter map.
* <p>
* This is a multi-step process consisting of:
* <ol>
* <li>Try the _eventId parameter first, if it is present, return its value
* as the eventId.
* <li>Try a parameter search looking for parameters of the format:
* _eventId_value. If a match is found, return the value as the eventId.
* <li>Try the _mapped_eventId request attribute
* <li>
* @param eventIdParameterName name of the event id parameter in the request (default=_eventId)
* @param eventIdAttributeName name of the event id attribute in the request (default=_mapped_eventId)
* @param parameterValueDelimiter delimiter used when a parameter value is
* sent as part of the name of a request parameter
* (e.g. "_eventId_value=bar", default=_)
* @return the event id, or null if not found
*/
2min4roughing
Jul 20th, 2005, 05:24 PM
Keith,
Thanks! I had failed to include the parameter _flowExecutionId in my form. Somewhere in my reading of the practical guide and the API, I missed this requirement.
I'd love to be able to have the flowId and flowExecutionId associated with the user's HttpSession, so that URLs and forms don't have to always include it in the request. Seems that a FlowExecutionManager should be able to associate a ServletEvent with a flow and execution by obtaining this information from the HttpSession. I'm just not clear on how to do it. Maybe the answer is to declare a ServletFlowExecutionManager instance in my app's spring-beans file and inject it into the FlowController.
Can you point me to any documents or samples that address this and performance considerations? (i'm happy to read up as this seems like a big request)
Jason
klr8
Jul 21st, 2005, 06:22 AM
Take a look at the FlowExecutionManager and its 'getFlowExecutionId()' method. You'll have to subclass FlowExecutionManager (or probably ServletFlowExecutionManager) and override that method, then you can inject your custom manager into the FlowController.
Erwin
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.