我想从表单中保存一些东西。按“保存”应用程序成功保存插入的信息并打印成功消息。问题是,由于某种原因,它还会打印一个没有任何消息的空盒子。
这是我用来保存的代码。
public void saveAndNew() {
IObject createdObj = null;
List<IAttributeObject> allAttributesList = new ArrayList<IAttributeObject>();
for (List attributeList : groupToFieldListMap.values()) {
for (Object object : attributeList) {
IAttributeObject attributeObject = (IAttributeObject) object;
if (attributeObject.getAttributeDescriptor().getDataType() == DataTypeConstants.THUMBNAIL) {
if (null != img) {
try { // add the cropped image bytes
attributeObject.setAttributeValue(img);
} catch (M3Exception e) {
JsfUtil.addErrorMessage(e, user);
}
}
}
allAttributesList.add(attributeObject);
}
}
// RequestContext requestContext = RequestContext.getCurrentInstance();
try {
createdObj = user.getApiSession().createObject(getIdByType(getSelectedVal()), allAttributesList);
if (createdObj != null) {
user.addRecentlyVisitedToServer(createdObj);
// Messages.addGlobalInfo("Object " + createdObj.getNumber() + "
// created");
// requestContext.update(":mainMenu");
init(this.selectedVal);
// requestContext.reset("createForm");
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO, "Info", "PrimeFaces Rocks."));
}
} catch (M3Exception e) {
JsfUtil.addErrorMessage(e, user);
// requestContext.update("createForm:tree");
}
}
在捕获之前我正在打印消息,结果是
这是xhtml中的代码
<h:form id="createForm">
<p:messages id="messages" showDetail="true" autoUpdate="true" />
<h:panelGrid columns="3" columnClasses="colOneTop, colTwoTop, colTop">....
我做错了吗?