1

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?

3
  • That can happen if the bean is request scoped (which should make completely sense to you), but why exactly are you binding the whole component instead of just its value? Commented Jul 17, 2012 at 18:55
  • Thanks for info, thats weird. I didn't think of pointing only value, I'll try it tommorow. I thought that only UI components can be bound to JSF tags. Commented Jul 17, 2012 at 19:44
  • Now I look again at your comment, and earlier on I probably wrongly understood your question. You ment why I'm using "binding" attribute instead of "value" one, right? If so, then because I need to validate password and it's confirmation. At first, I thought you suggesting to use binding attribute but use it like a value attribute which confused me a bit:) Commented Jul 17, 2012 at 21:46

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I changed RegistrationBean to session scope and let the JSF do the initialization of password component, and now it works. Big thanks BalusC.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.