org.gcube.portlets.user.geoexplorerportlet.shared
Class FieldVerifier
java.lang.Object
org.gcube.portlets.user.geoexplorerportlet.shared.FieldVerifier
public class FieldVerifier
- extends Object
FieldVerifier validates that the name the user enters is valid.
This class is in the shared
package 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.
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 not 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.
Method Summary |
static boolean |
isValidName(String name)
Verifies that the specified name is valid for our service. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FieldVerifier
public FieldVerifier()
isValidName
public static boolean isValidName(String name)
- 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.
- Parameters:
name
- the name to validate
- Returns:
- true if valid, false if invalid
Copyright © 2013. All Rights Reserved.