I have a managed Bean called bean1.java that has a boolean var called found. The variable says if a client has been found or not.
The bean has a method validate() that goes to the DB and checks if the client exists, and sets the variable to found=true if it exists or 'false' if it doesn't.
Then I keep completing other fields in my form. Now, when I click the button save, it the method saving(). That method has to do an action if the var found is true and another action if it's false.
But the problem is when I validate the variable that has been set to true on the method validate(), now it has the value "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
}