我的应用程序在glassfish中运行。我没有看到任何h:message或h:messages(或者,primefaces消息)......有没有配置,我必须在web.xml或faces-config.xml中指定? 目前我无法查看是否有任何验证失败,甚至,required =“true”with requiredMessages =“Some Value”不起作用..
答案 0 :(得分:3)
<强> JSF 强>
咆哮 - &gt; ID = “咆哮”
commandButton - &gt;更新= “咆哮”
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<p:growl id="growl" showDetail="false" sticky="true" />
<p:commandButton value="Update" update="growl" actionListener="#{userPageBacking.updateUser}"/>
</h:form>
</h:body>
</html>
支持Bean
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.ComponentSystemEvent;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author ezehrt
*/
@ManagedBean
@RequestScoped
public class UserPageBacking {
public void updateUser() {
FacesContext fc = FacesContext.getCurrentInstance();
if (fc.isValidationFailed()) {
return;
}
FacesMessage msg = new FacesMessage("fehlermeldung", "fehlermeldung");
msg.setSeverity(FacesMessage.SEVERITY_ERROR);
fc.addMessage("fehlermeldung", msg);
fc.renderResponse();
}
}