|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mentawai.list.DBListData
public class DBListData
The ListData that will load its ListItems from a database. All you have to do is provide: - the name of the key column - the name of the value column - the name of the locale column - the name of the table - the column to sort Or if you database table is not localized: - the name of the key column - the name of the value column - the name of the table - the single locale to use for that list
| Constructor Summary | |
|---|---|
DBListData(String name)
|
|
DBListData(String name,
String orderBy)
|
|
DBListData(String name,
String keyColumn,
String valueColumn,
String tableName,
String orderByColumn)
If your database table is not localized, in other words, if it does not care about locales and have only one list in one locale, use this constructor. |
|
DBListData(String name,
String keyColumn,
String valueColumn,
String localeColumn,
String tableName,
String orderByColumn)
If your database table is localized, in other words, if it has a locale column to define the locale, use this constructor. |
|
| Method Summary | |
|---|---|
protected String |
buildSQL(boolean isLocalized)
|
protected Locale |
getLocaleFromString(String loc)
Override this method to map whatever you have in your database to a Java locale. |
String |
getName()
Returns the name of this list. |
String |
getValue(int key)
Returns the string value of the list data item with the given id with the default locale. |
String |
getValue(int key,
Locale loc)
Returns the string value of the list data item with the given id in the given locale. |
String |
getValue(String key)
Returns the string value for the list data item with the default locale. |
String |
getValue(String key,
Locale loc)
Returns the string value of the list data item with the given id in the given locale. |
List<ListItem> |
getValues()
Returns a list of ListItem for the default locale. |
List<ListItem> |
getValues(Locale loc)
Returns a list of ListItem in the given locale. |
boolean |
isLocalized()
|
void |
load(Connection conn)
Call this method passing a db connection to load the lists from database! The SQL statement that will be constructed: "select " + keyColumn + "," + valueColumn + "," + localeColumn + " from " + tableName + " order by " + orderByColumn; or if localeColumn is null and a single locale (unique) is provided "select " + keyColumn + "," + valueColumn + " from " + tableName + " order by " + orderByColumn; |
void |
load(ConnectionHandler connHandler)
|
void |
loadUsingJPA()
load the lists from database from JPA Entity Manager warning: you NEED a defined persistence unit ! |
void |
refresh(Connection conn)
The only difference of this method to the load(conn) method is that it will clear everything before loading... |
void |
refresh(ConnectionHandler connHandler)
|
void |
run()
|
void |
setWhere(String where)
|
int |
size()
Returns the size of this list. |
void |
startAutoRefresh(ConnectionHandler connHandler,
long time)
|
void |
stopAutoRefresh()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DBListData(String name,
String keyColumn,
String valueColumn,
String localeColumn,
String tableName,
String orderByColumn)
name - keyColumn - valueColumn - localeColumn - tableName - orderByColumn -
public DBListData(String name,
String keyColumn,
String valueColumn,
String tableName,
String orderByColumn)
name - keyColumn - valueColumn - tableName - orderByColumn - public DBListData(String name)
public DBListData(String name,
String orderBy)
| Method Detail |
|---|
public boolean isLocalized()
public void setWhere(String where)
public void startAutoRefresh(ConnectionHandler connHandler,
long time)
public void stopAutoRefresh()
public void run()
run in interface Runnablepublic int size()
ListData
size in interface ListData
public String getValue(String key,
Locale loc)
ListData
getValue in interface ListDatakey - The id of the list data item.loc - The locale of the list data item.
public String getValue(String key)
ListData
getValue in interface ListDatapublic String getValue(int key)
ListData
getValue in interface ListDatakey - The id of the list data item
public String getValue(int key,
Locale loc)
ListData
getValue in interface ListDatakey - The id of the list data item.loc - The locale of the list data item.
public List<ListItem> getValues(Locale loc)
ListData
getValues in interface ListDataloc - The locale of the ListItems.
public List<ListItem> getValues()
ListData
getValues in interface ListDatapublic String getName()
ListData
getName in interface ListDataprotected Locale getLocaleFromString(String loc)
loc -
public void load(ConnectionHandler connHandler)
protected String buildSQL(boolean isLocalized)
public void load(Connection conn)
conn -
SQLExceptionpublic void loadUsingJPA()
public void refresh(ConnectionHandler connHandler)
throws SQLException
SQLException
public void refresh(Connection conn)
throws SQLException
conn -
SQLException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||