Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use enum values as field values inside UiBinder template?

Tags:

gwt

gwt2

uibinder

Can I use enum values as field values inside UiBinder template ? I'm using GWT 2.4

Something like this

<ui:with field="en" type="com.mine.courierApp.shared.PayerType" />

looks promising, where

public enum PayerType
{
    Sender,
    Recipient
}

but I can't refer to values of the enum by en.Sender.

Is it even possible ?

like image 694
expert Avatar asked Feb 29 '12 02:02

expert


1 Answers

<ui:import field='com.mine.courierApp.shared.PayerType.Sender' />

or

<ui:import field='com.mine.courierApp.shared.PayerType.*' />

And then you can use it as payerType='{Sender}'.

But UiBinder should automatically try to translate enum constant names into values, so the following should work without any need for a ui:with:

<my:MyWidget payerType='Sender' />

If the MyWidget widget has a public void setPayerType(PayerType type) method, UiBinder should look for an enum value named Sender (from the *.ui.xml file) in the PayerType enum (from the method's argument type).

like image 91
Thomas Broyer Avatar answered Nov 09 '22 06:11

Thomas Broyer