Modelの意義が掴めない
WicketのModelの使い方がよくわからない・・・
よくわからんが、とりあえず自分用にメモメモ。
/* 正解 */ public class EditPage extends WebPage { /** Creates a new instance of EditPage */ public EditPage() { add(new EditForm("editform")); } private final class EditForm extends Form { private Comment mComment; public EditForm(final String componentName) { super(componentName); mComment = new Comment(); TextArea ta = new TextArea("textarea", new PropertyModel(mComment, "text")); add(ta); } public final void onSubmit() { String comment = mComment.getText(); DB.insert(comment); } } } /* 間違い */ public class EditPage extends WebPage { /** Creates a new instance of EditPage */ public EditPage() { add(new EditForm("editform")); } private final class EditForm extends Form { private TextArea mTextArea; public EditForm(final String componentName) { super(componentName); mTextArea = new TextArea("textarea"); add(mTextArea); } public final void onSubmit() { String comment = mTextArea.getValue(); DB.insert(comment); } } }