首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JSF h:message或p:message不工作

JSF h:message或p:message不工作
EN

Stack Overflow用户
提问于 2011-05-02 06:46:24
回答 1查看 4.6K关注 0票数 2

我的申请是用玻璃鱼写的。我没有看到任何h:消息或h:消息(或者,primefaces消息).是否有任何配置,必须在web.xml或Facs-config.xml中指定?目前,我无法查看是否有任何验证失败,甚至,required="true“和requiredMessages="Some”都不起作用。

EN

回答 1

Stack Overflow用户

发布于 2011-05-02 08:08:23

JSF

咆哮-> id=“咆哮”

commandButton -> update=“咆哮”

代码语言:javascript
复制
<?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>

背豆

代码语言:javascript
复制
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();
    }
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5854220

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档