I searched a lot and did not find a solution.
I am using JSF 2.1 and RichFaces 4.2.3 and want to check user login details
I have two input fields. One username and one password, both with @NotEmpty
login.xhtml
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j" xmlns:mt="http://java.sun.com/jsf/composite/components"> <h:body> <ui:composition template="/protected/user/login-template.xhtml"> <ui:define name="panel-navigation"> <ui:include src="/protected/user/login-left-menu.xhtml" /> </ui:define> <ui:define name="contentbody"> <h:form> <div id="content"> <div class="subcolumns"> <div class="c65l"> <div class="subcl"> <p class="sum-error-message" /> <fieldset> <h3> <h:outputText value="#{styleguideMessages.login}" /> </h3> <p> <h:outputText value="#{messages.login_text}" /> </p> <div class="subcolumns"> <mt:inputText id="loginName" value="#{authenticationPM.loginName}" label="#{messages.general_label_loginname}" required="true" /> <div class="c33r validation"></div> </div> <div class="subcolumns"> <mt:inputText id="password" value="#{authenticationPM.password}" label="#{styleguideMessages.db_password}" required="true" secret="true" /> <div class="c33r validation"></div> </div> <div class="subcolumns"> <h:commandLink id="loginButton" action="#{authenticationPM.doLogin}" value="#{styleguideMessages.login}" title="#{styleguideMessages.login}" styleClass="button last" /> </div> </fieldset> </div> </div> </div> </div> <mt:commandButton id="login" action="#{authenticationPM.doLogin}" value="hidden" style="visibility:hidden" /> </h:form> <script src="#{facesContext.externalContext.requestContextPath}/js/lib/loginEnter.js" type="text/javascript" charset="utf-8"></script> </ui:define> </ui:composition>
AuthentificationPM.java
import *; @Named @SessionScoped public class AuthenticationPM extends AbstractPM implements Serializable { private String userName; private String password; @NotNull @Pattern(regexp = "^[^\"/\\[\\]:;|=,+?*<>]*$", message = "{user.loginname.pattern}") public String getLoginName() { return userName; } @NotNull public String getPassword() { return password; } public void setLoginName(String loginName) { this.userName = loginName; } public void setPassword(String password) { this.password = password; } }
If one of them (for example, the password) is not completed, the check fails and a message is displayed (as it should be).
Now I will delete the username and enter the password. Validation fails because the username is empty. It clears the password field and displays a message for the username.
And now an error occurs: the first username entered appears again! How can I prevent this behavior?
I know that after checking the process, the values ββof the update model and application are skipped and a rendering response is executed. As described here. The render response accepts the values ββstored in the ui component (during request requests) and uses them for reuse instead of deleting an invalid value.
I tried this solution as well as this idea . In both cases, my component was not found.
Any help or ideas are greatly appreciated.
hi? Kevin
source share