[英]How to validate a textfield in pageablelistview in java wicket
在代碼中的某個位置(例如,您重寫的Form#onSubmit()
或Form#onError()
,您的Ajax行為等),您再次添加了具有wicket ID“ FeedbackSubQuestions_”的組件,即使之前已經添加了此組件。 類似於以下內容:
public class MyPage extends WebPage {
public MyPage() {
this.add(new FeedbackPanel("FeedbackSubQuestions_"));
this.add(new Form<Void>("myForm"){
@Override
protected void onError() {
// This call the produce the error as the feedback component is already in the component hierarchy
MyPage.this.add(new FeedbackPanel("FeedbackSubQuestions_"));
}
});
...
Adding all the form components with validation and their ajax behaviors
...
}
}
在wicket中,一旦構造了組件層次結構,則與頁面的后續交互不再需要重新初始化任何頁面。 也就是說,一旦添加了反饋面板以使其顯示您的反饋,就無需再次添加此面板。 如果存在要顯示的錯誤(例如,表單驗證失敗或手動調用Component#error(String)
),則在再次呈現反饋面板(例如,將其添加到ajax響應中)時,反饋將自動獲取這些Component#error(String)
或整個頁面都作為表單提交過程的一部分重新呈現)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.