ani
ani

Reputation: 516

Evaluate expression in spring web flow

I am new to Spring framework learning Spring mvc and spring web flow . I came across an evaluate expression in action state

<evaluate expression = " requestParameters.ishotelbooking" result="flowScope.hotelbooking" />

Couldn't able to figure it out what is actually happening ?? And one more thing i understand that we are assigning flow scope for hotelbooking object but how the framework understands the hotelbooking is the object of hotel class ie how we can understand the type of object here .. can someone guide me .. Thanks in advance 😊

Upvotes: 1

Views: 4360

Answers (1)

rptmat57
rptmat57

Reputation: 3787

This evaluate expression is taking the "isHotelBooking" request parameter and copying it into a variable "hotelBooking" that will be available in the entire flow (flowScope)

So when the action state is called, probably after a transition, in a request like "flowTransition?isHotelBooking=true" the request parameter "isHotelBooking" is only available in the request. So the evaluate element is copying that into another variable available in the entire flow. Basically extending the scope of the variable from request to flow scope

FYI this could be replaced by

<set name="flowScope.hotelBooking" value="requestParameter.isHotelBooking"/>

[UPDATE]

For the type, the evaluate element has a result-type attribute that can be used to further define the type of the result. if not specified Webflow assumes it is of type Object.

The class/type is not always important since evaluation is done at runtime and using EL. Although it is useful if you are using an IDE (like IntelliJ or STS) so you can take advantage of auto-completion.

Upvotes: 3

Related Questions