Tôi đã tìm kiếm rất nhiều và chưa tìm thấy giải pháp.Giá trị đầu vào không rõ ràng sau khi lỗi xác thực
Tôi đang sử dụng JSF 2.1 và RichFaces 4.2.3 và muốn xác thực dữ liệu đăng nhập của người dùng
Tôi có hai trường nhập. Một Tên người dùng và một mật khẩu, cả với @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 {
/**
* The user name from the login.
*/
private String userName;
/**
* password.
*/
private String password;
/**
* Returns the login name.
*
* @return String
*/
@NotNull
@Pattern(regexp = "^[^\"/\\[\\]:;|=,+?*<>]*$", message = "{user.loginname.pattern}")
public String getLoginName() {
return userName;
}
/**
* Returns the password.
*
* @return String
*/
@NotNull
public String getPassword() {
return password;
}
/**
* Sets the login name.
*
* @param loginName
* - the login name of the user
*/
public void setLoginName(String loginName) {
this.userName = loginName;
}
/**
* Sets the password.
*
* @param password
* - the password of the user
*/
public void setPassword(String password) {
this.password = password;
}
}
Nếu một trong những người (nói mật khẩu) là n ot đầy, xác thực không thành công và một thông báo được hiển thị (vì nó nên).
Bây giờ tôi xóa tên người dùng và nhập mật khẩu. Xác thực không thành công do tên người dùng trống. Làm sạch trường mật khẩu và hiển thị thông báo cho tên người dùng.
Và bây giờ lỗi xảy ra: tên người dùng đã nhập trước đó xuất hiện trở lại! Làm cách nào để ngăn chặn hành vi này?
Tôi biết rằng sau khi quá trình xác nhận, mô hình cập nhật giá trị và ứng dụng invoke là bỏ qua và làm cho phản ứng được thực thi. As described here. Phản hồi trả lời lấy các giá trị được lưu trữ trong thành phần ui (tại áp dụng các yêu cầu) và sử dụng chúng để đặt lại thay vì xóa giá trị không hợp lệ.
Tôi đã thử this solution cũng như this idea. Cả hai cách đều không tìm thấy thành phần của tôi.
Bất kỳ trợ giúp hoặc ý tưởng nào đều được đánh giá cao.
Greetings, Kevin
Với tôi, có vẻ như trình duyệt lưu trữ trang –
Valar Morghulis! Tôi đã tắt bộ nhớ cache như đã đề cập [ở đây] (http://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-development). Môi trường phát triển của chúng tôi không cho phép trình duyệt lưu lại trang đó. Vì vậy, đó không phải là lý do. Cảm ơn bạn! – Wavemaster