Primefaces自定义验证消息

dil*_*p H 3 jsf primefaces jsf-2

如何在使用主面消息标签时显示自定义验证消息?

假设我有一个字段Description,我希望得到这样的消息:

描述:请输入值.

这里的描述是字段名称,所以我真正的要求是

formId:inputId:请输入值.

但目前我得到这个:

描述:验证错误:值是必需的.

我的代码:

<p:messages id="message" />
<p:inputText id="updatedescription" value="#{equipTemplateBean.equipmentSpecificationsVO.description}" requiredMessage="Please enter Description"                                           required='true'                         
</p:inputText>
Run Code Online (Sandbox Code Playgroud)

请建议如何做到这一点.

Smu*_*tje 8

请考虑我的最小示例显示自定义错误消息"此字段是必需的".提交时为空:

page.xhtml

<?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:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <f:view>
        <h:head/>
        <h:body>
            <h:form>
                <p:inputText id="input"
                             required="true"
                             requiredMessage="This field is required."/>
                <p:message for="input"/>

                <p:commandButton process="input"
                                 update="@form"/>
            </h:form>
        </h:body>
    </f:view>
</html>
Run Code Online (Sandbox Code Playgroud)