【发布时间】:2014-11-03 16:00:05
【问题描述】:
我正在开发我的第一个 Notes/XPages/Java 应用程序,但我陷入了一些基本的“粗略”级别。以下是托管 bean 的一部分。我可以将数据加载到 XPage,但保存 Checkbox 字段会给我带来问题,即它不会保存。我认为这与数据类型有关,因为 CheckboxGroup 是多值的。
表单字段是: 类别 就业角色
变量
public class TrainingModule implements Serializable {
private String Category;
private Object EmploymentRole;
public String getCategory() {
return Category; }
public void setCategory(final String category) {
Category = category;}
public Object getEmploymentRole() {
return EmploymentRole;}
public void setEmploymentRole(final Object employmentRole) {
EmploymentRole = employmentRole;}
加载方法
public void load(final String unid) {
setUnid(unid);
Document doc = null;
try {
doc = ExtLibUtil.getCurrentDatabase().getDocumentByUNID(getUnid());
setCategory(doc.getItemValueString("Category"));
setEmploymentRole(doc.getItemValue("EmploymentRole"));
etc
保存方法
public boolean saveData() {
boolean result = false;
Document doc = null;
try {
doc.replaceItemValue("Category", Category);
doc.replaceItemValue("EmploymentRole", EmploymentRole);
result = doc.save()
etc
XPage
<xp:checkBoxGroup id="checkBoxGroup1"
value="#{TrainingModule.employmentRole}">
<xp:selectItem itemLabel="Admin" itemValue="Admin">
</xp:selectItem>
<xp:selectItem itemLabel="Installation" itemValue="Installation">
</xp:selectItem>
<xp:selectItem itemLabel="Proj Man" itemValue="Proj Man">
</xp:selectItem>
</xp:checkBoxGroup>
我知道有类似的帖子,但我似乎无法将它们与我想要实现的目标联系起来。
我的下一个任务将是使用 Java 的上传和下载控件,因此任何要避免的提示或陷阱都会很棒。 任何帮助,将不胜感激。
【问题讨论】:
-
我假设您故意在保存方法中省略了设置 doc 对象的行?如果没有,那么您也应该实例化您的 doc 对象,因为它现在设置为 null,因此代码不会被执行,而是落入 catch 块中。
-
@OliverBusse 是的,抱歉 Oliver,我试图不放太多代码 - 一个错误。 doc = ExtLibUtil.getCurrentDatabase().getDocumentByUNID(getUnid());
标签: xpages