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
<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 であるため、含まれているものにはヒットしません。