JSF outputlabel清除 [英] JSF outputlabel clear

查看:112
本文介绍了JSF outputlabel清除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题.当我仅提供PIN码时,我会使用表格.我有验证器,它检查其是否为4位数字.然后,将提交操作设置为检查PIN是否存在于数据库中的方法.如果没有,则显示message ="no PIN";我在表格下方的输出标签中使用了该消息.以前它为null,所以那里没有消息.现在它变为"no PIN",但是我必须再次单击提交"按钮后将其清除,因为当您输入"12as" PIN时,错误消息不会消失,验证器会处理它.我应该如何实施这种情况?也许在这种情况下使用输出标签是个错误的主意吗?

I have the following problem. I use a form when I provide only PIN. I have validator which checks if its a 4-digit number. Then the action on submit is set to the method which checks if the PIN exists in the database. If not it does message = "no PIN"; I used the message in the output label below the form. Previously it was null so there was no message there. Now it changes into "no PIN" but I have to clear it after clicking the submit button again because the error message doesn't disappear when you enter for example "12as" PIN and validator takes care of it. How should i implement such situation? Maybe using an output label in such situtation is a wrong idea?

推荐答案

您可以在验证程序之外使用JSF消息组件: 对于您在表单中输入的消息:

You can use JSF message component outside a validator: For a message for your input in your form:

 <h:message for="PIN"/> 

在托管bean上,您可以使用以下方法添加FacesMessage:

And at your managed bean you can add a FacesMessage using:

FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_WARN,"No pin summary message","No pin detail message");
FacesContext.getCurrentInstance().addMessage("PIN", message);

无需在此处使用outputLabel.

No need to use a outputLabel here.

这篇关于JSF outputlabel清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆