如果当前用户没有足够的优势,我会尝试渲染和错误消息
<h:form id="distribution">
<h:panelGrid columns="1">
<h:messages errorStyle="color:red" infoStyle="color:blue" globalOnly="true" />
<rich:panel style="width:560px;">
<f:facet name="header">
<h:outputText value="Owners list"></h:outputText>
</f:facet>
<rich:pickList value="#{BomDistributor.selectedOwners}"
sourceCaption="Available Owners" targetCaption="Selected Owners"
listWidth="165px" listHeight="100px" orderable="true"
required="true" requiredMessage="Please select owner">
<f:selectItems value="#{BomDistributor.availableOwners}"
var="capital" />
</rich:pickList>
</rich:panel>
</h:panelGrid>
</h:form>
这是bean,我称之为@ bean构造函数
public ScrubbingDistribution() {
this.loading = false;
this.now = Calendar.getInstance();
this.currentUser = (UserJTO) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("currentUser") ;
if(currentUser.getGroupJTO().getGroupId()!=1){
System.out.println("Not Allowed");
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"Not Allowed", "Only Admins can upload jobs"));
}
} 但我在控制台得到这个
INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=null[severity=(ERROR 2), summary=(Not Allowed), detail=(Only Admins can upload jobs)]
出了什么问题?