users@jaxb.java.net

Re: ValidationEventHandler returns only parent object through ValidationEvent.getLocator().getObject()

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 29 Sep 2004 10:42:27 -0400

Aleksei Valikov wrote:
> I'm also interested in on-demand validation that would, for instance,
> allow displaying detailed validation messages in a document editor.

The problem that I have with this is that the JAXB on-demand validation
is still based on XML validation. So errors are all found in terms of XML.

For example, when you are missing the city property, the error is
actually "unexpected <zip-code> element: <city> expected", and it just
doesn't naturally translate to the level of errors that the application
developers would be looking for (such as "property city is missing from
this Address object, along with enough information to let him put the
focus on the right Swing component.)

Plus then there's an issue of further translating those errors to
user-level error messages (such as "please type in a proper city name".)
Furthermore, it is a very common for schemas to leave out some of the
constraints.

Another thing is, those constraint checks on objects are by no means
limited to JAXB --- you could have the same problem with Hibernate, for
example.

Yet another problem is that this on-demand validation is the primary
reason we have to require such a huge runtime jars. Essentially it
amounts to implementing a custom schema validator, and that's just insane.

I think it would be much nice if someone develops a framework to check
constraints on a Java object graph. Then JAXB can produce a contraint
set from a given schema. Such a framework would do a much better job of
reporting errors, it would allow you to add more constraints, and it
would have enough hook to connect errors to your application.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net