0

frmClock と呼ばれる私のフォーム内に、jQuery UI モーダル ダイアログの基礎として最終的に使用される div があります。

    <div id="dialog-form-clockout" title="Associate Mileage Reimbursement" data-ok="<%=clkContinueClockOut%>" data-cancel="<%=clkCancel%>" data-errornum="Invalid number format. Valid number format is 999.9" data-errorzero="Please enter a value greater than zero. Otherwise, select No." data-errormaxchars="Please enter a numeric value less than 5 characters long." data-errornoradio="Please select Yes or No.">
        <fieldset>        
            <div id="personalVehicle">
                <label for="<%=TAConstants.FN_ASM_RESPONSE%>">Did you use your personal vehicle for business travel during this shift?</label>
                <br>
                <input type="radio" name="<%=TAConstants.FN_ASM_RESPONSE%>" id="personalvehicle" class="text ui-widget-content ui-corner-all" value="Y"/>Yes
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="radio" name="<%=TAConstants.FN_ASM_RESPONSE%>" id="personalvehicle" class="text ui-widget-content ui-corner-all" value="N"/>No
                <br>
            </div>
            <div id="questionsY" class="hidden">
                <div class="modalDialogQuestions">
                    <label for="<%=TAConstants.FN_BANK_ROUND_TRIPS%>" class="modalDialogQuestionsLbl">Enter number of round-trips to the bank.</label>  
                    <select name="<%=TAConstants.FN_BANK_ROUND_TRIPS%>" class="modalDialogAnswers" id="roundtrips">
                        <option selected value="0">0</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                    </select>
                </div>
                <div class="modalDialogQuestions">
                    <label for="<%=TAConstants.FN_OTHER_MILES%>" class="modalDialogQuestionsLbl">Enter number of miles for business related travel other than the bank.</label>     
                    <input class="positive modalDialogAnswers" type="number" name="<%=TAConstants.FN_OTHER_MILES%>" id="mileage" value="0.0" maxlength=5/>
                </div>
            </div>
        </fieldset>
        <div class="ui-state-error hidden" style="height:auto;"><span class="ui-icon ui-icon-alert" style="display:inline; margin-right:.25em; float:left;"/></span><p class="validateTips" style="display:inline; border:0px;"></p></div>
    </div>
</form>

したがって、最終的にこの jQuery モーダル ダイアログ フォームに入力したら、この機能強化の前にフォーム送信に使用していたものと同じ JavaScript を使用します (さらに、このデータがドキュメント要素にあることを通知するアラートも使用します)。

    alert(document.getElementById('personalvehicle').value);
    alert(document.getElementById('roundtrips').value);
    alert(document.getElementById('mileage').value);

    submitForm();

...

/**
 *  This function disallows the form to be submitted twice.
 */
function submitForm () {
  if (!hasBeenSubmitted) {
    hasBeenSubmitted = true;
    document.frmClock.submit();
  }

アラートはユーザーが入力したものと同じテキストを表示しますが、jQuery モーダル ダイアログ フォームなしで過去に受け取った残りのフォーム データと一緒に送信されないようです。これは、null チェックに合格しないため、vars を設定していないように見える次のコードを使用して、プロセッサの .java ファイルから判断しています。

if (req.getParameter(FN_ASM_RESPONSE)!=null){
    Character asmResponse = (req.getParameter(FN_ASM_RESPONSE)).charAt(0);
}
if (req.getParameter(FN_BANK_ROUND_TRIPS)!=null){
    Integer bankRoundTrips = Integer.parseInt(req.getParameter(FN_BANK_ROUND_TRIPS));
}
if (req.getParameter(FN_OTHER_MILES)!=null){
    Float otherMiles = Float.parseFloat(req.getParameter(FN_OTHER_MILES));
}

私が聞いたほとんどのことは、入力にname属性があることを確認することです。これらの名前属性は設定されているようですが、ソースを表示すると、次の定数 .java ファイルから設定されたpersonalvehicle, roundtrips、およびとして表示されます。mileage

public static final String FN_ASM_RESPONSE = "personalvehicle";
public static final String FN_BANK_ROUND_TRIPS = "roundtrips";
public static final String FN_OTHER_MILES = "mileage";

私が何を調べたり試したりすべきかについて、誰かアイデアはありますか? getParameter() メソッドのブレークポイントは、null がこれらのポイントにヒットするかどうかを確認しますが、パラメーターが null であるため、含まれているものにはヒットしません。

4

1 に答える 1

1

問題は、jQuery UI が入力フィールドを含むダイアログをフォームの外に移動することです。

ダイアログの読み込み関数を変更して、ダイアログの作成時に実行される関数を追加し、それをフォームに戻すことができます。

$('#myDialog').dialog({  create: function () { $(this).parent().appendTo('form') } });
于 2013-01-22T13:35:13.557 に答える