0

I have a very strange behavior in a managed-bean where it is not retaining the values sent from the jsf and when it s going to process the POST then the properties are all null.

The JSF I have is a simple form with 2 fields and a button, the values of the two fields are received, and the button executes a POST method to process the data received from the JSF. When running a debug, I can see that after pressing the button then the setter methods are executed with the values sent to the bean (good), but when it goes to execute the mothod then suddenly all properties are null.

I have to include, that all this was working fine before, it started with this behavior when I moved all the managed-beans (backbeans) to a separated JAR file. I know that if I move the files again to the webapp then it will work, but I am looking for a way to not accumulate too many files in the same project, it's taking too long for compilation and deployment.

Here is the code of the backbean and the JSF:

@Named
@RequestScoped
public class RegisterController implements Serializable {            
private String accountType;

public String getAccountTypes() {
    return accountType;
}

public void setAccountTypes(String accountType) {
    this.accountType = accountType;   // Here it stores the value ********
}

private String businessType;

public String getBusinessType() {
    return businessType;
}

public void setBusinessType(String businessType) {
    this.businessType = businessType;    // Here it stores the other value *******
}   

// Method called with the button
public String prepareCreate() {
    if ("PERSONAL".equals(getAccountTypes()))  // Here is null!!  *************
    {            
        return "PersonalSignup";
    }
    else
        if (businessType == null)  // Here is also null!! ************
        {
            JsfUtil.addErrorMessage(
                    new Exception(""), ResourceBundle.getBundle(CommonUtil.bundleStr).getString("cc.signup.accounttype.invalid.businesstype"));
        }
...

Any help would be really appreciated, thanks.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Joe Almore
  • 4,036
  • 9
  • 52
  • 77

1 Answers1

0

Found the answer here: How does JSF find beans annotated with @ManagedBean?. Certainly if you need that your webapp looks into your jar file for managed-beans, only include a faces-config.xml file in your META-INF folder of your jar file.

Community
  • 1
  • 1
Joe Almore
  • 4,036
  • 9
  • 52
  • 77
  • 1
    Did that really solve your problem? You aren't using a JSF managed bean, but a CDI named bean. – BalusC Nov 18 '11 at 20:19
  • Hi @BalusC, yes it solved the problem in the first try, thanks for the help. And yes, I am using JSF managed beans; I changed the annotation to `@Named` because it was throwing an exception when sending the POST using `@ManagedBean`, but adding the faces-config.xml then I could use again the `@ManagedBean` annotation. BTW, perhaps you could help me with another question I have [here](http://stackoverflow.com/questions/8188794/java-entity-inheritance-does-not-compile-in-separated-jar-files), I really cannot find a workaround to this problem, seems easy but... you'll see. Thanks. – Joe Almore Nov 18 '11 at 20:47