wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Field validation in session beans? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Field validation in session beans?" Watch "Field validation in session beans?" New topic
Author

Field validation in session beans?

R van Vliet
Ranch Hand

Joined: Nov 10, 2007
Posts: 144
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30050
    
149

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.)


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Field validation in session beans?
 
Similar Threads
difference between jsf beans and ejb
Struts: another resources bundle with validation.xml
General JSF page navigation questions
Best practice for secure login authorisation
Part II: Cade's usage of a Controller within the Class Diagram & the Sequence Diagrams