Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/shared/FieldVerifier.java @ 0:4e8be5e7855f
Start of a GWT based client for FLYS-3.0
flys-client/trunk@1305 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 08 Feb 2011 10:29:49 +0000 |
parents | |
children | ba1b27b7d282 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4e8be5e7855f |
---|---|
1 package de.intevation.flys.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 } |