enums - smartgwt DataSourceEnumField example -


I tried to do some research on SmartGWT Showcase and forums, but I could not find the answer. I also tried to spread a wide spread Google search and did not get the answer. So, I hope I can get some help here.

I have an enum Java class in the "Share" folder:

  public enum PointInTimeType {FIRST ("F" "," first "), start (" S Min ("MI", "Min"), Max ("MX", "Max"), EDD ("E", "End"), Last ("L", "Last") ; Private string code; Private string name; Private PointInTimeType (string code, string name) {this.code = code; this.name = name;} public string getCode () {return code;} public string getName () {return Name;}   

I know that I I can make a Datacoren Enamfield and set a Valuemap, but these values ​​are hard-working and the Enum Java class can add more emos in the future. I do not have to update the value even when the enumix is ​​updated. Therefore, knowing that I am going to have a form with the drop-down, I want to set the option for the list of values ​​from the DataSource enumfield.

so, I think I'm asking how do I set up a datasource to get this enum data, or is this linked to the enum Java class?

In this way, when I create my form and tie it to another data source, then I can create a SlectItem and set it as another drop down. I am used to just using datasource attached to a list of objects, and not enums.

The same problem I had encountered and I came to know that "enu" in the name class is actually deceptive is.

Anyway, even though you can use enum, it will be worthless for you since you have custom attributes.

However, you can work to run this problem on and running the value values. Map. Creating an interface like this in a normal way:

  public interface codeNameEnum {String getCode (); String matching (); }   

Then, enum to enforce it:

  public enum PointInTimeType codeNameEnum {FIRST ( "F", "first"), start ("S", "start"), EDD ("E", "end"), last ("L", "last"), min ("MI" Private string code; private string name; private PointInTimeType (string code, string name) {this.code = code; this.name = name;} public string getCode () {Return code;} public string getName () {return name; finally, this term Use the method:  
  public class EnumToMap {public static map & lt; string, string & gt; getMapFromEnum (CodeNameEnum [] codeNameEnumArray) {map & Lt; string, string & gt; map = new hashmap & lt; string, string & gt; (); for (code namename code: codename name) {map.put (codeNameEnum.getCode (), codeNameEnum.getName ()) ;} Return map;} Public static zero main (string [] Args) {Map & lt; String, string & gt; Map = getMapFromEnum (PointInTimeType.values ​​()); Println (map); }}   

So that you can use this method for every nm with code and name.

Otherwise, if this is a different matter, then do this:

  Maps & lt; String, string & gt; Map = new hashmap & lt; String, string & gt; (); (PointInTimeType for items: PointInTimeType.values ​​()) {map.put (item.getCode (), item.getName ()); } Return map;    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -