我正在使用 inputText 从用户那里获取输入
<h:inputText id="firstName" value="#{beanManager.currentUser.firstName }" required="true" style="font-size: 15px"></h:inputText>
然后我添加了一个消息标签
<h:message for="firstName"></h:message>
但是当输入文本为空白并且我按下提交时,我收到此错误消息:
> j_id_jsp_1382885624_1:ID: Validation Error: Value is required.
如何仅显示错误消息?
> Validation Error: Value is required.
这是代码:
<f:view>
<h:form>
<h:panelGrid border="1" columns="3" style="width: 643px; ">
<h:outputText value="First Name" style="font-size: 25px; font-weight: bold"></h:outputText>
<h:outputText value="Last Name" style="font-size: 25px; font-weight: bold"></h:outputText>
<h:outputText value="ID" style="font-size: 25px; font-weight: bold"></h:outputText>
<h:inputText id="firstName" value="#{beanManager.currentUser.firstName }" required="true" requiredMessage="Enter a Valid First Name" style="font-size: 15px"></h:inputText>
<h:inputText id="LastName" value="#{beanManager.currentUser.lastName }" required="true" requiredMessage="Enter a Valid Last Name" style="font-size: 15px"></h:inputText>
<h:inputText id="ID" value="#{beanManager.currentUser.ID}" required="true" requiredMessage="Enter a Valid ID" style="font-size: 15px">
</h:inputText>
<h:form><h:commandButton action="#{beanManager.save }" value="Save Changes" style="height: 30px; width: 100px"></h:commandButton>
</h:form>
</h:panelGrid>
<h:commandLink action="backtopersonalview" value="Back To Users" style="height: 30px; width: 100px">
</h:commandLink>
</h:form>
</f:view>