早上好,我只想知道像这样验证 JSF 组件之间的区别:
<h:form id="register">
<h:message for="RegisterGroupPanel" style="color:red;" />
<h:panelGrid columns="3" id="RegisterGroupPanel">
<f:event listener="#{user.validatePassword}" type="postValidate" /> // diff between that and normal <h:command>
<h:outputLabel for="username" value="Username : " />
<h:inputText id="username" value="#{user.username}" required="true"
requiredMessage="Please enter username" />
<h:message for="username" style="color: red;" />
<h:outputLabel for="password" value="Password : " />
<h:inputSecret id="password" value="#{user.password}" required="true"
requiredMessage="Please enter password" />
<h:message for="password" style="color: red;" />
<h:outputLabel for="confirmPassword" value="Confirm password : " />
<h:inputSecret id="confirmPassword" required="true"
requiredMessage="Please enter confirm password" />
<h:message for="confirmPassword" style="color: red;" />
</h:panelGrid>
<h:commandButton action="thanks" value="register" />
</h:form>
在这里,我将动作放在按钮内并删除了<f:event listener="#{user.validatePassword}" type="postValidate" />
<h:form id="register">
<h:message for="RegisterGroupPanel" style="color:red;" />
<h:panelGrid columns="3" id="RegisterGroupPanel">
<h:outputLabel for="username" value="Username : " />
<h:inputText id="username" value="#{user.username}" required="true"
requiredMessage="Please enter username" />
<h:message for="username" style="color: red;" />
<h:outputLabel for="password" value="Password : " />
<h:inputSecret id="password" value="#{user.password}" required="true"
requiredMessage="Please enter password" />
<h:message for="password" style="color: red;" />
<h:outputLabel for="confirmPassword" value="Confirm password : " />
<h:inputSecret id="confirmPassword" required="true"
requiredMessage="Please enter confirm password" />
<h:message for="confirmPassword" style="color: red;" />
</h:panelGrid>
<h:commandButton action="#{user.validatePassword}" value="register" />
</h:form>
这增加了什么额外的功能 <f:event>
?