Aipoの一覧画面でタイトルや更新日付などでソートをするときに、テンプレートでは
#ALtdheadAtt("#ALajaxsort('wiki_name' $l10n.WIKI_TITLE $result 'WikiListScreen')" "")のように書きます。 ただここを変更しただけではソートは効きません。
/**
* @return
*
*/
@Override
protected Attributes getColumnMap() {
Attributes map = new Attributes();
map.putValue("wiki_name", EipTWiki.WIKI_NAME_PROPERTY);
map.putValue("parent_name", EipTWiki.PARENT_ID_PROPERTY);
map.putValue("update_user", EipTWiki.UPDATE_USER_ID_PROPERTY);
map.putValue("update_date", EipTWiki.UPDATE_DATE_PROPERTY);
return map;
}にソートさせたいキーをセットしておきます。ソートする際のキーワードとソートさせるデータベースのカラムを紐付けます。
なぜここを変更する必要が有るかというと、
のところでセッションに入っているソートのキーを上で設定したマップのデータベースのカラムを取り出しているからです。
/**
* ソート用の <code>SelectQuery</code> を構築します。
*
* @param crt
* @return
*/
protected SelectQuery<M1> buildSelectQueryForListViewSort(
SelectQuery<M1> query, RunData rundata, Context context) {
String sort = ALEipUtils.getTemp(rundata, context, LIST_SORT_STR);
String sort_type = ALEipUtils.getTemp(rundata, context, LIST_SORT_TYPE_STR);
String crt_key = null;
Attributes map = getColumnMap();
if (sort == null) {
return query;
}
crt_key = map.getValue(sort);
if (crt_key == null) {
return query;
}
if (sort_type != null
&& ALEipConstants.LIST_SORT_TYPE_DESC.equals(sort_type)) {
query.orderDesending(crt_key);
} else {
query.orderAscending(crt_key);
sort_type = ALEipConstants.LIST_SORT_TYPE_ASC;
}
current_sort = sort;
current_sort_type = sort_type;
return query;
}


