Reputation: 4130
I need to run an AJAX method from one of the pages in my webflow. According to the docs, this is what RequestContextHolder is for.
So, here is my method:
@RequestMapping(value="training/test", method=RequestMethod.POST)
public GridItem getGridItems() {
RequestContext requestContext = RequestContextHolder.getRequestContext();
Set<String> fsKeyset = requestContext.getFlowScope().asMap().keySet();
for (String key: fsKeyset) {
log.debug(key);
}
Form form = (Form) requestContext.getFlowScope().get("form");
return form.getGridItem();
}
Unfortunately, the RequestContext is null. Is there something special I need to do to actually GET the RequestContext?
Jason
Upvotes: 1
Views: 1497
Reputation: 3198
Lets say your flow/view definition look like this
<view id="someId" view="someView" model="entity">
<transition on="ajaxSave" to="handleAjaxActionState"/>
<transition on="save" to="handleStandardSave"/>
</view>
then the bare min for your ajax url would look like:
url=${flowExecutionUrl}&_eventId=ajaxSave&ajaxSource=true
executing this (while you are still inside "someId" view state) will then get picked up in the "ajaxSave" transition.
disclaimer: I did not test the above example.
Upvotes: 1