Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/shared/FieldVerifier.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-client/src/main/java/org/dive4elements/river/client/shared/FieldVerifier.java@821a02bbfb4e |
children | 172338b1407f |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.client.shared; | |
2 | |
3 /** | |
4 * <p> | |
5 * FieldVerifier validates that the name the user enters is valid. | |
6 * </p> | |
7 * <p> | |
8 * This class is in the <code>shared</code> package because we use it in both | |
9 * the client code and on the server. On the client, we verify that the name is | |
10 * valid before sending an RPC request so the user doesn't have to wait for a | |
11 * network round trip to get feedback. On the server, we verify that the name is | |
12 * correct to ensure that the input is correct regardless of where the RPC | |
13 * originates. | |
14 * </p> | |
15 * <p> | |
16 * When creating a class that is used on both the client and the server, be sure | |
17 * that all code is translatable and does not use native JavaScript. Code that | |
18 * is note translatable (such as code that interacts with a database or the file | |
19 * system) cannot be compiled into client side JavaScript. Code that uses native | |
20 * JavaScript (such as Widgets) cannot be run on the server. | |
21 * </p> | |
22 */ | |
23 public class FieldVerifier { | |
24 | |
25 /** | |
26 * Verifies that the specified name is valid for our service. | |
27 * | |
28 * In this example, we only require that the name is at least four | |
29 * characters. In your application, you can use more complex checks to ensure | |
30 * that usernames, passwords, email addresses, URLs, and other fields have the | |
31 * proper syntax. | |
32 * | |
33 * @param name the name to validate | |
34 * @return true if valid, false if invalid | |
35 */ | |
36 public static boolean isValidName(String name) { | |
37 if (name == null) { | |
38 return false; | |
39 } | |
40 return name.length() > 3; | |
41 } | |
42 } |