Apache Wicket에 관한 질문 : 여러 텍스트 입력 필드가있는 양식이 있습니다. 그것은 DateTextField를 추가 할 때까지 제대로 작동합니다. 오버라이드 된 onSubmit() 메소드는 단순히 더 이상 호출되지 않습니다. Wicket 예제를 살펴 봤지만 내 코드와 큰 차이는 볼 수 없습니다.DateTimeField가있을 때 양식의 onSubmit 메서드가 호출되지 않는 이유는 무엇입니까?
<html xmlns:wicket="http://wicket.apache.org">
\t <head>
\t \t <title>Students</title>
\t </head>
\t <body>
\t \t <div class="container">
\t \t \t <form id="createStudent" wicket:id="createStudent">
\t \t \t \t <div>
\t \t \t \t \t <span id="lastNameLabel"><wicket:message key="lastNameLabel" /></span>
\t \t \t \t \t <input id="lastName" wicket:id="lastName" type="text" />
\t \t \t \t </div>
\t \t \t \t <div>
\t \t \t \t \t <span id="firstNameLabel"><wicket:message key="firstNameLabel" /></span>
\t \t \t \t \t <input id="firstName" wicket:id="firstName" type="text" />
\t \t \t \t </div>
\t \t \t \t <div>
\t \t \t \t \t <span id="dateOfBirthLabel"><wicket:message key="dateOfBirthLabel" /></span>
\t \t \t \t \t <input id="dateOfBirth" wicket:id="dateOfBirth" type="text" />
\t \t \t \t </div>
\t \t \t \t <div>
\t \t \t \t \t <input id="submit" type="submit" value="" wicket:message="value:submitLabel"/>
\t \t \t \t </div>
\t \t \t </form>
\t \t </div>
\t </body>
</html>
대응하는 자바 파일 :
package it.foo;
import java.util.Locale;
import org.apache.wicket.Session;
import org.apache.wicket.datetime.StyleDateConverter;
import org.apache.wicket.datetime.markup.html.form.DateTextField;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.joda.time.DateTime;
public class CreateStudentForm extends Form<Student> {
private static final long serialVersionUID = 1L;
private String lastName;
private String firstName;
private DateTime dateOfBirth;
@SpringBean
StudentDao studentDao;
public CreateStudentForm(String id) {
super(id);
setDefaultModel(new CompoundPropertyModel<>(this));
add(new TextField<String>("lastName"));
add(new TextField<String>("firstName"));
final DateTextField dateOfBirthField = new DateTextField("dateOfBirth", new StyleDateConverter("S-", true)) {
private static final long serialVersionUID = 1L;
@Override
public Locale getLocale() {
return Session.get().getLocale();
}
};
dateOfBirthField.setType(DateTime.class);
add(dateOfBirthField);
}
@Override
protected void onSubmit() {
// does not get called as soon as the DateTextField is present. Works fine otherwise.
Student student = new Student(this.lastName, this.firstName, this.dateOfBirth);
studentDao.store(student);
setResponsePage(StudentsPage.class);
}
}
내가 브라우저에서 렌더링되는 HTML을 살펴했다
다음은 HTML 코드입니다. dateTextField가 존재하지 않는다면, 그것은 다음과 같습니다
<html>
\t <head>
\t \t <title>Students</title>
\t </head>
\t <body>
\t \t <div class="container">
\t \t \t <form id="createStudent" method="post" action="./?2-1.IFormSubmitListener-createStudent"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="createStudent_hf_0" id="createStudent_hf_0" /></div>
\t \t \t \t <div>
\t \t \t \t \t <span id="lastNameLabel">Nachname: </span>
\t \t \t \t \t <input id="lastName" type="text" value="" name="lastName"/>
\t \t \t \t </div>
\t \t \t \t <div>
\t \t \t \t \t <span id="firstNameLabel">Vorname:</span>
\t \t \t \t \t <input id="firstName" type="text" value="" name="firstName"/>
\t \t \t \t </div>
\t \t \t \t <!-- <div>
\t \t \t \t \t <span id="dateOfBirthLabel"><wicket:message key="dateOfBirthLabel" /></span>
\t \t \t \t \t <input id="dateOfBirth" wicket:id="dateOfBirth" type="text" />
\t \t \t \t </div> -->
\t \t \t \t <div>
\t \t \t \t \t <input id="submit" type="submit" value="Schüler anlegen"/>
\t \t \t \t </div>
\t \t \t </form>
\t \t </div>
\t </body>
</html>
을 즉시 dateTextField이 존재하는 한, 형태는 자바 스크립트 호출에 추가 부서가 있습니다. 추가 부서가 모두 떨어져 갑자기 왜
<html>
\t <head>
\t \t <title>Students</title>
\t </head>
\t <body>
\t \t <div class="container">
\t \t \t <form id="createStudent" method="post" action="./?6-7.IFormSubmitListener-createStudent"><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="hidden" name="createStudent_hf_0" id="createStudent_hf_0" /></div><div style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input type="text" tabindex="-1" autocomplete="off"/><input type="submit" tabindex="-1" name="p::submit" onclick=" var b=document.getElementById('submit'); if (b!=null&&b.onclick!=null&&typeof(b.onclick) != 'undefined') { var r = Wicket.bind(b.onclick, b)(); if (r != false) b.click(); } else { b.click(); }; return false;" /></div>
\t \t \t \t <div>
\t \t \t \t \t <span id="lastNameLabel">Nachname: </span>
\t \t \t \t \t <input id="lastName" type="text" value="Matthias" name="lastName"/>
\t \t \t \t </div>
\t \t \t \t <div>
\t \t \t \t \t <span id="firstNameLabel">Vorname:</span>
\t \t \t \t \t <input id="firstName" type="text" value="Tonhäuser" name="firstName"/>
\t \t \t \t </div>
\t \t \t \t <div>
\t \t \t \t \t <span id="dateOfBirthLabel">Geburtsdatum: </span>
\t \t \t \t \t <input id="dateOfBirth" type="text" value="06.09.17" name="dateOfBirth"/>
\t \t \t \t </div>
\t \t \t \t <div>
\t \t \t \t \t <input id="submit" type="submit" value="Schüler anlegen" name="p::submit"/>
\t \t \t \t </div>
\t \t \t </form>
\t \t </div>
\t </body>
</html>
는 꽤 이해가 안 돼요. 내 생각 엔 자바 스크립트 호출이 작동하지 않는다는 것이다.
감사합니다.
당신이'피드백 panel'를 추가하고 당신에게 몇 가지 아이디어를 줄 것이다 제출할 수 있습니다 ..
onError(...)
메소드를 오버라이드 (override) 해, 세드릭 볼 수 있습니까? – soorapadman유효성 검사가 완료되면 Wicket onSubmit이 호출됩니다. onError를 확인할 수 있습니다. 어쩌면 문제가 있습니다. –