當觸發事件「onkeyup」時,獲取輸入數據時遇到小問題。我有這樣的投入和其他DATAS:獲取帶有事件「onkeyup」的輸入數據
// El-cheapo model for form
private static final ValueMap cheapModel = new ValueMap();
//some code...
//...
Form form = new Form("pushNotificationForm");
form.setOutputMarkupId(true);
final Label actualSizeLabel = new Label(ACTUAL_NOTIFICATION_SIZE_ID, new Model<String>(actualSize));
actualSizeLabel.setOutputMarkupId(true);
final TextField<String> titleTextField = new TextField<String>(TITLE_TEXTFIELD_ID, new PropertyModel<String>(
cheapModel, TITLE_TEXTFIELD_ID));
titleTextField.setRequired(true);
titleTextField.add(new AjaxEventBehavior("onkeyup")
{
@Override
protected void onEvent(AjaxRequestTarget ajaxRequestTarget)
{
actualSize = Integer.toString((getTitle()).getBytes().length);
ajaxRequestTarget.add(actualSizeLabel);
}
});
form.add(titleTextField);
form.add(actualSizeLabel);
//.. some code
//later
private String getTitle()
{
return cheapModel.getString(TITLE_TEXTFIELD_ID);
}
的actualSize保持爲空,直到我提交表單,但是爲什麼呢?任何幫助請
因爲您沒有提交數據。 – bert 2012-02-24 17:08:09