Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Field validation in session beans?

 
R van Vliet
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a question. I'm working on some EJB3 session beans which are the business logic for a few JSF pages. Currently, both the JSF pages as well as my methods seperately check if certain method parameters conform to specific rules (length min/max, matches specific regex, etc.). I dont like having to do this twice but since the beans can be called from places thay may not do such validation I dont have much of a choice.

My question is this; is there a neat way to define such rules once and use them in both the beans and the JSPs? Is there a best practice for this?

Hope someone can help me out,

Regards,

Remon
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remon,
You could put the rules in a utility class and call it from two places. It's good to be doing validation in places other than a JSP though (like the JSF Java code.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic