そのため、単一のフォーム オブジェクト/モデルを徐々に設定する Spring Web フローを使用して、ウィザード インターフェイスを設定しました。単一の文字列またはプリミティブ プロパティと文字列配列を (チェックボックス インターフェイスから) 設定する必要がある最初のいくつかの手順では問題なく動作します。
それから私はList<String>
財産を持っています。正しく初期化された値を持つ複数のテキストボックスとして適切にレンダリングされます。しかし、ブラウザでテキストボックスを編集して送信すると、値がフォーム Bean に反映されません。初期値のままです。
以下に詳細な設定を示します。
Bean を作成する開始時の Web フロー:
<on-start>
<evaluate expression="new mypackage.MyFormBean()" result="flowScope.myFormBean" />
</on-start>
私のフォーム Bean の関連部分は次のとおりです。
public class MyFormBean implements Serializable {
...
private List<SlotBean> slots;
...
public List<SlotBean> getSlots() {
return slots;
}
public void setSlots(List<SlotBean> slots) {
this.slots= slots;
}
...
}
public class SlotBean {
...
private int quantity;
...
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity= quantity;
}
...
}
Web フローに一連のビューステートがあり、フォームに問題なく初期化、表示、および保存される単純な文字列または数値フィールド バインディングが設定されています。
このビューステートは、任意の数の SlotBean オブジェクトを生成し、数量を 2 で初期化します。これらは、slots プロパティに設定されます。
<view-state id="generate-criteria" model="disciplineCatalogue">
...
<transition on="next" to="slots-grid">
<evaluate expression="myService.generateSlots(myFormBean)"/>
</transition>
...
</view-state>
これがjspフラグメントです。一連のテキストボックスをレンダリングするだけです。次のボタンもあります。
<form:form id="slotsGrid" modelAttribute="myFormBean" action="${flowExecutionUrl}">
...
<c:forEach var="slot" items="${myFormBean.slots}" varStatus="idx">
<form:input path="slots[${idx.index}].quantity" />
</c:forEach>
...
<button type="submit" id="next" name="_eventId_next">Next</button>
...
</form:form>
上記のコードは、初期値 (2) で正しく表示されます。以下のように複数のテキストボックスを生成します。
<input id="slots0.quantity" name="slots[0].quantity" type="text" value="2"/>
このページがブラウザ上にあるとき、数量テキストボックスの値を別の値に変更し、「次へ」ボタンをクリックします。ブラウザーのネットワーク デバッガーで、フォームの値がサーバーに送信されていることがわかります。
slots[0].quantity:3
slots[1].quantity:1
slots[2].quantity:2
次のボタンに関連する Web フロー エントリを次に示します。
<view-state id="slots-grid" model="myFormBean">
<binder>
...
<binding property="slots" />
</binder>
...
<transition on="next" to="finished">
<evaluate expression="myService.create(myFormBean)"/>
</transition>
...
</view-state>
そのため、メソッドにブレークポイントをmyService.create(myFormBean)
設定すると、すべての数量フィールドが元の「2」に設定されたままになっていることがわかります。新しい値は にバインドされませんでしたmyFormBean.slots
。
私のセットアップで間違っているように見えるものはありますか?
ありがとうございました。
春のフレームワーク 3.1.1
春の Webflow 2.3.1
トムキャット 6.0.18
エクリプス インディゴ