struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Struts Newsgroup ( <>
Subject What's a good practice to reuse formBeans with validation
Date Fri, 08 Mar 2002 02:10:01 GMT
Subject: What's a good practice to reuse formBeans with validation
From: "Tea Yu" <>
Hi, consider the following scenario:

a countryForm bean contains properties "id" and "name"
actions to 1) insert, 2) update and 3) delete countries (not likely to
happen except to remove wrong/test inputs)

if I allow my users to delete a country by id (maybe a hyperlink), then I
suppose the name field will be null.  How should I handle such a basic
validation in countryForm as name shouldn't be null in case 1) and 2) but
could be null in case 3)?  The same question applies to id field in case

Is this a business logic and not to be handled in form bean?  Thus only
test if id is an integer:

if(id != null){
    }catch(NumberFormatException nfe){
        //chain up errors

in the actionForm:

    //test id==null

or should I turn to struts validator (which I guess rules could be
included in the form)?  or to use 3 different formBeans?  |o|

Nice day!
Tea Yu

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message