嗨夥計我想實現不同的輸入字段,如果有些在文本字段中沒有放置任何內容,請在文本字段中顯示一條消息。如果輸入正確,則顯示一個對話框。JSF消息驗證不起作用
我使用primefaces 3.5和JSF 2.1
謝謝您的幫助。
reg.xhtml
<ui:composition template="/META-INF/templates/templateLogin.xhtml">
<ui:define name="title">
<h:outputText value="Register"/>
</ui:define>
<ui:define name="content">
<h:form id="regiForm">
<p:panelGrid >
<p:row style="height:20%">
<p:column><h:outputLabel value="#{msg['regi_firstname']}" /></p:column>
<p:column>
<p:inputText style="width:350px" id="firstname"
value="#{regiBean.firstname}" required="true" requiredMessage="#{msg['regi_firstname_error']}" />
</p:column>
<p:column><p:message for="firstname"/></p:column>
</p:row>
<p:row style="height:20%">
<p:column><h:outputText/> </p:column>
<p:column>
<p:commandButton style="width:350px" type="submit" actionListener="#{regiBean.showDialog}"
value="#{msg['regi_button']}" />
</p:column>
<p:column></p:column>
</p:row>
</p:panelGrid>
<p:dialog id="dialog" header="#{msg['regi_dialog_header']}" widgetVar="myDialog" position="center center" >
<h:outputText value="#{msg['regi_dialog']}" />
</p:dialog>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</f:view>
</html>
「不工作」是什麼意思? – kolossus
如果我沒有在文本字段中填寫任何內容並單擊按鈕,則不顯示任何消息。 – bvb1909