webwork/src/main/webwork/examples FormTest.java,1.7,1.8
[email protected] Thu, 16 May 2002 20:43:36 -0700
| Newsgroups | gmane.comp.java.webwork.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/webwork/webwork/src/main/webwork/examples
In directory usw-pr-cvs1:/tmp/cvs-serv3661
Modified Files:
FormTest.java
Log Message:
added IllegalArgumentExceptions
Index: FormTest.java
===================================================================
RCS file: /cvsroot/webwork/webwork/src/main/webwork/examples/FormTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- FormTest.java 2 May 2002 18:54:10 -0000 1.7
+++ FormTest.java 17 May 2002 03:43:34 -0000 1.8
@@ -10,11 +10,11 @@
import webwork.action.CommandDriven;
/**
- * A simple form
- *
- * @see <related>
- * @author Rickard Öberg (<email>)
- * @version $Revision$
+ * A simple form
+ *
+ * @see <related>
+ * @author Rickard Öberg (<email>)
+ * @version $Revision$
*/
public class FormTest
extends ActionSupport
@@ -56,6 +56,9 @@
public void setUser(String user)
{
+ if ("".equals(user)) {
+ throw new IllegalArgumentException(getText("missing_name"));
+ }
this.user = user;
}
@@ -66,6 +69,8 @@
public void setPassword(String password)
{
+ if ("".equals(password))
+ throw new IllegalArgumentException("Please enter your password.");
this.password = password;
}
@@ -76,6 +81,8 @@
public void setAge(String age)
{
+ if ("0-10".equals(age))
+ throw new IllegalArgumentException("Your age must be greater than 10.");
this.age = age;
}
@@ -96,6 +103,8 @@
public void setCountry(String country)
{
+ if ("ch".equals(country))
+ throw new IllegalArgumentException("Wrong country. Please try again.");
this.country = country;
}
@@ -126,6 +135,8 @@
public void setAdditionalInfo(boolean additionalInfo)
{
+ if (additionalInfo != true)
+ throw new IllegalArgumentException("You must accept the additional information to continue.");
this.additionalInfo = additionalInfo;
}
@@ -145,21 +156,6 @@
}
// Action implementation -----------------------------------------
- protected void doValidation()
- {
- // Validate
- if (user.equals(""))
- addError("user", getText("missing_name"));
- if (password.equals(""))
- addError("password", "Please enter your password.");
- if (age.equals("0-10"))
- addError("age", "Your age must be greater than 10.");
- if (country.equals("ch"))
- addError("country", "Wrong country. Please try again.");
- if (additionalInfo != true)
- addError("additionalInfo", "You must accept the additional information to continue.");
- }
-
protected String doExecute()
throws Exception
{
_______________________________________________________________
Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [email protected]