Primefaces 在下面或下一个字段显示自定义消息

Primefaces 在下面或下一个字段显示自定义消息,primefaces,jsf-1.2,Primefaces,Jsf 1.2,目前,我在顶部位置显示错误消息。但我想在我想要的地方展示,即近场。表示用户名的错误消息必须在其附近。 当我将该标记放置在那里时,它显示的是空资源错误 <!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/xh

目前,我在顶部位置显示错误消息。但我想在我想要的地方展示,即近场。表示用户名的错误消息必须在其附近。 当我将该标记放置在那里时,它显示的是空资源错误

<!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Prime Faces Demo</title>
<link rel="stylesheet" href="second.css" type="text/css" />

</head>
<body>
<h:body>
<f:view>
<f:loadBundle var="mg" basename="messages1"></f:loadBundle>
 <h:message for="firstname" style="color:red"></h:message> 
 <br></br>
 <h:message for="lastname" style="color:red"></h:message> 
 <br></br>
 <h:message for="pass" style="color:red"></h:message>
 <br></br>
  <h:message for="date" style="color:red"></h:message> 
  <br></br>
 <h:message for="cpass" style="color:red"></h:message> 
 <br></br>
  <h:message for="gender" style="color:red"></h:message>
   <br></br>
  <h:message for="nation" style="color:red"></h:message> 
 <br></br>
 <h:message for="faci" style="color:red"></h:message>
 <br></br>
  <h:message for="padd" style="color:red"></h:message> 
  <br></br>
 <h:message for="tadd" style="color:red"></h:message> 
 <br></br>
 <h:message for="email" style="color:red"></h:message>
   <br></br>
  <h:message for="phone" style="color:red"></h:message> 
 <br></br>
 <h:message for="quali" style="color:red"></h:message>
 <br></br>
  <h:message for="state" style="color:red"></h:message> 
  <br></br>
 <h:message for="hobby" style="color:red"></h:message> 
 <br></br>
 <h:message for="zone" style="color:red"></h:message> 
 <br></br>


<h:form>  

 <h:panelGrid columns="2" width="1000">

<h:panelGrid columns="2" width="600">   
<p:outputLabel value="Enter first name" style="font-weight:bold"></p:outputLabel>   
<h:inputText requiredMessage="#{mg.firstname}" value="#{Userdeatil.firstname}"
required="true" id="firstname">
</h:inputText>


<p:outputLabel value="Enter last name" style="font-weight:bold" ></p:outputLabel>
<h:inputText requiredMessage="#{mg.lastname}" value="#{Userdeatil.lastname}"
required="true" id="lastname">
</h:inputText>

 <p:outputLabel value="Enter password" style="font-weight:bold"></p:outputLabel>
<p:password value="#{Userdeatil.password}" required="true" requiredMessage="#{mg.password}" id="pass"></p:password>


 <p:outputLabel value="ReEnter password" style="font-weight:bold"></p:outputLabel>
<p:password value="#{Userdeatil.conpassword}" required="true" requiredMessage="#{mg.confrom}" id="cpass"></p:password>

<p:outputLabel value="Enter Date of Birth" style="font-weight:bold"></p:outputLabel>
<h:inputText requiredMessage="#{mg.birth}" value="#{Userdeatil.dob}"
required="true" id="date">
</h:inputText>

   <p:outputLabel value="Select Gender" style="font-weight:bold" ></p:outputLabel>
<p:selectOneRadio value="#{Userdeatil.gender}" required="true" id="gender" requiredMessage="#{mg.gender}">
<f:selectItem itemValue="male" itemLabel="Male"></f:selectItem>
<f:selectItem itemValue="female" itemLabel="Female"></f:selectItem>
</p:selectOneRadio >
<p:outputLabel value="Select Nationality" style="font-weight:bold"></p:outputLabel>
<p:selectOneRadio value="#{Userdeatil.nation}" required="true" id="nation" requiredMessage="#{mg.nation}" >
<f:selectItem itemValue="indian" itemLabel="Indian"></f:selectItem>
<f:selectItem itemValue="nonindian" itemLabel="NonIndian"></f:selectItem>
<f:selectItem itemValue="nri" itemLabel="NRI"></f:selectItem>
</p:selectOneRadio >
<p:outputLabel value="Select Account Facilities" style="font-weight:bold" ></p:outputLabel>
<h:selectManyCheckbox  required="true" id="faci" requiredMessage="#{mg.faci}">
<f:selectItem itemValue="1" itemLabel="Online banking"></f:selectItem>
<f:selectItem itemValue="2" itemLabel="Credit Card"></f:selectItem>
<f:selectItem itemValue="3" itemLabel="Debit Card"></f:selectItem>
<f:selectItem itemValue="4" itemLabel="All"></f:selectItem>
</h:selectManyCheckbox>
<p:outputLabel value="Permanent Address" style="font-weight:bold"></p:outputLabel>
<p:inputTextarea value="#{Userdeatil.tadd}" required="true" id="padd" requiredMessage="#{mg.padd}"></p:inputTextarea>
<p:outputLabel value="Temporary Address" style="font-weight:bold"></p:outputLabel>
<p:inputTextarea value="#{Userdeatil.padd}" required="true" id="tadd" requiredMessage="#{mg.tadd}"></p:inputTextarea>
<p:outputLabel value="Select if both are same" style="font-weight:bold"></p:outputLabel>
<p:selectBooleanCheckbox value="#{Userdeatil.same}"></p:selectBooleanCheckbox>
<p:outputLabel value="Select Zone" style="font-weight:bold"></p:outputLabel>  
       <h:selectOneMenu value="#{Userdeatil.zone}"   id="zone" requiredMessage="#{mg.zone}">  
        <f:selectItem itemLabel="Northern" itemValue="" />  
        <f:selectItem itemLabel="Western"></f:selectItem>
         <f:selectItem itemLabel="Eastern"></f:selectItem>
        <f:selectItem itemLabel="Southern"></f:selectItem>
       <f:selectItem itemLabel="Central"></f:selectItem>
            </h:selectOneMenu>
           <p:commandButton value="Submit" action="#{Userdeatil.check}"/>  
    </h:panelGrid> 


 <h:panelGrid columns="2" >  
<p:outputLabel value="Enter email" style="font-weight:bold"></p:outputLabel>   
 <p:inputText value="#{Userdeatil.email}" required="true"  id="email" requiredMessage="#{mg.email}">

 </p:inputText>
<p:outputLabel value="Enter phone number" style="font-weight:bold" ></p:outputLabel>
<p:inputText value="#{Userdeatil.phone}"  required="true" id="phone" requiredMessage="#{mg.phone}"></p:inputText>

 <p:outputLabel value="Enter qualification" style="font-weight:bold"></p:outputLabel>
<p:inputText value="#{Userdeatil.quali}" required="true" id="quali" requiredMessage="#{mg.quali}"></p:inputText>

<p:outputLabel value="Enter State" style="font-weight:bold"></p:outputLabel>
<p:inputText value="#{Userdeatil.state}" required="true" id="state" requiredMessage="#{mg.state}"></p:inputText>

<p:outputLabel value="Enter Hobby" style="font-weight:bold"></p:outputLabel>
<p:inputMask value="#{Userdeatil.hobbey}" required="true" id="hobby" requiredMessage="#{mg.hobby}"/>   

    </h:panelGrid>




 </h:panelGrid>
</h:form>  
</f:view>
</h:body>
</body>
</html>

素面演示