Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to reference enums in a GWT UiBinder context

I have an enumeration that looks like the following

public enum MyEnum {
    A,
    B;
}

And then I have a UiBinder file with a custom component that has a setter and getter expecting the enum above. (I've stripped the extra code for

<ui:UiBinder ....>
    <g:HTMLPanel>
        ....
        <myNamespace:myComponent myAttribute="" />
        ....
    </g:HTMLPanel>
</ui:UiBinder>

Can I reference my enum and put that value into myAttribute in any way? What I want to accomplish is something like this

<ui:UiBinder ....>
    <ui:with field="myEnumField" type="com.example.MyEnum" />
    <g:HTMLPanel>
        ....
        <myNamespace:myComponent myAttribute="{myEnumField.A}" />
        ....
    </g:HTMLPanel>
</ui:UiBinder>

However it would seem that I cannot do this with ui:with. Can I do this in any way at all?

like image 483
wasatz Avatar asked Jan 19 '23 06:01

wasatz


1 Answers

After searching a bit more I realized that you could actually do the following:

<ui:import field="com.example.MyEnum.*" />
<g:HTMLPanel>
    ...
    <myNamespace:myComponent myAttribute="{A}" />
    ...
</g:HTMLPanel>
like image 56
wasatz Avatar answered Feb 07 '23 19:02

wasatz