0

装飾にはSpring 3.0.5、Webflow 2.3.0、およびSpring JSを使用しています。

私のフォームの1つに次のコードがあります:

<form:select path="selection">
    <form:option value="" label="Please select"></form:option>
    <form:options></form:options>
</form:select>

<noscript>
 <button id="btnSelect" type="submit" name="_eventId_dropDownSelectionChange">Select</button>
</noscript>

<script type="text/javascript">
Spring.addDecoration(new Spring.ElementDecoration({
    widgetType : "dijit.form.Select",
    widgetAttrs : {
        forceWidth : true,
        missingMessage : "<s:message code="NotEmpty" />",
    }
}));

Spring.addDecoration(new Spring.AjaxEventDecoration({
    elementId : "selection",
    formId : "templateModel",
    event : "onChange",
    params : {  _eventId: "dropDownSelectionChange" }
})); 
</script>

意図は、ドロップダウンで選択されたものに応じて、フォームの 2 番目の部分をレンダリングすることです。これは、ドロップダウンの onChange で AJAX 呼び出しを使用するか、noscript の場合は [選択] ボタンを押すことで実現できます。

物事のノースクリプト側が機能します。ドロップダウンで何かを選択し、[選択] を押すと、フォームの残りの部分が更新時にレンダリングされます。

ただし、AJAX 呼び出しの要求には、選択したばかりの値が含まれていません。Dijit コンポーネントがその表現を更新する前に、AJAX 呼び出しが発生したかのようです。これらのコンポーネントは、私が使用している方法で互換性がありますか?

次の場合に動作させることができます。

  1. コンポーネントを Dijit コンポーネントとして装飾するのではなく、onclick AJAX 装飾を使用した通常のドロップダウンにします。
  2. Dijit onChange ではなくボタンに AJAX 呼び出しを配置し​​ました
4

1 に答える 1

0

同じ問題に直面し、その回避策は選択された値を非表示フィールドに設定することであり、Spring.AjaxEventDecoration が残りを処理します。

                <input id="vehicleType" name="vehicleType" type="hidden" />
                    <select id="selectVehicle">
                        <c:forEach var="vehicle" items="${vehicleTypes}">
                            <option value="${vehicle.type}"><fmt:message key="${vehicle.description}" /></option>
                        </c:forEach>
                    </select>
                </p>
                <script type="text/javascript">
                    Spring.addDecoration(new Spring.ElementDecoration({
                        elementId : 'selectVehicle',
                        widgetType : "dijit.form.Select",
                        widgetAttrs : {
                            value : "${vehicleType}",
                            onChange : function(newValue){
                            document.getElementById('vehicleType').value=dijit.byId('selectVehicle').get('value');}
                        }                           
                    }));
                    Spring.addDecoration(new Spring.AjaxEventDecoration({
                        elementId : "selectVehicle",
                        formId : "quote",
                        event : "onChange",
                        params : {
                            _eventId : "dropDownVehicleSelectionChange",
                            fragments : "body"

                        }
                    }));
                </script>
于 2011-09-26T00:17:42.877 に答える