I have found the answer to my own question. The parser used for
UIObjects is UIObjectParser which does not allow any child elements.
Currently in the SDK there is no way to register a custom parser
(although there is a TODO in the code to add such a mechanism). So
with the SDK as it is the only way to add child elements is to make my
rule extend Widget and my TextField implement HasWidgets.

Given that there seems to be intent to allow custom parsers I took the
decision to customize the UIObjectParser and basically add the
contents of the parse method from the HasWidgetsParser to the end of
the UIObjectParser parse method.

There does seem to be a bug in the UiBinderWriter#isWidgetElement
method simply checks whether the namespace of the element starts with
urn:import which obviously only checks the element maps to an object
although a class cast exception will result later if it is not a
Widget.

On Dec 12, 1:36 pm, Dave Finch <finch.d...@googlemail.com> wrote:
> Hi,
>
> I am using the UiBinder mechanism in GWT 2.0 and have created a
> standard text field that includes a label, required icon etc. which
> all works great.
> The field also includes a list of validation rules which i currently
> add from the java code in my form class  but i would like to include
> them in my form.ui.xml file as follows:
>
> <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
>     xmlns:a='urn:import:com.acuedo.gwt.common.client.core.widgets'
>     xmlns:v='urn:import:com.acuedo.gwt.common.client.core.validation'
>     xmlns:gwt='urn:import:com.google.gwt.user.client.ui'>
>     <gwt:SimplePanel stylePrimaryName="margin5">
>         <gwt:DecoratorPanel>
>             <gwt:FlowPanel stylePrimaryName="margin5">
>                 <a:TextField ui:field="title" label="Title"
>                     required="true" >
>                     <v:RegexRule pattern="[ a-zA-Z0-9]*"
> errorMessage="Your title can only contain letters, numbers and
> spaces." />
>                 </a:TextField>
>                 <gwt:Button ui:field="saveButton" text="Submit" />
>             </gwt:FlowPanel>
>         </gwt:DecoratorPanel>
>     </gwt:SimplePanel>
> </ui:UiBinder>
>
> but this doesn't compile. I get the following error:
> 12:48:35.060 [ERROR] [admin] In
> com.google.gwt.uibinder.rebind.xmlelemen...@185ee14, found unexpected
> child "<v:RegexRule errorMessage='Your site&#39;s title can only
> contain letters, numbers and spaces.' pattern='[ a-zA-Z0-9]*'>"
>
> Does anyone know if it is possible to do this and if so how?
>
> (My RegexRule class does not extend widget because it doesn't have any
> visual aspect.)
>
> Thanks,
> Dave

--

You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.


Reply via email to