《示范法》如何运作?
我有这样的书记官处:
public class RegisterPanel extends Panel{
//empty user
public User user = new User();
protected ServiceClient client = ((WicketApplication) (WicketApplication.get())).getClient();
@SuppressWarnings({ "rawtypes" })
public RegisterPanel(String id) {
super(id);
//creates form with an empty user
Form form = new RegisterForm("registerForm", user);
add(form);
}
@SuppressWarnings({ "rawtypes" })
class RegisterForm extends Form {
private String userId = "";
private String email = "";
private String password1 = "";
private String password2 = "";
private FormComponent formEmail;
private FormComponent formPassword1;
private FormComponent formPassword2;
@SuppressWarnings("unchecked")
public RegisterForm(String id, User user) {
super(id);
add(new TextField("userId", new PropertyModel(this, "userId")).setRequired(true));
formEmail = new TextField("email", new PropertyModel(this, "email")).setRequired(true);
formPassword1 = new PasswordTextField("password1", new PropertyModel(this, "password1")).setRequired(true);
formPassword2 = new PasswordTextField("password2", new PropertyModel(this, "password2")).setRequired(true);
add(formEmail);
add(formPassword1);
add(formPassword2);
}
@Override
public void onSubmit() {
Result result = client.register(email, userId, password1);
if(result.getStatus()) {
user.setEail(email);
user.setUserId(userId);
user.setPassword(password1);
client.postUser(user);
}
}
}
}
但是,我如何利用模式开展工作? 现在,我只把财产模型与我的文本领域联系起来。 我认为,我可以把模型约束给我的空勤者,而采用提交方法,我的工作是仿照我的简单用户。 如何工作? 如何利用模型开展工作?