Mvp4gAnnotationException when using SimpleDateFormat

80 Views Asked by At

I am writing a GWT application using java and eclipse. I am trying to add date validation to a text field and I am coming across the oddest issue.

When trying to build my ant build, I get the following error com.mvp4g.util.exception.loader.Mvp4gAnnotationException:

My code is below:

private boolean dateValidation(Date value) {
    boolean valid = true;
    String dateString = value.toString();   
    try {
        //SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm a");
        //format.setLenient(false);
        //format.parse(dateString);
    } catch (Exception e) {
        valid = false;
    }
    return valid;
}

The commented out code is the code that is causing the error. When I un-comment the format = new SimpleDateFormat() statement, the building breaks. Otherwise, it builds fine. Does anyone have any idea what would be causing this? I am not very familiar with GWT and I m not sure what would be causing this....

any help is appreciated I have been looking around and trying to figure this out forever! Let me know if you need me to add more code / full exception!

Thanks...

FYI: Using gwt-2.5.1-2.5.1 jdk1.6.0_43 developing in eclipse

UPDATE:

I was able to fix this by using the following code:

DateTimeFormat dateFormat = DateTimeFormat.getFormat("MM/dd/yyyy HH:mm a");
Date current = view.getDtEndDate().getValue();                          
current = dateFormat.parse(dateFormat.format(current));

Although issue is technically resolved.... I would be interested into WHY this was the case? Can anyone elaborate?

1

There are 1 best solutions below

0
El Hoss On

I assume, that you are validating the date field in a view- or presenter-class. Because you can not use SimpleDateFormat on the client side (No Source Code is available for type java.text.SimpleDateFormat: GWT Compilation Error) the class could not be compiled.

In mvp4g you have to annotate your presenter (inside the eventbus in the @Event-annotation) and your view class as a paraemter of the @Presenter annotation. mvp4g tries to load these classes. In the case where the class can not be compiled, the class is not available and can not be loaded.

That's the reason why you get an com.mvp4g.util.exception.loader.Mvp4gAnnotationException.

Hope that helps