更新用户类别的密码:
@SuppressWarnings("serial")
public class UpdateProfilePanel extends Panel{
protected ServiceClientTemp client = ((WicketApplication) (WicketApplication.get())).getClient();
protected User oldUser;
protected User newUser;
public UpdateProfilePanel(String id) {
super(id);
Form updateProfileForm = new UpdateProfileForm("updateProfileForm");
add(updateProfileForm);
}
class UpdateProfileForm extends Form {
private FormComponent formForename;
private FormComponent formSurname;
private FormComponent formEmail;
public UpdateProfileForm(String id) {
super(id);
oldUser = client.getSessionUser();
formForename = new TextField("forename1", new PropertyModel(oldUser, "forename"));
formSurname = new TextField("surname1", new PropertyModel(oldUser, "surname"));
formEmail = new TextField("email1", new PropertyModel(oldUser, "email"));
add(formForename);
add(formSurname);
add(formEmail);
}
public void onSubmit() {
newUser = new User();
newUser.setForename(formForename.getInput());
newUser.setSurname(formSurname.getInput());
newUser.setEmail(formEmail.getInput());
}
}
}
当我进入一个新名称并发表我的文纽时,新价值在文本领域保持不变。 以后的工作与这一点类似,但只是为了理解: 为什么他更新了我的文稿,当时财产复制品的重犯仍为老的User和客户。 我还是老的User。 后面没有更新。
在同一个网站Page Ive上,另一个小组向我提供实际用户信息。
@SuppressWarnings("serial")
public class UserInfoPanel extends Panel {
protected ServiceClientTemp client = ((WicketApplication) (WicketApplication.get())).getClient();
protected User infoUser;
@SuppressWarnings("rawtypes")
UserInfoPanel(String id) {
super(id);
infoUser = client.getSessionUser();
add(new Label("username", new PropertyModel(infoUser, "username")));
add(new Label("surname", new PropertyModel(infoUser, "surname")));
add(new Label("forename", new PropertyModel(infoUser, "forename")));
add(new Label("email", new PropertyModel(infoUser, "email")));
add(new Label("state", new PropertyModel(infoUser, "state")));
}
}
而且,这一标签也变成了新价值,尽管他仍然被客户带走。 由于更新方法尚未实施,因此获得User。
希望有人能向我解释,为什么财产估价人提到新的User,而不是老的User。 为什么它像我一样建造我的财产模式,如财产管理(旧的User)......