我对PrimeFaces有一个奇怪的问题。我已经写了一个注册表单,其中所有字段都是必填字段。几乎每个字段都有自定义的国际化转换器或验证器消息。
有两种错误情况(使用和不使用AJAX):
不会抛出任何异常。没有错误消息或类似的东西。我甚至尝试更改PrimeFaces版本(我目前正在使用6.1)并使用没有任何样式的表单,在其中包含div容器和周围的HTML标记。起初我认为一些CSS div在验证后与表单重叠,但事实并非如此。
我的代码:
<h:form id="form">
<p:panelGrid columns="1" styleClass="ui-noborder">
<!-- MESSAGES -->
<p:messages id="msgs" closable="true"/>
<!-- E-MAIL -->
<h:outputLabel for="email" value="#{msgs.email_label} *"/>
<p:inputText id="email" name="email" required="true"
requiredMessage="#{msgs.email_format_message}" value="#{regCon.email}"
validatorMessage="#{msgs.email_format_message}">
<f:validateRegex
pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]"/>
</p:inputText>
<!-- USERNAME -->
<h:outputLabel for="username" value="#{msgs.username_label} *"/>
<p:inputText id="username" name="username" required="true"
requiredMessage="#{msgs.username_format_message}" value="#{regCon.username}"
validatorMessage="#{msgs.username_format_message}">
<f:validateRegex pattern="[a-zA-Z][a-zA-Z0-9]{3,15}"/>
</p:inputText>
<!-- PASSWORD -->
<h:outputLabel for="password" value="#{msgs.password_label} *"/>
<p:password id="password" name="password" required="true"
requiredMessage="#{msgs.password_format_message}" match="password_rep"
value="#{regCon.password}" validatorMessage="#{msgs.password_format_message}">
<f:validateRegex
pattern="((?=.*[a-z])(?=.*d)(?=.*[A-Z]).{8,40})"/>
</p:password>
<!-- REPEAT PASSWORD -->
<h:outputLabel for="password_rep" value="#{msgs.password_repeat_label} *"/>
<p:password id="password_rep" name="password_rep" required="true" value="#{regCon.passwordRepeat}"
requiredMessage="#{msgs.password_repeat_required_message}"/>
<!-- FIRSTNAME -->
<h:outputLabel for="firstname" value="#{msgs.firstname_label} *"/>
<p:inputText id="firstname" name="firstname" required="true"
requiredMessage="#{msgs.firstname_required_message}" value="#{regCon.firstname}">
</p:inputText>
<!-- LASTNAME -->
<h:outputLabel for="lastname" value="#{msgs.lastname_label} *"/>
<p:inputText id="lastname" name="lastname" required="true"
requiredMessage="#{msgs.lastname_required_message}" value="#{regCon.lastname}">
</p:inputText>
<!-- PHONE -->
<h:outputLabel for="phone" value="#{msgs.phonenumber_label} *"/>
<p:inputText id="phone" name="phone" required="true"
requiredMessage="#{msgs.phone_format_message}" value="#{regCon.phoneNumber}"
validatorMessage="#{msgs.phone_format_message}">
<f:validateRegex
pattern="\+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\d{1,14}$"/>
</p:inputText>
<!-- BIRTHDAY -->
<h:outputLabel for="birthday" value="#{msgs.birthday_label} *"/>
<p:inputMask id="birthday" name="birthday" required="true"
requiredMessage="#{msgs.birthday_format_message}"
value="#{regCon.dateOfBirth}" mask="#{msgs.birthday_mask}"
converterMessage="#{msgs.birthday_format_message}">
<f:convertDateTime pattern="#{msgs.birthday_pattern}"/>
</p:inputMask>
<p:commandButton value="#{msgs.registration_button}" styleClass="ui-priority-primary" ajax="false"
update=":form:msgs"
process=":form:email :form:username :form:password password_rep :form:firstname :form:lastname :form:phone :form:birthday"
actionListener="#{regCon.register()}"/>
<p:commandButton type="reset" value="#{msgs.reset_button}" update=":form:msgs"
process=":form:email :form:username :form:password :form:password_rep firstname :form:lastname :form:phone :form:birthday"/>
</p:panelGrid>
</h:form>
答案 0 :(得分:0)
我解决了这个问题。看起来引导主题有问题。
我并不确切知道究竟是什么造成的,但经过几个小时无用的故障排除后,我很高兴我已经解决了......