0

I have set up a managed bean with help of the following code.

And have connected inputboxes on an XPage to the managed bean.

Now I want to save values from the inputboxes back to the underlying Notes document.

How should I do this? Should I set up a save method in the managed bean and call it via a button?

Example code would be helpful.

4

1 回答 1

3

除了您使用的代码之外,您还必须在 Java 类中为您在输入框中显示的所有字段添加设置器以进行更改,例如

public void setApplicationTitle(String applicationTitle) {
    this.applicationTitle = applicationTitle;
}

并添加一个方法 save()

public void save() throws NotesException {
    Database db = ExtLibUtil.getCurrentSession().getCurrentDatabase();
    View view = db.getView("config");
    Document doc = view.getFirstDocument();
    doc.replaceItemValue("ApplicationTitle", applicationTitle);
    // ... replace all other items changed by user
    doc.save(true, true);
    doc.recycle();
    view.recycle();
}

并使用 SSJS 在按钮中调用此方法

#{javascript:config.save()}

这只是发展的起点。此外,您必须关心可能的异常。您还应该只允许管理员进行更改,因为此配置文档似乎保留了您的应用程序的常规设置。

于 2013-06-11T07:00:33.583 回答