I'm trying to create a decorator that works for LeafValueEditor as opposed
to ValueBoxEditor but I'm finding that, in the case of
ValueBoxEditor showErrors is passed *two *EditorError objects per error.
One that has an editor that equals the ValueBoxEditor and the other that
has an editor that equals the decorator. If all I change is the type of
editor returned from asEditor to LeafValueEditor, then only *one* EditorError
is passed in, with an editor equal to the decorator. What's going on here?
On Thursday, May 5, 2011 5:15:44 PM UTC+1, Thomas Broyer wrote:
>
> Assuming you want to replicate the HasEditorErrors behavior (otherwise, I
> don't see the point in having the decorator an Editor by itself), it'll
> depends whether you want to decorate a LeafValueEditor or an Editor with
> sub-editors, and/or an IsEditor.
> We learned it the hard way this week, so better share our findings than
> let you drive nuts with something that works in some cases and not in
> others.
>
> For a LeafValueEditor, make your decorator an IsEditor and
> HasEditorErrors, with the asEditor() method returning your wrapped
> LeafValueEditor. For an IsEditor<LeafValueEditor<?>>, you'd have to
> "unwrap" it (call asEditor) yourself (like ValueBoxEditorDecorator does),
> which presumes the editor isn't itself both an IsEditor and an Editor
> (HasEditorDelegate, HasEditorErrors, etc.). Being both IsEditor and Editor
> is IMO a bad practice, but sometimes you don't have the choice.
>
> For a complex Editor (with sub-editors), do not implement IsEditor, but
> instead use a @Path("") sub-editor (typed either as your Editor type or
> IsEditor depending on what you need).
>
> For the rest, you can basically copy from ValueBoxEditorDecorator.
>
> HTH, ask if you need more info.
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/FW-Ly8a89i4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.