Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9307975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:30:51+00:00 2026-06-19T00:30:51+00:00

Using GWT 2.5.0, I would like to use Client side validation and Editors. I

  • 0

Using GWT 2.5.0,
I would like to use Client side validation and Editors. I encounter the following error when trying to pass the ConstraintViolation java.util.Set to the EditorDriver as follows.

Validator a = Validation.buildDefaultValidatorFactory().getValidator();
Set<ConstraintViolation<Person>> b = a.validate(person);
editorDriver.setConstraintViolations(b);

The method setConstraintViolations(Iterable<ConstraintViolation<?>>) in the type EditorDriver<Person> is not applicable for the arguments (Set<ConstraintViolation<Person>>)

The only somewhat relevant post I could find was Issue 6270!

Below is an Example which brings up a PopUpDialog with a Person Editor that allows you to specify a name and validate it against your annotations. Commenting out the personDriver.setConstraintViolations(violations); line in the PersonEditorDialog will allow you to run the example.

I don’t have enough reputation points to post the image of the example.

Classes


Person

public class Person {

@NotNull(message = "You must have a name")

@Size(min = 3, message = "Your name must contain more than 3 characters")

private String name;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

}

PersonEditorDialog

public class PersonEditorDialog extends DialogBox implements Editor<Person> {

private static PersonEditorDialogUiBinder uiBinder = GWT
        .create(PersonEditorDialogUiBinder.class);

interface PersonEditorDialogUiBinder extends
        UiBinder<Widget, PersonEditorDialog> {
}

private Validator validator;

public PersonEditorDialog() {
    validator = Validation.buildDefaultValidatorFactory().getValidator();
    setWidget(uiBinder.createAndBindUi(this));
}

interface Driver extends SimpleBeanEditorDriver<Person, PersonEditorDialog> {
};

@UiField
ValueBoxEditorDecorator<String> nameEditor;

@UiField
Button validateBtn;

private Driver personDriver;

@UiHandler("validateBtn")
public void handleValidate(ClickEvent e) {
    Person created = personDriver.flush();
    Set<ConstraintViolation<Person>> violations = validator
            .validate(created);
    if (!violations.isEmpty() || personDriver.hasErrors()) {
        StringBuilder violationMsg = new StringBuilder();
        for (Iterator<ConstraintViolation<Person>> iterator = violations.iterator(); iterator.hasNext();) {
            ConstraintViolation<Person> constraintViolation = (ConstraintViolation<Person>) iterator
                    .next();
            violationMsg.append(constraintViolation.getMessage() + ",");
        }
        Window.alert("Detected violations:" + violationMsg);
         personDriver.setConstraintViolations(violations);
    }
}

@Override
public void center() {
    personDriver = GWT.create(Driver.class);
    personDriver.initialize(this);
    personDriver.edit(new Person());
    super.center();
}
}

SampleValidationFactory

public final class SampleValidationFactory extends AbstractGwtValidatorFactory {

/**
 * Validator marker for the Validation Sample project. Only the classes and
 * groups listed in the {@link GwtValidation} annotation can be validated.
 */
@GwtValidation(Person.class)
public interface GwtValidator extends Validator {
}

@Override
public AbstractGwtValidator createValidator() {
    return GWT.create(GwtValidator.class);
}
}

EditorValidationTest

public class EditorValidationTest implements EntryPoint {


/**
 * This is the entry point method.
 */
public void onModuleLoad() {
    PersonEditorDialog personEditorDialog = new PersonEditorDialog();
    personEditorDialog.center();
}
}

UiBinder

PersonEditorDialog.ui.xml

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:e="urn:import:com.google.gwt.editor.ui.client">
<ui:style>
    .important {
        font-weight: bold;
    }
</ui:style>
<g:HTMLPanel>
    <g:Label>Enter your Name:</g:Label>
    <e:ValueBoxEditorDecorator ui:field="nameEditor">
        <e:valuebox>
            <g:TextBox />
        </e:valuebox>
    </e:ValueBoxEditorDecorator>
    <g:Button ui:field="validateBtn">Validate</g:Button>
</g:HTMLPanel>
</ui:UiBinder> 

GWT Module

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.0//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/2.5.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='editorvalidationtest'>
<inherits name='com.google.gwt.user.User' />
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<inherits name="com.google.gwt.editor.Editor"/>

<!-- Validation module inherits -->

<inherits name="org.hibernate.validator.HibernateValidator" />
<replace-with
    class="com.test.client.SampleValidationFactory">
    <when-type-is class="javax.validation.ValidatorFactory" />
</replace-with>

<!-- Specify the app entry point class. -->
<entry-point class='com.test.client.EditorValidationTest' />

<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />

</module>

Libs required on Classpath

  • hibernate-validator-4.1.0.Final.jar
  • hibernate-validator-4.1.0.Final-sources.jar
  • validation-api-1.0.0.GA.jar (in GWT SDK)
  • validation-api-1.0.0.GA-sources.jar (in GWT SDK)
  • slf4j-api-1.6.1.jar
  • slf4j-log4j12-1.6.1.jar
  • log4j-1.2.16.jar
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T00:30:52+00:00Added an answer on June 19, 2026 at 12:30 am

    As discussed in the comments, the following cast was determined to be a valid workaround.

    Set<?> test = violations; 
    editorDriver.setConstraintViolations((Set<ConstraintViolation<?>>) test);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some simple GWT client code that I would like to test using
When using GWT I get following warning: Referencing deprecated class 'com.google.gwt.user.client.rpc.SerializableException' While it's only
I have a monolingual GWT application (English) and I would like to use localized
I am using the GWT for developing my web application and would like to
I am new to GWT, I would like to use hyperlinks where I would
I would just like to setup a new GWT project in Eclipse and use
I am trying to implement an API (SCORM API) using GWT. The client code
I'm using GWT in my stuff, and I would like to make it, international,
I am using GWT/JAVA for development. I have following problem: I want to remove
I am using GWT for google map application. I use Google's gwt-maps.jar for mapping

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.