我們有一個問題在我們的登錄頁面有一個使用post方法的表單,問題是有時候post參數對於服務器來說是空的,但它們不爲空。表單驗證器的行爲與參數沒有輸入一樣。我把我的表單代碼放在下面。你有任何想法或直覺?Wicket表單提交數據丟失
protected class LoginForm extends OurForm {
private static final long serialVersionUID = -5813819309808445973L;
public LoginForm(String id) {
super(id);
setDefaultModel(new CompoundPropertyModel<Map<Object , Object>>(iMap));
TextField<String> userId=new TextField<String>("USERCODE" , String.class);
userId.setOutputMarkupId(true);
userId.setRequired(true);
add(userId);
PasswordTextField password = new PasswordTextField("USERPASSWORD");
password.setOutputMarkupId(true);
password.setRequired(true);
add(password);
add(new SubmitLink("SUBMIT"));
}
通過檢票口生成的HTML形式的代碼:
<form autocomplete="off" id="id2" method="post" action=";jsessionid=989511050F24C577A23CF7CC55BC9757.salacakEUPT?x=UYCQLoTt3sXylAFd5u7DPGpiOKN9Mx4oErlMwLtbLndItHXg9LDIrg"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="id2_hf_0" id="id2_hf_0" /></div>
<table width="100%">
<tr><td colspan="3"><h2> </h2></td></tr>
<tr><td width="10%"> </td>
<td width="80%">
<table width="100%">
<tr><td colspan="2" height="100"> </td></tr>
<tr>
<td align="right" width="50%"><label class="label" >Kullanıcı Kodu</label></td>
<td align="left" width="50%"><input type="text" value="" name="USERCODE" id="id3"/></td>
</tr>
<tr>
<td align="right"><label class="label" >Şifre</label></td>
<td align="left" ><input type="password" value="" name="USERPASSWORD" id="id4"/></td>
</tr>
<tr><td colspan="2" height="20"> </td></tr>
<tr><td colspan="2" align="center"><input type="submit" id="id5" onclick="var wcall=euptWicketSubmitFormById('id2', ';jsessionid=989511050F24C577A23CF7CC55BC9757.salacakEUPT?x=UYCQLoTt3sXylAFd5u7DPIvNsZm6zLH4Nn8IO6OcpRl09M**bsF1rsqDb-hhJWazVdFfqhn-IWmQiM30HCroAnex3YAslQLnMwTnZBT5fO6Cuav6A95RGA', 'SUBMIT' ,function() { }.bind(this),function() { }.bind(this), function() {return Wicket.$$(this)&&Wicket.$$('id2')}.bind(this));;; return false;" submitlink="true" value="Giriş"/></td></tr>
<tr><td colspan="2" height="100"> </td></tr>
</table>
</td>
<td width="10%"></td></tr></table>
</form>
注:有時會出現此問題不是每次。
我們在代碼中使用compoundpropertymodel這行代碼就是這樣。 setDefaultModel(new CompoundPropertyModel
我們所有的頁面都使用這個模型,我們通過地圖達到組件值 –
你的代碼片段並不顯示你如何閱讀表單處理的結果。 –