• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Field validation in session beans?

 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 42073
932
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.)
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic