Johnathan Smith
Johnathan Smith

Reputation: 1112

How to set off a Spring WebFlow transition in javascript

I have a Spring WebFlow2 project that if the user clicks the "loadschools" submit button I will call to my controller and load the states and then redisplay the same screen with the new states based on a radio button that is selected. I would like to remove the "loadschool" submit button and have java script run if the user clicks a radio button. can this be done? how do I tell webflow the transition to run?

<view-state id="SchoolVisitReport" view="SchoolVisitReport.jsp" model="visit" >
 <transition on="submit" to="addVisit">
   <evaluate expression="flowActions.validateVisit(visit, messageContext)"/>
 </transition>
 <transition on="cancel" to="endState" bind="false"/>
 <transition on="loadSchools" to="SchoolVisitReport" >
    <evaluate expression="flowActions.initializeSelectableStates(visit)" result="flowScope.selectableStates"/>
 </transition>
</view-state>

Upvotes: 0

Views: 3697

Answers (2)

rptmat57
rptmat57

Reputation: 3767

for your second issue, try

<script type="text/javascript">
                    Spring.addDecoration(new Spring.AjaxEventDecoration({
                        elementId : "radiobuttonId",
                        formId : "visitFormId",
                        event : "onChange",
                        params : {
                            _eventId : "loadSchools",
                            fragments : "body"
                        }
                    }));
                </script>

and see if the form gets submitted

Upvotes: 0

rptmat57
rptmat57

Reputation: 3767

onchange='window.location="${flowExecutionUrl}&_eventId=loadSchools"'

Upvotes: 1

Related Questions