jspx页面找到要显示错误信息框的地方, 插入如下:
<af:messages id="messages1" globalOnly="true" binding="#{backing_projectList.messages1}"/>
代码逻辑中在错误处理的地方写入如下:
例如不允许table选择大于一行, 如下
Set rowSet = table.getSelectionState().getKeySet();
if (rowSet.size()>1) {
// cannot copy more than 1 project
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot copy more than 1 project at a time", "Please select only 1 project to copy.");
context.addMessage(null, message);
return null;
}
没有评论:
发表评论