A web application can have one or more static data lists that it has to display and control. For example, the list of states, a list of genders, a list of accepted payment methods, etc. With Mentawai you can define localized and non-localized static lists in the database to load and display easily in the web application.
Non-localized data list:
mysql> select * from genders; +----+--------+ | id | value | +----+--------+ | 1 | Man | | 2 | Woman | +----+--------+
Localized data list:
mysql> select * from genders; +----+--------+---------------+ | id | locale | value | +----+--------+---------------+ | 1 | en_US | Man | | 2 | en_US | Woman | | 1 | pt_BR | Homem | | 2 | pt_BR | Mulher | +----+--------+---------------+
Loading in the application manager:
@Override public void loadLists() { addLocalizedLists("groups", "languages"); // localized // OR addLists("groups", "languages"); // non-localized }
Displaying as a combo box inside a HTML form:
<!-- basics --> <mtw:select name="groupId" list="groups" /> <!-- show an empty item with value=0 --> <mtw:select name="groupId" list="groups" emptyField="true" />
Displaying its value:
<mtw:out value="user.groupId" list="groups" />
NOTE: The values displayed will be in the correct language if the list is localized. No need to worry or do anything.
Validating:
In the action:
val.requiredLists("required_field", "groupId", "languageId");
In the JSP:
<mtw:outError field="groupId"> <font color="red"> <b><mtw:out /></b> </font> </mtw:outError>