diff src/econnect/wp3_3/shared/FieldVerifier.java @ 3:cf06b77a8bbd

Committed branch of the e4D repos sti-gwt branch 16384. git-svn-id: http://dev.dariah.eu/svn/repos/eu.dariah.de/ap1/sti-gwt-dariah-geobrowser@36 f2b5be40-def6-11e0-8a09-b3c1cc336c6b
author StefanFunk <StefanFunk@f2b5be40-def6-11e0-8a09-b3c1cc336c6b>
date Tue, 17 Jul 2012 13:34:40 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/econnect/wp3_3/shared/FieldVerifier.java	Tue Jul 17 13:34:40 2012 +0000
@@ -0,0 +1,42 @@
+package econnect.wp3_3.shared;
+
+/**
+ * <p>
+ * FieldVerifier validates that the name the user enters is valid.
+ * </p>
+ * <p>
+ * This class is in the <code>shared</code> packing because we use it in both
+ * the client code and on the server. On the client, we verify that the name is
+ * valid before sending an RPC request so the user doesn't have to wait for a
+ * network round trip to get feedback. On the server, we verify that the name is
+ * correct to ensure that the input is correct regardless of where the RPC
+ * originates.
+ * </p>
+ * <p>
+ * When creating a class that is used on both the client and the server, be sure
+ * that all code is translatable and does not use native JavaScript. Code that
+ * is note translatable (such as code that interacts with a database or the file
+ * system) cannot be compiled into client side JavaScript. Code that uses native
+ * JavaScript (such as Widgets) cannot be run on the server.
+ * </p>
+ */
+public class FieldVerifier {
+
+	/**
+	 * Verifies that the specified name is valid for our service.
+	 * 
+	 * In this example, we only require that the name is at least four
+	 * characters. In your application, you can use more complex checks to ensure
+	 * that usernames, passwords, email addresses, URLs, and other fields have the
+	 * proper syntax.
+	 * 
+	 * @param name the name to validate
+	 * @return true if valid, false if invalid
+	 */
+	public static boolean isValidName(String name) {
+		if (name == null) {
+			return false;
+		}
+		return name.length() > 3;
+	}
+}