English 中文(简体)
Wicket: PropertyModel Update
原标题:Wicket: PropertyModel updates
  • 时间:2012-01-15 13:21:19
  •  标签:
  • model
  • wicket

更新用户类别的密码:

 @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)......

最佳回答

这说明模式是如何运作的。

页: 1

 formForename = new TextField("forename1", new PropertyModel(oldUser, "forename"));

您提到你原来的“名称”财产。

现在,当你提交表格时,模型本身便更新,以便用新的价值更新物体旧User的“名称”。

此处所有模型:

问题回答

暂无回答




相关问题
What do you have in your Model class?

What do you have in your model classes. Generally if i use any framework or any library (Zend Framework) , my classes only have variable which is table name . I know that in complicated applications ...

Rails Model With Aggregrate Data (not backed by a table)

Id like to create a model in rails that does not correlate to a table in the database. Instead the model should dynamically pull aggregrate data about other models. Example: I have a Restaurant ...

Trouble changing databases for my models in codeigniter

I m making a website with two different databases. Let s say one is DB1, and the other is DB2. I ve set up my database.php in the config folder, so they each have the correct host/password/username/...

EMAIL server FSP model

For my assignment I need to develop FSP model for email server and client. I manage to write simple model which describes one user, server and his mailbox, but I am having problems changing this ...

Rails Custom Model Functions

I m in a databases course and the instructor wants us to develop an e-commerce app. She said we can use any framework we like, and now that we re halfway through the semester she decided that Rails ...

热门标签