It turns out this is already supported in the editor framework, though 
perhaps not in your editors themselves - the framework even supports a 
collection being passed from the client code (perhaps from the server) to 
the driver to indicate that there are problems, and which fields to 
highlight. The call on the driver is
driver.setConstraintViolations(...)

That takes an Iterable (a List or a Set will work) of 
javax.validation.ConstraintViolation instances. If you create these objects 
on the server (using Java's own validation wiring), you can pass them 
along, else just use 
com.google.gwt.validation.client.impl.ConstraintViolationImpl's builder() 
method, and create the instances.

You'll need to at least pass the propertyPath (to each bean property that 
is wrong), the message (to show the user), and the rootBean (which I 
believe represents the base object passed to the driver, but it has been a 
while).

Then, the driver will inform all of your editors which implement 
HasEditorErrors<T>, by calling their showErrors(...) method with a List of 
com.google.gwt.editor.client.EditorError instances. With this, you can 
display that red dot, and give the message about why it is wrong. In GWT 
itself, only ValueBoxEditorDecorator implements this (and you would wrap a 
ValueBoxBase subtype with it), but toolkits like GXT show that it is also 
possible to make each of your individual editors implement it as well.

You can also implement it at the panel level, where you might also say 
Editor<Person>, add HasEditorErrors<Person>, and then that will get all of 
the errors within that person instance, so you can render them.

On Thursday, November 16, 2017 at 2:06:49 AM UTC-6, 129pierre wrote:
>
> Hi,
>
> I have a tree structure of data with a lot of fields and relations. I used 
> Editors to avoid too much code.
> I have an additionnal feature implemented with Editors but not satisfiying.
> For almost all fields in the structure a RedPoint is diplayed next to the 
> field if it is still with the init value (ie: Not answered for RadioButton 
> or empty for textfield...).
> To implement that RedPoint feature, I added for each field a boolean 
> fieldRP in the bean so that they are part of the editors.
>
> In case of change, the bean is flush, each boolean are computed and the 
> bean is edited again for display modification of redpoints.
>
> I am looking for a simpler way of doing that. For example, use 2 beans so 
> only flush of data and edit of boolean RP will be necessary.
> But for my understanding of Editors, only one bean can be used...
>
>
> Any help will be apprecied.
> Thanks in advance
> Pierre
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to