GrzesiekC
GrzesiekC

Reputation: 37

JSF binding. Property in backing bean is a different object than the actual UI component bound to the tag

I have a very simple scenario. I'm trying to bind the property in my backing bean:

<tr:inputText secret="true" id="passw"
                      required="true" binding="#{registrationBean.password}"/>

tr is trinidad tag library.

RegistrationBean:

public RegistrationBean()
{
   ...
   CoreInputText password = new CoreInputText();
}

...

public CoreInputText getPassword() {
    return password;
}

public void setPassword(CoreInputText password) {
    this.password = password;
}

The problem is, that during the validations phase, reference password is pointing to different UIInput component than actualy is bound to the desired tag. I've run out of ideas why is that happening that way. Any suggestions?

Upvotes: 1

Views: 621

Answers (1)

BalusC
BalusC

Reputation: 1108842

Don't create it yourself. Let JSF create it.

Replace

CoreInputText password = new CoreInputText();

by

CoreInputText password;

Otherwise a brand new one will be created on every request as you're using a request scoped bean.

Upvotes: 1

Related Questions