found
이라는 부울 var가있는 bean1.java
이라는 관리 Bean이 있습니다. 변수는 클라이언트를 찾았는지 여부를 나타냅니다.jsf 변수 손실 값
빈에는 DB로 이동하여 클라이언트가 있는지 확인하고 변수가 존재하는 경우 found=true
으로 설정하고 그렇지 않은 경우에는 'false'로 설정합니다.
그런 다음 양식에서 다른 입력란을 계속 작성합니다. 이제 버튼 저장을 클릭하면 방법이 saving()
이됩니다. 이 메서드는 var found
이 true이면 작업을 수행하고 false이면 다른 작업을 수행해야합니다.
그러나 문제는 validate()
메서드에서 true로 설정된 변수의 유효성을 검사 할 때 값이 "false"가됩니다.
@ManagedBean
@ViewScoped //SessionScoped
public class AgregarPoliza implements Serializable{
public boolean found=false;
public void validate(){
// go to data base and validate if the client exist, when exist
// set variable true
found = true; // setFound(true); <--- i already try this way too
}
public void saving(){
//it has two actions to do but need to know the value of found
System.out.println("my var found has" + found); //this system.out shows false
if(found ==true){
//makes an action
}
else{
//makes another action
}
}
//get and set of the value found
}
JSF 페이지도 표시하고 bean java 코드의 오타를 수정하십시오. – elbuild
'found = false'가 다시 bean이 다시 작성되는 유일한 이유입니다. 빈에 대한 생성자에 일부 로깅을 추가하여 빈이 삭제 및 다시 작성되지 않는지 확인하십시오. – kolossus