Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF validator problem

 
Gina vernon
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to practice implementing the validator interface to validate an inputSecret UIcomponent. And I can't get it to work.

Here is my class that implements the validator:



This is the class with the setter&getter methods for the password:


the related JSF code:


and faces.cofig:


On a related note, i have read a lot of articles that call the validating class a 'backing bean'. How is it different from a 'managed bean'. And why is it called a bean when it doesn't have any set/get methods?

Thanks.

 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gina vernon wrote:Hi,
And I can't get it to work.

Elaborate the problem in detail. What happens? What happens not?
On a related note, i have read a lot of articles that call the validating class a 'backing bean'. How is it different from a 'managed bean'. And why is it called a bean when it doesn't have any set/get methods?

The validator class is not a backing bean class. Either the article is wrong or you misinterpreted the article.

To the point, a backing bean is a java class which can be managed by JSF as managed bean. A managed bean is a backing bean instance which is been managed by JSF.
 
Gina vernon
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:
Elaborate the problem in detail. What happens? What happens not?


My validator implementation does not validate my password when the length of the password is less than 5. It goes through to a welcome page. I expect it to print the error message I specified in the implementation class.
Thanks.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please analyze the problem at developer's level, not at user's level. The situation at the user's level is clear enough for us, developers.

Do the validator method for instane get executed? Does the string reference 'passw' contain the expected value? Are all the JSF phases executed? Etcetera. Debug your code and see what happens and what not. What lines got executed according expectations and what not. That kind of things.
 
Gina vernon
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the solution! There is nothing wrong with the code as it turns out, so its not a developer level issue. Its more a page designer issue. I needed to put this tag in to the JSP:
.





 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So your validator actually does validate the input and does add the message, but the message doesn't show up.

Glad you solved it yourself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic