CSValidation: A TextField with client-side validation with regexps and JS

Sorry to take a bit long to answer, I tried to import the project earlier, but the GAE and other things caused some odd trouble.

Anyhow, the problem seems to be that you are using a web.xml to configure the servlet, but you do not define the widget set there. The widget set is defined in the annotation for the servlet class, but the class is missing the @WebServlet annotation, so it’s not detected as a servlet class, the configuration is not read, and the widget set is not used.

You can define a servlet both in web.xml and @WebServlet, in which case the settings given in the web.xml override the ones given in @WebServlet. But, perhaps it’s usually best to use just either of the ways to avoid confusion.

Your question about regexps is not related to Vaadin, but a general Java regexp question, for which there are many better sources that you can google up.

For a short answer: OR: (expr1|expr2), AND: (?=expr1)(?=expr2). The (?=) is a lookahead operator, which can be used for doing AND, which is perhaps not very obvious from the Java regexp documentation.

Hi,

Cannot enable validation in vaadin 7.3.9
Steps to reproduce:

  1. Create a vaadin web application in NetBeans with help of standard plugin
  2. Install via netbeans plugin CSValidator
  3. make in console: mvn vaadin:update-widgeset install
  4. Insert the code in main source file:

[code]
final CSValidator validator = new CSValidator();
String fn_regexp = “^\d+$”;
validator.extend(e1);
validator.setRegExp(fn_regexp);
validator.setErrorMessage(“Enter a number”);

    layout.addComponent(e1);        

[/code]5. Run. Web browser loads the application I can enter symbols in TextField but no validation occurs.

Please help! Thanks!

Hi,

Indeed, it looks like CSValidator does not work with the newest Vaadin versions. I’ll investigate the problem.

Thanks for notifying about the issue.

Oops, no problem after all, I just made a mistake with widget set compilation when trying it quickly.

So, it works at least with Vaadin 7.4.0.beta2 and .beta3. I didn’t try the 7.3.9, but there shouldn’t be anything special in exactly that version.

Just remember to compile your project widget set and see that the CSValidationWidgetset is really included in the widget set. Widget set compilation should automatically find and include it in your project’s widget set, but if you have edited the widget set manually (and prevented automatic generation with “” comment), you need to add the proper line manually.

Thank you! It works. For those who will find this thread - I have manually copied maven declarations from a page of plugin to pom.xml of widgetset then vaadin:update-widgetset and vaadin:compile

Upgrading to version 0.5.2 throws the follwoing exception:
java.lang.UnsupportedClassVersionError: org/vaadin/csvalidation/CSValidator : Unsupported major.minor version 52.0

I’m running with JavaSE 1.7.0_51

Ouch, it looks like my new build script didn’t set source level to JDK 1.7 like it should (or actually I should try to compile with 1.6). Sorry about that, I’ll try to make a new build tomorrow.


There’s now
version 0.5.3 available, which should fix the Java version problem.

I think there is another problem. This time with the Widgetset compilation. When I upgrade to 0.5.3 and compile my widgetset it adds the following line to my widgetset.gwt.xml file:

<inherits name="${widgetset}" />

With 0.5.1 it adds a proper inherits:

<inherits name="org.vaadin.csvalidation.widgetset.CSValidationWidgetset" />

Hi Marko. Do you think you’re going to issue an update that fixes the widgetset issue or should we stick with 0.5.1? Thanks.

Yes, I’ll make a new build soon, hopefully today.

It looks like an error in the new build script, it writes an invalid add-on manifest. Instead of putting the widget set name there it puts the variable which was undefined… So when your application widget set is regenerated, it puts the invalid line there. I tested the add-on with a manually edited widget set, so I didn’t have the problem.

If you edit an application widget set (.gwt.xml) manually, you can use the following comment in the file to prevent automatic regeneration:

<!-- WS Compiler: manually edited -->

There’s now version 0.5.4 with the widget set problem fixed. I hope there’s no more regressions… I probably should separate the demo from the add-on project to have a bit better integration testing for that, would have avoided the issues with the recent releases…

Well this addon is just refusing to play nice…

The compile now works fine but during runtime I get this exception:

java.lang.NoClassDefFoundError: org/vaadin/csvalidation/widgetset/client/csvalidator/CSValidatorState
    at com....MaskedValueField.<init>(MaskedValueField.java:63)
    at com....createEntryField(FieldFactory.java:445)

The failure happens when constructing the validator. Here’s my code;

        CSValidator intValidator = new CSValidator();   <-- throws exception
        intValidator.extend(this);
        intValidator.setRegExp("^[0-9]
{0,5}$");
        intValidator.setPreventInvalidTyping(true)

I cleaned and rebuilt the project many times. Explicitly rebuilt the Vaadin theme and WidgetSet as well, but still get this error.

Going back to 0.5.1 again :frowning:

Indeed looking at the csvalidation-0.5.4.jar I see that the org.vaadin.csvalidation.widgetset.client package includes only empty sub packages. So it appears there is still a problem with the build script.

Ah, the compiled files required by the server-side application are not included in the JAR… Only the sources are there, but not the .class files. Right. I’ll make yet another release. I now migrated to Maven and the test/demo app is a separate module, as is it’s recommended to be, so there should be less trouble like this. I hope.

Hi Marko, is there any chance you can put a working jar for 0.5.4 on the Maven repository? I want to move 0.5.4 but the jar pulled by Maven is still missing the .class files. Thanks.

Sorry, it’s taking a bit long to fix the issue, because I noticed that there is a regression with partially valid matches. I hope I soon have time to fix it. If you are not using partial matches, you could build the add-on yourself.

The project is now converted to Maven, so building it is fairly easy with:

$ git clone https://github.com/Magi42/csvalidation $ cd csvalidation/csvalidation-addon $ mvn install Oh, the configuration doesn’t currently use a SNAPSHOT version number, but has a release number. I’ll fix that.

Hi,

Thanks a lot for the add-on, I’m using it with Vaadin 7.2 and it works very well!!
I just have one little issue, I tried to use the setValidateInitialEmpty method but it seems that it does not work.

In fact I cannot see in the CSValidator connector where this field is used. Am I missing something?

Thanks a lot!

Thomas

Hello,

Excellent add-on !! But I still have the error
Caused by: java.lang.NoClassDefFoundError: org/vaadin/csvalidation/widgetset/client/csvalidator/CSValidatorState
(.class still missing in the jar). Is there a chance to have a 0.5.5 version with the .class please ? I cannot clone with git in my production environnement. I use vaadin 7.5.0.

Thank you.
Benoît.