The implementation (http://code.google.com/p/google-web-toolkit/source/
browse/trunk/samples/validation/src/com/google/gwt/sample/validation):

public class GreetingServiceImpl extends RpcServlet implements
    GreetingService {

  private final Validator validator =
Validation.buildDefaultValidatorFactory().getValidator();

  public SafeHtml greetServer(Person person) throws
IllegalArgumentException,
      ConstraintViolationException {
    // Verify that the input is valid.
    Set<ConstraintViolation<Person>> violations =
validator.validate(person,
        Default.class, ServerGroup.class);
    if (!violations.isEmpty()) {
      Set<ConstraintViolation<?>> temp = new
HashSet<ConstraintViolation<?>>(
          violations);
      throw new ConstraintViolationException(temp);
    }

    String serverInfo = getServletContext().getServerInfo();
    String userAgent = getThreadLocalRequest().getHeader("User-
Agent");

    // Escape data from the client to avoid cross-site script
vulnerabilities.
    SafeHtmlBuilder builder = new SafeHtmlBuilder();

    SafeHtml safeHtml = builder//
    .appendEscapedLines("Hello, " + person.getName() + "!")//
    .appendHtmlConstant("<br>")//
    .appendEscaped("I am running " + serverInfo + ".")//
    .appendHtmlConstant("<br><br>")//
    .appendEscaped("It looks like you are using: ")//
    .appendEscaped(userAgent)//
    .toSafeHtml();
    return safeHtml;
  }

On 25 mai, 11:30, Adolfo Panizo Touzon <adolfo.pan...@gmail.com>
wrote:
> You can save the errors strings in an arrayList<String> and transpor by rpc
> to the client side.
>
> 2011/5/25 MaximeMularz <max...@mularz.fr>
>
> > Hi,
>
> > Client Side no probem it works, but ServerSide I can't catch the
> > excepetion becasue HashSet is not supported by RPCService :
>
> > [ERROR] javax.servlet.ServletContext log: Exception while dispatching
> > incoming RPC call
> > com.google.gwt.user.client.rpc.SerializationException: Type
> > 'java.util.HashSet' was not included in the set of types which can be
> > serialized by this SerializationPolicy or its Class object could not
> > be loaded. For security purposes, this type will not be serialized.:
> > instance =
> > [ConstraintViolationImpl{interpolatedMessage='{custom.name.size.message}',
> > propertyPath=name, rootBeanClass=class myvalidator.shared.Person,
> > messageTemplate='{custom.name.size.message}'}]
> >        at
>
> > com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:
> > 619)
> >        at
>
> > com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:
> > 126)
> >        at
>
> > javax.validation.ConstraintViolationException_CustomFieldSerializer.serialize(ConstraintViolationException_CustomFieldSerializer.java:
> > 49)
> >        at
>
> > javax.validation.ConstraintViolationException_CustomFieldSerializer.serializeInstance(ConstraintViolationException_CustomFieldSerializer.java:
> > 72)
> >        at
>
> > javax.validation.ConstraintViolationException_CustomFieldSerializer.serializeInstance(ConstraintViolationException_CustomFieldSerializer.java:
> > 28)
> >        at
>
> > com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:
> > 740)
> >        at
>
> > com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:
> > 621)
> >        at
>
> > com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:
> > 126)
> >        at
> > com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter
> > $ValueWriter$8.write(ServerSerializationStreamWriter.java:153)
> >        at
>
> > com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:
> > 539)
> >        at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:616)
> >        at
> > com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:
> > 390)
> >        at
> > com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
> > 588)
> >        at
>
> > com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:
> > 208)
> >        at
>
> > com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:
> > 248)
> >        at
>
> > com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:
> > 62)
> >        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
> >        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> >        at
> > org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
> > 511)
> >        at org.mortbay.jetty.servlet.ServletHandler
> > $CachedChain.doFilter(ServletHandler.java:1166)
> >        at
>
> > com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:
> > 35)
> >        at org.mortbay.jetty.servlet.ServletHandler
> > $CachedChain.doFilter(ServletHandler.java:1157)
> >        at
>
> > com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:
> > 58)
> >        at org.mortbay.jetty.servlet.ServletHandler
> > $CachedChain.doFilter(ServletHandler.java:1157)
> >        at
>
> > com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:
> > 43)
> >        at org.mortbay.jetty.servlet.ServletHandler
> > $CachedChain.doFilter(ServletHandler.java:1157)
> >        at
>
> > com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:
> > 122)
> >        at org.mortbay.jetty.servlet.ServletHandler
> > $CachedChain.doFilter(ServletHandler.java:1157)
> >        at
>
> > com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:
> > 94)
> >        at org.mortbay.jetty.servlet.ServletHandler
> > $CachedChain.doFilter(ServletHandler.java:1157)
> >        at
> > org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
> > 388)
> >        at
> > org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
> > 216)
> >        at
> > org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
> > 182)
> >        at
> > org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
> > 765)
> >        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
> > 418)
> >        at
>
> > com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:
> > 70)
> >        at
> > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
> > 152)
> >        at com.google.appengine.tools.development.JettyContainerService
> > $ApiProxyHandler.handle(JettyContainerService.java:351)
> >        at
> > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
> > 152)
> >        at org.mortbay.jetty.Server.handle(Server.java:326)
> >        at
> > org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
> > 542)
> >        at org.mortbay.jetty.HttpConnection
> > $RequestHandler.content(HttpConnection.java:938)
> >        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
> >        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
> >        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
> >        at
> > org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
> > 409)
> >        at org.mortbay.thread.QueuedThreadPool
> > $PoolThread.run(QueuedThreadPool.java:582)
>
> > Thanks for your help
>
> > Maxime
>
> > On 23 mai, 18:34, Nick Chalko <ncha...@google.com> wrote:
> > > Glad you got it working.
>
> > > On Mon, May 23, 2011 at 9:31 AM, Adolfo Panizo Touzon <
>
> > > adolfo.pan...@gmail.com> wrote:
> > > > Hi Maxim!!!
>
> > > > It works!!!
>
> > > > I have made a very simple example based on Google (because if you have
> > a
> > > > problemthat I do not solve, sure there are people that if you could
> > lend a
> > > >  hand.)
> > > > The steps you follow are the following:
>
> > > > -Add the project (which I attached) to your workspace.
> > > > -Select your gwt sdk 0.0.0.0
> > > > -Add the libraries to your classpath you in the picture attached.
> > > > -Run it.
>
> > > > If you have any questions or comment on it is a problem here that I
> > miss
> > > > you a hand with any thing.
>
> > > > Greetings!
>
> > > > Now I work as an example to finally understand itself completely.
>
> > > > Adolfo Panizo.
>
> > > > 2011/5/23 Adolfo Panizo Touzon <adolfo.pan...@gmail.com>
>
> > > >> You've read the email you send to another address? Is there a problem
> > that
> > > >> prevents theapplication run.
> > > >> I need all the sdk result of the compilation not only gwt-user.
>
> > > >> I copied the email you send:
>
> > > >> *Listen*, now there is another problem, when I substitute the
> > "gwt-user
> > > >> "original, foryours in the GWT SDK and run the project. There's
> > something
> > > >> I do not like eclipse.
> > > >> *[*I have no choice but to do this because if I include your lib in
> > the
> > > >> classpath when the module of my project runs collides thw sdk of
> > google
> > > >> and your library compiled]
> > > >> *I enclose* a picture.
> > > >> *
> > > >> *
> > > >> *Would you know* how to fix? I believe that through a compilation
> > entire
> > > >> google sdk(which if you look very similar to what you've done just
> > that by
> > > >> running the ant.xmlgeneral) would end the problems.
>
> > > >> 2011/5/23 MaximeMularz <max...@mularz.fr>
>
> > > >>> Hi,
>
> > > >>> I'm waiting your sample because, I don't know how to play with !!!
>
> > > >>> Maxime
>
> > > >>> On 23 mai, 14:17, Adolfo Panizo Touzon <adolfo.pan...@gmail.com>
> > > >>> wrote:
> > > >>> > Hi,
>
> > > >>> > [I feel like a complete idiot right now. XD. There is a tutorial on
> > > >>> google!]
>
> > > >>> > Ok. I'm putting to work to try to compile everything on my own in
> > the
> > > >>> > meantime, if youmanage what you put in the mail to compile all the
> > SDK
> > > >>> and
> > > >>> > get it, accelerate the whole process and so I can create the
> > complete
> > > >>> sample
> > > >>> >  validation .
>
> > > >>> > We are in touch, thank you very much for everything.
>
> > > >>> > 2011/5/23 MaximeMularz <max...@mularz.fr>
>
> > > >>> > > Hi,
>
> > > >>> > > 1/ I did  the tuto :
>
> >http://code.google.com/webtoolkit/makinggwtbetter.html#workingoncode.
> > > >>> > > 2/ I visited this page "
> >http://subversion.apache.org/packages.html";
> > > >>> > > 3/ I downloaded and Installed : Win32Svn (32-bit client, server
> > and
> > > >>> > > bindings, MSI and ZIPs; maintained by David Darj)
> > > >>> > > 4/ I added SVN.exe to the PATH
> > > >>> > > 5/ and the command ant !!!
>
> > > >>> > > Regards
>
> > > >>> > > Maxime
>
> > > >>> > > On 23 mai, 10:56, Adolfo Panizo Touzon <adolfo.pan...@gmail.com>
> > > >>> > > wrote:
> > > >>> > > > Another thing I forgot, you could specify the steps you have
> > done
> > > >>> to
> > > >>> > > compile
> > > >>> > > >  the gwt-user project?
>
> > > >>> > > > Thanks in advance.
>
> > > >>> > > > 2011/5/23 Adolfo Panizo Touzon <adolfo.pan...@gmail.com>
>
> > > >>> > > > > Try it with:
> > > >>> > > > > Validator validator = GWT.create(SampleValidator.class);
>
> > > >>> > > > > Other thing, send us the modules that you are inhertir in
> > your
> > > >>> project.
>
> > > >>> > > > > If you use your form, you must specify in your xxx.gwt.xml
> > the
> > > >>> change
> > > >>> > > of
> > > >>> > > > > the class (remember, you must use the gwt class and not the
> > > >>> standar
> > > >>> > > class),
> > > >>> > > > > like this:
>
> > > >>> > > > >   <generate-with class=
>
> ...
>
> plus de détails »

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to