Reviewers: cromwellian, Nick Chalko,
Description:
Updated Validation sample. Now uses the correct RPC mechanism. Also
removed unnessecary super source for the server constraint.
Please review this at http://gwt-code-reviews.appspot.com/1800807/
Affected files:
M
samples/validation/src/main/java/com/google/gwt/sample/validation/Validation.gwt.xml
M
samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingService.java
M
samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingServiceAsync.java
M
samples/validation/src/main/java/com/google/gwt/sample/validation/server/GreetingServiceImpl.java
D
samples/validation/src/main/resources/com/google/gwt/sample/validation/super/com/google/gwt/sample/validation/shared/ServerValidator.java
Index:
samples/validation/src/main/java/com/google/gwt/sample/validation/Validation.gwt.xml
===================================================================
---
samples/validation/src/main/java/com/google/gwt/sample/validation/Validation.gwt.xml
(revision 11221)
+++
samples/validation/src/main/java/com/google/gwt/sample/validation/Validation.gwt.xml
(working copy)
@@ -14,7 +14,7 @@
<module rename-to='validation'>
- <inherits name='com.google.gwt.rpc.RPC' />
+ <inherits name='com.google.gwt.user.RemoteService' />
<inherits name='com.google.gwt.user.User' />
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<inherits name='org.hibernate.validator.HibernateValidator' />
Index:
samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingService.java
===================================================================
---
samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingService.java
(revision 11221)
+++
samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingService.java
(working copy)
@@ -15,10 +15,12 @@
*/
package com.google.gwt.sample.validation.client;
-import com.google.gwt.rpc.client.RpcService;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.sample.validation.shared.Person;
+import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
+
+import org.hibernate.validator.engine.ValidationSupport;
import javax.validation.ConstraintViolationException;
@@ -26,7 +28,14 @@
* The client side stub for the RPC service.
*/
@RemoteServiceRelativePath("greet")
-public interface GreetingService extends RpcService {
+public interface GreetingService extends RemoteService {
SafeHtml greetServer(Person name) throws IllegalArgumentException,
ConstraintViolationException;
+
+ /**
+ * Force hibernate validator imple1metations to be available for
+ * serialization.
+ */
+ ValidationSupport dummy();
+
}
Index:
samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingServiceAsync.java
===================================================================
---
samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingServiceAsync.java
(revision 11221)
+++
samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingServiceAsync.java
(working copy)
@@ -19,6 +19,8 @@
import com.google.gwt.sample.validation.shared.Person;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import org.hibernate.validator.engine.ValidationSupport;
+
import javax.validation.ConstraintViolationException;
/**
@@ -27,4 +29,6 @@
public interface GreetingServiceAsync {
void greetServer(Person person, AsyncCallback<SafeHtml> callback)
throws IllegalArgumentException, ConstraintViolationException;
+
+ void dummy(AsyncCallback<ValidationSupport> callback);
}
Index:
samples/validation/src/main/java/com/google/gwt/sample/validation/server/GreetingServiceImpl.java
===================================================================
---
samples/validation/src/main/java/com/google/gwt/sample/validation/server/GreetingServiceImpl.java
(revision 11221)
+++
samples/validation/src/main/java/com/google/gwt/sample/validation/server/GreetingServiceImpl.java
(working copy)
@@ -15,12 +15,14 @@
*/
package com.google.gwt.sample.validation.server;
-import com.google.gwt.rpc.server.RpcServlet;
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.sample.validation.client.GreetingService;
import com.google.gwt.sample.validation.shared.Person;
import com.google.gwt.sample.validation.shared.ServerGroup;
+
+import org.hibernate.validator.engine.ValidationSupport;
import java.util.HashSet;
import java.util.Set;
@@ -35,7 +37,7 @@
* The server side implementation of the RPC service.
*/
@SuppressWarnings("serial")
-public class GreetingServiceImpl extends RpcServlet implements
+public class GreetingServiceImpl extends RemoteServiceServlet implements
GreetingService {
private final Validator validator =
Validation.buildDefaultValidatorFactory().getValidator();
@@ -67,4 +69,9 @@
.toSafeHtml();
return safeHtml;
}
+
+ @Override
+ public ValidationSupport dummy() {
+ return null;
+ }
}
\ No newline at end of file
Index:
samples/validation/src/main/resources/com/google/gwt/sample/validation/super/com/google/gwt/sample/validation/shared/ServerValidator.java
===================================================================
---
samples/validation/src/main/resources/com/google/gwt/sample/validation/super/com/google/gwt/sample/validation/shared/ServerValidator.java
(revision 11221)
+++
samples/validation/src/main/resources/com/google/gwt/sample/validation/super/com/google/gwt/sample/validation/shared/ServerValidator.java
(working copy)
@@ -1,27 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
- * use this file except in compliance with the License. You may obtain a
copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
under
- * the License.
- */
-package com.google.gwt.sample.validation.shared;
-
-import
com.google.gwt.validation.client.constraints.NotGwtCompatibleValidator;
-
-/**
- * Always invalid.
- * <p>
- * Server validator is overriden so it compiles, but it is always invalid.
- */
-public class ServerValidator extends
- NotGwtCompatibleValidator<ServerConstraint, Person> {
-}
\ No newline at end of file
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors