Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

generic Validation class with optional parameters  RSS feed

Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to create a generic Validation class which will have all form value validation in it.
It will also be able to append an error message to a String buffer.I want to use a Data Bean
to store all form data/request parameters and pass this bean as a parameter to a method
validate(databean) in the Validation class. But the parms being passed are optional or required in
different cases when the Validation class is called. Right now, the procedural program just uses a
getparm(req,res,parmname,isrequired,..) and uses the parmname to decide if the variable is optional
or required.Itthrows an error msg if the parameter is required yet missing. This getparm method is called about
35-40 times before doing an insert into a table with these values. It gets pretty ugly in the servlet
code. How can i account for the optional or required feature for each parameter in the Validation
class or the Data Bean or in any other way?
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!