Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Validation

Thread view: 
cliveswan@yahoo.co.uk - 12 Apr 2007 11:05 GMT
Hi,

Could anyone provide assistance with validation.

I have Q1 (Yes/No)
Q2 - Q10 (Yes/No)

If Q1 is Yes, then at least one of Q2-10 must be yes
If Q1 is No, then all Q2-10 must be No

Can you assign Q2-10 = 0 or 1

then add-up Q2-10

If yes the Q2-20 >= 1
or No then Q2-10 = 0

How would you say this in Java????

Thanks

Clive
Lew - 12 Apr 2007 13:23 GMT
> Hi,
>
[quoted text clipped - 14 lines]
>
> How would you say this in Java????

Convert checkbox inputs to boolean (Struts does this for you).  Throw the
booleans into an array or List.

boolean isQ1 = checks.get(0);
if ( isQ1 )
{
  for ( int ix = 1; ix < checks.size(); ++ix )
  {
    if ( checks.get(ix) )
    {
      return VALID;
    }
  }
  return INVALID;
}
else
{
  for ( int ix = 1; ix < checks.size(); ++ix )
  {
    if ( checks.get(ix) )
    {
      return INVALID;
    }
  }
  return VALID;
}

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.