gpt4 book ai didi

validation - JSF h :message or p:message does not work

转载 作者:行者123 更新时间:2023-12-04 06:27:37 25 4
gpt4 key购买 nike

我的应用程序在 glassfish 中运行。我没有看到任何 h:message 或 h:messages(或者,primefaces 消息)......是否有任何配置,我必须在 web.xml 或 faces-config.xml 中指定?
目前我无法查看是否有任何验证失败,甚至, required="true"with requiredMessages="Some Value"也不起作用..

最佳答案

JSF

咆哮 -> id="咆哮"

命令按钮 -> 更新 =“咆哮”

<?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();
}
}

关于validation - JSF h :message or p:message does not work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5854220/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com