- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
and normal jsf command button 之间的差异-6ren"> and normal jsf command button 之间的差异-早上好,我只想知道像这样验证 JSF 组件之间的区别: // diff between that and normal -6ren">
早上好,我只想知道像这样验证 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>
添加??
最佳答案
<f:event>
提供了一种调用给定 listener
的方法给定事件的方法 type
发生。 postValidate
事件在验证阶段结束时被调用,在整个表单被处理、转换和验证之后,但 之前 模型已更新。因此,如果您打算根据提交的值执行作业,则需要通过 UIInput#getValue()
获取它们。 .
在更新模型值阶段之后,在调用应用程序阶段调用命令按钮的操作方法。因此,如果您需要提交的值,则可以直接访问 bean 属性。
请注意,这两种方法都没有提供在所需组件处自动显示消息的好方法,也没有提供 FacesContext#validationFailed()
的方法。会返回 true
在验证失败的情况下。
从两个方面来说,<f:event type="postValidate">
如果监听器方法被正确实现,方法在技术上是执行工作的最正确的方法。验证应该在验证阶段而不是在调用应用程序阶段执行。
但是,更好的方法是使用专门用于验证多个字段是否相等的组件。 JSF 实用程序库 OmniFaces有这样一个组件: <o:validateEqual>
.在您的特定情况下,您可以按如下方式使用它:
<h:form id="register">
<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:panelGroup>
<h:message for="password" style="color: red;" />
<h:message for="validateConfirm" style="color:red;" />
</h:panelGroup>
<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>
<o:validateEqual id="validateConfirm" components="password confirmPassword" message="Passwords are not equal" />
<h:commandButton action="thanks" value="register" />
</h:form>
关于jsf-2 - <f :event listener ="#{}" type ="postValidate"/> and normal jsf command button 之间的差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15727933/
我正在尝试捕捉评论状态事件,例如有人正在关闭它。并在从插件中获得任何生命迹象之后。向日志文件(从任何日志级别)或 STDOUT 发送一行。atlassian-plugins.xml 看起来像这样:
我在跑; sass --watch --style compressed --sourcemap css/sass:css 我得到了; NameError: uninitialized constan
您好,我正在创建一个 android 应用程序作为 ejabbered 服务器的 XMPP 客户端。 但我真的很困惑,因为我看到我可以将消息作为数据包或消息发送,我也可以使用 PacketListen
我有一个 imageview - 它的属性 -focusable 和 focusableintouchmode 都设置为 true 我已经在我的 Activity 中实现了 onFocus
我有一个查询来查找指定条形码的文档 ID: Future findBarcode() async { String searchBarcode = await BarcodeScanner.sca
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 5 年前。 Improve
这可能是一个非常基本的问题,但我就是不明白。使用 Express.js 创建应用和启动应用监听 1234 端口有什么区别,例如: var express = require('express'); v
所以我想知道什么是更好看的解决方案/有什么区别以及在决定制作多个监听器(1 个监听器用于 1 个按钮)还是仅 1 个 ActionListener 用于 GUI 中的所有按钮(大约 10 个按钮),并
我目前正在尝试制作一个聊天室服务器。我正在努力做到这一点,以便我可以同时监听新请求的连接和监听从已建立的连接发送的消息。 我可以用它来监听请求的连接: def reqlisten(): glo
有没有办法在事件监听器方法中访问类上下文并有可能删除监听器? 示例 1: import {EventEmitter} from "events"; export default class Event
应用程序在本地主机上工作正常。但是当它连接到服务器时出现错误。 我通过端口 22 连接服务器 这是错误 Error: listen EADDRNOTAVAIL Error: listen EADDRN
我有类似的东西: $scope.$on(config.SOME_CONSTANT, ()=> { activate(); // plus a bunch of instantiatio
我的 HTML 页面上有以下 Controller : ... ... 此子 Controller 映射到以下 c
我的 HTML 页面上有以下 Controller : ... ... 此子 Controller 映射到以下 c
我构建了一个自定义属性并将其添加到可观察列表中。但是,如果属性内容发生更改,则不会调用任何监听器。以下代码片段向您展示了“建筑”: public static final class TestObje
这里我不明白这两种方法的基本区别是什么。 var events = require('events'); var eventEmitter = new events.EventEmitter(); v
我正在尝试使用 grunt-express 设置 Grunt 来启动我的 Express 服务器。读完docs后和 this SO question ,我还是想不通。我已经为我的 Grunt 文件尝试
如果这里问题的某些方面不清楚,我深表歉意,因为我是 Node 和 javascript 的新手。请询问更多详情 我有一个使用 socketio 连接到 firebase 的 Node 应用程序。在 h
情况 我可能没有使用传统意义上的 PHPUnit。我正在使用带有 Selenium 2 的 PHPUnit。我们有这个想法来记录 Selenium 以“重现步骤”的方式执行的操作。这意味着如果我们调用
我正在尝试学习在 struts2 中使用 session 。所以,我只想实现一个登录/注销、配置文件应用程序。我正在关注互联网上提供的基本教程。但是,它根本不起作用。请帮助我解决以下问题如何解决。 S
我是一名优秀的程序员,十分优秀!