1

Springs Web Flow に問題があります。ユーザーがフォーム送信ボタンをクリックすると、Beanに正しい値が含まれます。

たとえば、性別フィールドは MALE または FEMALE になります。しかし、その後、AjaxEventDecorationを追加して、実際にはform:selectである性別ドロップダウン ボックスの変更時に送信し、Beanで elementId である値「sex」を取得します。以下は私のコードです。確認して、あなたの考えを教えてください...この値をできるだけ早く修正する必要があります...

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>



<style type="text/css" media="screen">
 @import url("<c:url value="/resources/dojo/resources/dojo.css"/>");
 @import url("<c:url value="/resources/dijit/themes/claro/claro.css"/>");
</style>     

<script djconfig="parseOnLoad: true"
 src="<c:url value="/resources/dojo/dojo.js"/>" type="text/javascript"></script>
<script type="text/javascript"
 src="<c:url value="/resources/spring/Spring.js" />"> </script>
<script type="text/javascript"
 src="<c:url value="/resources/spring/Spring-Dojo.js" />"></script>
<script type="text/javascript">dojo.require("dojo.parser");</script>

<html>
<head>
<title>Spring 3.0 MVC - Web Flow Example</title>
</head>
<body class="claro">
    <h2>Dropdown Test</h2>

    <form:form commandName="customer" id="customer">
        <input type="hidden" name="_flowExecutionKey"
            value="${flowExecutionKey}" />
        <div id="container">
            <table>
                <tr>
                    <td><font color=red><form:errors path="sex" /></font><b>Sex:</b></td>
                    <td><form:select path="sex" id="sex">
                            <form:option value="MALE" label="MALE" />
                            <form:option value="FEMALE" label="FEMALE" />
                        </form:select> 

                        <script type="text/javascript">
                        Spring.addDecoration(new Spring.ElementDecoration({
                            elementId : "sex",
                            widgetType : "dijit.form.Select",
                            widgetAttrs : {
                            promptMessage : "Enter Sex",
                            required : true }}));
                         </script></td></tr>
                </table>
        </div>

        <input type="submit" name="_eventId_submit" id="submit" value="Submit" />
        <input type="submit" name="_eventId_cancel" value="Cancel" />
        <p>
        <script type="text/javascript">
            Spring.addDecoration(new Spring.ValidateAllDecoration({
                elementId : 'submit',
                event : 'onclick'
            }));

            Spring.addDecoration(new Spring.AjaxEventDecoration({
                 elementId: "sex",
                 event: "onChange",
                 formId:"customer",
                 params: {fragments:"body", _eventId: "loadSchools"}}));
        </script>
    </form:form>
</body>
</html>
4

2 に答える 2

1

</b>「アクティブ」の後に閉じる必要はありませんが</n>
これらのことは、あなたが抱えているような奇妙な問題につながることがあります

修正して、もう一度やり直してください

[編集]私はあなたに解決策を見つけましたpb:基本的に選択の装飾とajaxイベントを削除し、次のようにします:

<tr>
    <td><font color=red><form:errors path="sex" /></font><b>Sex:</b></td>
    <td><form:select path="sex" id="sex" required="true" data-dojo-type="dijit/form/Select" onchange="Spring.remoting.submitForm('sex', 'customer', {fragments:'body', _eventId: 'loadSchools'}); return false;">
            <form:option value="MALE" label="MALE" />
            <form:option value="FEMALE" label="FEMALE" />
        </form:select>
   </td>
</tr>

装飾の選択に問題があるようです...別の方法を見つけることができるかどうかを確認しようとしますが、これをテストして動作します

于 2012-10-12T13:31:48.440 に答える
0

問題を修正しました。Spring.AjaxEventDecoration呼び出しを削除し、Spring.ElementDecorationを次のように変更しました。

<script type="text/javascript">
                        Spring.addDecoration(new Spring.ElementDecoration({
                            elementId : "sex",
                            widgetType : "dijit.form.Select",
                            widgetAttrs : {
                            promptMessage : "Enter Sex",
                            required : true, 
                            onChange : function() {
                                Spring.remoting.submitForm(
                                    'submit', 
                                    'customer', 
                                    {_eventId: 'sexchange', fragments:'contents'}
                                 ); 
                                 return false;
                            } }}));


                    </script>

Ajax 呼び出しが機能しなかった理由については 100% 明確ではありませんが、プロジェクトでこのコードを使用できるようになりました。

于 2012-10-12T16:37:42.737 に答える