[Databinding] using ValidationStatusProvider to link external validation framework [message #331772] |
Sun, 21 September 2008 19:03  |
Eclipse User |
|
|
|
Originally posted by: zx.code9.com
So here is my use case.
(1) I have some Java beans that act as model code.
(2) Databinding is used to bind the model some some UI widgets
(3) Databinding is also used to do validation
(4) There is also an external "global" validator that is used to do
validation to simplify the pain of writing validators for users. This
was done mainly to handle the complexities of validation when it is
across bindings... that is... you have elements that depend on each
other. I believe this could be done with MultiValidator in Databinding,
but we are trying hard to hide any Databinding code from developers.
I was looking at linking this "ICustomValidator" with databinding to
have one unified front of managing interactions. I believe this is
possible via ValidationStatusProvider but things are a bit tricky.
Any advice how to tackle this problem? Was anything done in EMF
Databinding to link EMF Validators with databinding?
This problem is slightly similar to what Riena is trying to with its
"Ridgets"
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.riena/o rg.eclipse.riena.sample.snippets/src/org/eclipse/riena/sampl e/snippets/SnippetTextRidget001.java?root=RT_Project&vie w=markup
We are trying to prevent users from writing complex databinding if they
don't have to.
|
|
|
Re: [Databinding] using ValidationStatusProvider to link external validation framework [message #331773 is a reply to message #331772] |
Sun, 21 September 2008 19:45   |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------020107080908040302060807
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Chris,
In EMF you can defined name constraints on EClassifiers (EClasses and
EDataTypes). Things like the facet constraints on simple types from XML
Schema are directly supported and you can add your own hand-implemented
named constraints:
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/references/overview/EMF.Validation.html
I'll bet it wouldn't be hard to hook up things like
Diagnostician.INSTANCE.validate to the data binding stuff. I'd be happy
to help explore that for the 2.5 release. Right now things like
EMFUpdateValueStrategy just help with the conversion from a String to a
value, which will yield messages about conversion problems, but it would
be interesting to ensure that the constraints are also enforce. E.g.,
10 might be a valid integer, but if the values are constrained to be > 2
and < 9 then it's still wrong...
Chris Aniszczyk wrote:
> So here is my use case.
>
> (1) I have some Java beans that act as model code.
> (2) Databinding is used to bind the model some some UI widgets
> (3) Databinding is also used to do validation
> (4) There is also an external "global" validator that is used to do
> validation to simplify the pain of writing validators for users. This
> was done mainly to handle the complexities of validation when it is
> across bindings... that is... you have elements that depend on each
> other. I believe this could be done with MultiValidator in
> Databinding, but we are trying hard to hide any Databinding code from
> developers.
>
> I was looking at linking this "ICustomValidator" with databinding to
> have one unified front of managing interactions. I believe this is
> possible via ValidationStatusProvider but things are a bit tricky.
>
> Any advice how to tackle this problem? Was anything done in EMF
> Databinding to link EMF Validators with databinding?
>
> This problem is slightly similar to what Riena is trying to with its
> "Ridgets"
>
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.riena/o rg.eclipse.riena.sample.snippets/src/org/eclipse/riena/sampl e/snippets/SnippetTextRidget001.java?root=RT_Project&vie w=markup
>
>
> We are trying to prevent users from writing complex databinding if
> they don't have to.
--------------020107080908040302060807
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Chris,<br>
<br>
In EMF you can defined name constraints on EClassifiers (EClasses and
EDataTypes). Things like the facet constraints on simple types from
XML Schema are directly supported and you can add your own
hand-implemented named constraints:<br>
<blockquote><a
href=" http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/references/overview/EMF.Validation.html"> http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/references/overview/EMF.Validation.html</a><br>
</blockquote>
I'll bet it wouldn't be hard to hook up things like
Diagnostician.INSTANCE.validate to the data binding stuff. I'd be
happy to help explore that for the 2.5 release. Right now things like
EMFUpdateValueStrategy just help with the conversion from a String to a
value, which will yield messages about conversion problems, but it
would be interesting to ensure that the constraints are also enforce.
E.g., 10 might be a valid integer, but if the values are constrained to
be > 2 and < 9 then it's still wrong...<br>
<br>
<br>
<br>
Chris Aniszczyk wrote:
<blockquote cite="mid:gb65qm$av0$1@build.eclipse.org" type="cite">So
here is my use case.
<br>
<br>
(1) I have some Java beans that act as model code.
<br>
(2) Databinding is used to bind the model some some UI widgets
<br>
(3) Databinding is also used to do validation
<br>
(4) There is also an external "global" validator that is used to do
validation to simplify the pain of writing validators for users. This
was done mainly to handle the complexities of validation when it is
across bindings... that is... you have elements that depend on each
other. I believe this could be done with MultiValidator in Databinding,
but we are trying hard to hide any Databinding code from developers.
<br>
<br>
I was looking at linking this "ICustomValidator" with databinding to
have one unified front of managing interactions. I believe this is
possible via ValidationStatusProvider but things are a bit tricky.
<br>
<br>
Any advice how to tackle this problem? Was anything done in EMF
Databinding to link EMF Validators with databinding?
<br>
<br>
This problem is slightly similar to what Riena is trying to with its
"Ridgets"
<br>
<br>
<a class="moz-txt-link-freetext" href=" http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.riena/o rg.eclipse.riena.sample.snippets/src/org/eclipse/riena/sampl e/snippets/SnippetTextRidget001.java?root=RT_Project&vie w=markup"> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.riena/o rg.eclipse.riena.sample.snippets/src/org/eclipse/riena/sampl e/snippets/SnippetTextRidget001.java?root=RT_Project&view=markup</a>
<br>
<br>
We are trying to prevent users from writing complex databinding if they
don't have to.
<br>
</blockquote>
</body>
</html>
--------------020107080908040302060807--
|
|
|
Re: [Databinding] using ValidationStatusProvider to link external validation framework [message #331774 is a reply to message #331772] |
Sun, 21 September 2008 20:41   |
Eclipse User |
|
|
|
This is also on the list for UFacekit but I didn't wrapped by head
around it.
Tom
Chris Aniszczyk schrieb:
> So here is my use case.
>
> (1) I have some Java beans that act as model code.
> (2) Databinding is used to bind the model some some UI widgets
> (3) Databinding is also used to do validation
> (4) There is also an external "global" validator that is used to do
> validation to simplify the pain of writing validators for users. This
> was done mainly to handle the complexities of validation when it is
> across bindings... that is... you have elements that depend on each
> other. I believe this could be done with MultiValidator in Databinding,
> but we are trying hard to hide any Databinding code from developers.
>
> I was looking at linking this "ICustomValidator" with databinding to
> have one unified front of managing interactions. I believe this is
> possible via ValidationStatusProvider but things are a bit tricky.
>
> Any advice how to tackle this problem? Was anything done in EMF
> Databinding to link EMF Validators with databinding?
>
> This problem is slightly similar to what Riena is trying to with its
> "Ridgets"
>
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.riena/o rg.eclipse.riena.sample.snippets/src/org/eclipse/riena/sampl e/snippets/SnippetTextRidget001.java?root=RT_Project&vie w=markup
>
>
> We are trying to prevent users from writing complex databinding if they
> don't have to.
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
|
|
Re: [Databinding] using ValidationStatusProvider to link external validation framework [message #331818 is a reply to message #331772] |
Tue, 23 September 2008 20:28  |
Eclipse User |
|
|
|
Initially, DataBindingContext only had a list of bindings (all producing
validation statuses). In 3.4, we introduced the more abstract
ValidationStatusProvider with exactly your use case in mind - you may have
additional logic (usually on the model side) that also produces validation
statuses. Note that this does not change how the bindings work, i.e. they
will not stop updating the model when there are validation errors - the
whole point of doing model-side validation is that you change the model
objects so that you can run your validation logic on them. You might need a
"working copy" of model objects that can tolerate invalid values
temporarily.
I would look at how MultiValidator is implemented, but it sounds like you
may want to subclass ValidationStatusProvider yourself. All you need to do
is return something useful for getValidationStatus() - getTargets() and
getModels() is optional, it can be useful if you have any code that needs to
know how the bindings or other validation status producers are connected to
model or target observables. One example for this (the only so far) is how
WizardPageSupport uses getTargets() to detect when the user has started
interacting with the UI so that it does not produce warnings or errors
before that.
I hope this helps - if it doesn't, you can always file a bug and ask for a
code snippet. ;-)
Boris
"Chris Aniszczyk" <zx@code9.com> wrote in message
news:gb65qm$av0$1@build.eclipse.org...
> So here is my use case.
>
> (1) I have some Java beans that act as model code.
> (2) Databinding is used to bind the model some some UI widgets
> (3) Databinding is also used to do validation
> (4) There is also an external "global" validator that is used to do
> validation to simplify the pain of writing validators for users. This was
> done mainly to handle the complexities of validation when it is across
> bindings... that is... you have elements that depend on each other. I
> believe this could be done with MultiValidator in Databinding, but we are
> trying hard to hide any Databinding code from developers.
>
> I was looking at linking this "ICustomValidator" with databinding to have
> one unified front of managing interactions. I believe this is possible via
> ValidationStatusProvider but things are a bit tricky.
>
> Any advice how to tackle this problem? Was anything done in EMF
> Databinding to link EMF Validators with databinding?
>
> This problem is slightly similar to what Riena is trying to with its
> "Ridgets"
>
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.riena/o rg.eclipse.riena.sample.snippets/src/org/eclipse/riena/sampl e/snippets/SnippetTextRidget001.java?root=RT_Project&vie w=markup
>
> We are trying to prevent users from writing complex databinding if they
> don't have to.
|
|
|
Powered by
FUDForum. Page generated in 0.04047 seconds