【发布时间】:2016-03-15 08:16:56
【问题描述】:
在我的 Spring Webflow(带有 JSP 视图)中,我有一个模型,其中包含一个枚举字段。我需要一个带有一组单选按钮的表单,其中仅包含几个可能的枚举值,但我似乎无法破解如何做到这一点。
所以我的流程是这样的:
<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>
myModel 有一个名为“paymentType”的字段,它是一个枚举(称为 PaymentType),可能看起来像这样:
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;
}
}
假设在我的第 1 步页面中,我只想将其中 2 个值放在表单上。 所以它看起来像:
* A paper reciept
* MyCoin
|Submit|
它会将选定的值绑定到模型中的 paymentType 字段。
所以我想知道如何在 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>
【问题讨论】:
标签: java spring forms jsp spring-webflow