Reputation: 1258
In my Spring Webflow (with JSP views) I have a model that contains an enum for one of its fields. I need a form with a set of radio buttons that contain only a couple of those possible enum values and I can't seem to crack how to do it.
So my flow is something like this:
<on-start>
<evaluate expression="someService.getModel()" result="flowScope.myModel" />
</on-start>
<view-state id="step1" view="step1View" model="myModel">
<transition on="proceed" to="step2"/>
</view-state>
And myModel has a field called "paymentType" which is an enum (called PaymentType) that could look soemthing like this:
public enum PaymentType{
RE("A paper reciept"),
CC("Credit Card"),
PA("Pre-Authorised Debit"),
MC("MyCoin"),
private final String shortDescription;
PaymentOptionType(final String shortDescription) {
this.shortDescription = shortDescription;
}
public String getShortDescription() {
return shortDescription;
}
}
So let's say in my step1 page I only want to put 2 of these values on the form. So it would look like:
* A paper reciept
* MyCoin
|Submit|
And it would bind the selected value to the paymentType field in the model.
So I'm wondering how to populate the radio buttons in my form in step1.jsp
<form:form id="paymentForm" name="paymentForm" modelAttribute="myModel" method="post" action="${flowExecutionUrl}">
<!-- What to put for radio buttons here? -->
<button name="_eventId_proceed">Next Step</button>
</form:form>
Upvotes: 0
Views: 1085
Reputation: 3787
try:
<form:radiobutton path="paymentType" value="RE"/>A paper receipt
<form:radiobutton path="paymentType" value="MC"/>My Coin
..
or add something like this to your flow
<on-start>
<evaluate expression="someService.getPaymentTypes()" result="flowScope.paymentTypes" />
</on-start>
and then use
<c:forEach var="paymentType" items="${paymentTypes}>
<form:radiobutton path="paymentType" value="${paymentType}"/>${paymentType.shortDescription}
</c:forEach>
Upvotes: 1