Updated Validation sample. Now uses the correct RPC mechanism. Also removed unnessecary super source for the server constraint. Review at http://gwt-code-reviews.appspot.com/1800807 git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@11229 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/samples/validation/src/main/java/com/google/gwt/sample/validation/Validation.gwt.xml b/samples/validation/src/main/java/com/google/gwt/sample/validation/Validation.gwt.xml index 09b6e83..04a1068 100644 --- a/samples/validation/src/main/java/com/google/gwt/sample/validation/Validation.gwt.xml +++ b/samples/validation/src/main/java/com/google/gwt/sample/validation/Validation.gwt.xml
@@ -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' />
diff --git a/samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingService.java b/samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingService.java index 9ed0787..2f7d3ab 100644 --- a/samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingService.java +++ b/samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingService.java
@@ -15,18 +15,27 @@ */ 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; /** * 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(); + }
diff --git a/samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingServiceAsync.java b/samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingServiceAsync.java index 1309e56..ae27175 100644 --- a/samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingServiceAsync.java +++ b/samples/validation/src/main/java/com/google/gwt/sample/validation/client/GreetingServiceAsync.java
@@ -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); }
diff --git a/samples/validation/src/main/java/com/google/gwt/sample/validation/server/GreetingServiceImpl.java b/samples/validation/src/main/java/com/google/gwt/sample/validation/server/GreetingServiceImpl.java index f8712c7..e91fe27 100644 --- a/samples/validation/src/main/java/com/google/gwt/sample/validation/server/GreetingServiceImpl.java +++ b/samples/validation/src/main/java/com/google/gwt/sample/validation/server/GreetingServiceImpl.java
@@ -15,13 +15,15 @@ */ 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
diff --git a/samples/validation/src/main/resources/com/google/gwt/sample/validation/super/com/google/gwt/sample/validation/shared/ServerValidator.java b/samples/validation/src/main/resources/com/google/gwt/sample/validation/super/com/google/gwt/sample/validation/shared/ServerValidator.java deleted file mode 100644 index c633d58..0000000 --- a/samples/validation/src/main/resources/com/google/gwt/sample/validation/super/com/google/gwt/sample/validation/shared/ServerValidator.java +++ /dev/null
@@ -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