I have an enum class named "BlankEnm" and have a searchlayout.html page. How can i use enum velues in html page in <select>
( <option>
) tags. i want to see them in the select box (combo box)
I tried obuot the th tags ( <th th:text="bla bla ">
), but coudn't get any progress. It didn't work.
here is my enum class that i would like to use in the html page;
public enum BlankEnm {
ALL(0,"blankEnm.all"),
TITLE(1, "blankEnm.title"),
IDENTITY(2, "blankEnm.identity"),
TAXNUMBER(3, "blankEnm.taxNumber");
private final int id;
private final String text;
BlankEnm(int id, String text) {
this.id = id;
this.text = text;
}
public int id() {
return this.id;
}
public String text() {
return this.text;
}
public static int blankMapper(String blankChar) {
switch (blankChar.toLowerCase()) {
case "ü":
return TITLE.id;
case "k":
return IDENTITY.id;
case "v":
return TAXNUMBER.id;
default:
return 0;
}
}
public static BlankEnm parseType(Integer value) {
for (BlankEnm type : BlankEnm.values()) {
if (value.equals(type.id())) {
return type;
}
}
return null;
}
}
I expect using my enum class elements in the html page in a select box
I'd suggest you to store the values of your Enum in a new class and than iterate throug an ArrayList with the different objects of your class in it.
Your Class:
public class Data {
private int id;
...
public Data(int id) {
this.id = id;
...
}
}
Array List:
ArrayList<Data> list = new ArrayList<>();
list.add(new Data(0));
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.