如果服务器端验证失败,则突出显示<p:inputtext>在PrimeFaces </p:inputtext>中

时间:2014-05-22 09:57:27

标签: java jsf primefaces

如果此值与来自数据库的值不匹配,我正在尝试突出显示p:inputText(用于保存电子邮件地址)。这是我的java代码:

private UIInput gUiInputemailAdd;  //global variable

public void validateCredentials(ComponentSystemEvent event) {
    UIComponent components = event.getComponent();
    UIInput uiInputemailAdd = (UIInput) components.findComponent("emailAdd");//ID of textbox
    gUiInputemailAdd = uiInputemailAdd;
    // uiInputemailAdd.setValid(false);//works fine here(it highlights this particular textBox)
}

public boolean forgotPasswordValidator(UserDetailTO userDetailTO)
        throws MessagingException {
    if (!gEmailAddress.equalsIgnoreCase(userDetailTO.getEmailAddress())) {
        System.out.println(gUiInputemailAdd.getValue().toString()); //works fine and print value
        gUiInputemailAdd.setValid(false);//doesn't work here
    }
}

Xhtml代码: -

<p:outputLabel for="emailAdd" value="EmilAddresss" />
<p:inputText value="#{loginTo.emailAddress}" id="emailAdd"/>

请帮助我,我已经被困在这里这么久了。

0 个答案:

没有答案