- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 previous question我遇到了从登录表单显示验证消息的问题。该问题现已解决,但这次我无法显示带有 FacesContex#addMessage
的自定义消息.
使用 JSF + PrimeFaces。
<p:dialog header="Login" widgetVar="loginDlg">
<h:form id="loginForm">
<h:panelGrid columns="3" cellpadding="5">
<h:outputLabel for="username" value="Username:" />
<p:inputText value="#{loginBean.username}" id="username" required="true" label="username" />
<p:message for="username" />
<h:outputLabel for="password" value="Password:" />
<h:inputSecret value="#{loginBean.password}" id="password" required="true" label="password" />
<p:message for="password" />
<f:facet name="footer">
<p:commandButton value="Login" id="loginDlgButton" update=":loginForm,:welcomeMsg" actionListener="#{loginBean.login}"
oncomplete="handleLoginRequest(xhr, status, args)"/>
<p:message for="loginDlgButton" />
</f:facet>
</h:panelGrid>
</h:form>
</p:dialog>
SessionScoped
ManagedBean
):
public void login() {
FacesContext context = FacesContext.getCurrentInstance();
RequestContext rContext = RequestContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
try {
request.login(this.username, this.password);
rContext.addCallbackParam("loggedIn", true);
} catch (ServletException e) {
rContext.addCallbackParam("loggedIn", false);
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Login Error", "Invalid credentials"));
}
}
<p:messages autoUpdate="true" />
If clientId is null, this FacesMessage is assumed to not be associated with any specific component instance
最佳答案
地点 <p:messages autoUpdate="true" />
在您的 form
内或在一些由 update
更新的包装器中您的 commandButton ,或放置 loginDlgButton
而不是 null
在 context.addMessage(...
关于JSF FacesContext#addMessage 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10396572/
我意识到一个是原型(prototype),有人能告诉我这两个之间的区别吗? $.addMessage = function () { 和 $.fn.addMessage = function () {
在我的 previous question我遇到了从登录表单显示验证消息的问题。该问题现已解决,但这次我无法显示带有 FacesContex#addMessage 的自定义消息. 使用 JSF + P
我有大约 50K 条消息想要添加到 Azure 队列中。 我不确定我的代码是否安全。感觉/闻起来很糟糕。 基本上,给出 POCO 的集合,将 POCO 序列化为某个 json,然后将该 json 文本
当您将消息发布到 Azure 队列时,如何判断消息是否已成功发布? 当使用以下代码时: queue.AddMessage(message); 我们发现在某些情况下消息不会发布到队列中。正在查看the
当您将消息发布到 Azure 队列时,如何判断消息是否已成功发布? 当使用以下代码时: queue.AddMessage(message); 我们发现在某些情况下消息不会发布到队列中。正在查看the
本文整理了Java中org.raml.parser.visitor.YamlDocumentValidator.addMessages()方法的一些代码示例,展示了YamlDocumentValida
我的页面: ... ... 我的托管Bean: public class ExampleManagedBe
我是一名优秀的程序员,十分优秀!