use of org.olat.core.gui.media.JSONMediaResource in project OpenOLAT by OpenOLAT.
the class TextBoxListComponent method setMapper.
/**
* registers a OpenOLAT Mapper for this textBoxListComponent
*
* @param ureq
*/
private void setMapper(UserRequest ureq) {
Mapper mapper = new Mapper() {
public MediaResource handle(String relPath, HttpServletRequest request) {
String lastInput = request.getParameter("term");
if (lastInput != null && lastInput.length() > 2) {
Map<String, String> autoCContLoc = new HashMap<String, String>();
provider.getAutoCompleteContent(lastInput, autoCContLoc);
setAutoCompleteContent(autoCContLoc);
}
JSONArray jsonResult = getAutoCompleteJSON();
return new JSONMediaResource(jsonResult, "UTF-8");
}
};
mapperKey = CoreSpringFactory.getImpl(MapperService.class).register(ureq.getUserSession(), mapper);
}
use of org.olat.core.gui.media.JSONMediaResource in project OpenOLAT by OpenOLAT.
the class JSTranslatorMapper method handle.
/**
* @see org.olat.core.dispatcher.mapper.Mapper#handle(java.lang.String, javax.servlet.http.HttpServletRequest)
*/
public MediaResource handle(String relPath, HttpServletRequest request) {
I18nManager i18nManager = I18nManager.getInstance();
// Get bundle and locale
String[] parts = relPath.split("/");
String localeKey = parts[1];
String bundleName = parts[2];
Locale locale = i18nManager.getLocaleOrDefault(localeKey);
// Get the translation data
JSONObject translationData = i18nManager.getJSONTranslatorData(locale, bundleName);
return new JSONMediaResource(translationData, "UTF-8");
}
use of org.olat.core.gui.media.JSONMediaResource in project openolat by klemens.
the class AutoCompleterMapper method handle.
@Override
public MediaResource handle(String relPath, HttpServletRequest request) {
// Read query and generate JSON result
String lastN = request.getParameter(PARAM_QUERY);
JSONArray result;
if (StringHelper.containsNonWhitespace(lastN)) {
AutoCompleterListReceiver receiver = new AutoCompleterListReceiver(noResults, showDisplayKey);
gprovider.getResult(lastN, receiver);
result = receiver.getResult();
} else {
result = new JSONArray();
}
return new JSONMediaResource(result, "UTF-8");
}
use of org.olat.core.gui.media.JSONMediaResource in project OpenOLAT by OpenOLAT.
the class AutoCompleterMapper method handle.
@Override
public MediaResource handle(String relPath, HttpServletRequest request) {
// Read query and generate JSON result
String lastN = request.getParameter(PARAM_QUERY);
JSONArray result;
if (StringHelper.containsNonWhitespace(lastN)) {
AutoCompleterListReceiver receiver = new AutoCompleterListReceiver(noResults, showDisplayKey);
gprovider.getResult(lastN, receiver);
result = receiver.getResult();
} else {
result = new JSONArray();
}
return new JSONMediaResource(result, "UTF-8");
}
use of org.olat.core.gui.media.JSONMediaResource in project OpenOLAT by OpenOLAT.
the class FullCalendarMapper method handle.
/**
* [{
* "id":111,
* "title":"Event1",
* "start":"2013-03-10",
* "url":"http:\/\/yahoo.com\/"
* },{
* "id":222,
* "title":"Event2",
* "start":"2013-03-20",
* "end":"2013-03-22",
* "url":"http:\/\/yahoo.com\/"
* }]
*/
@Override
public MediaResource handle(String relPath, HttpServletRequest request) {
try {
JSONArray ja = new JSONArray();
String calendarId = getCalendarID(request);
String start = request.getParameter("start");
String end = request.getParameter("end");
Date startDate = null;
if (StringHelper.isLong(start)) {
long startTime = Long.parseLong(start);
startDate = new Date(startTime * 1000);
}
Date endDate = null;
if (StringHelper.isLong(end)) {
long time = Long.parseLong(end);
endDate = new Date(time * 1000);
}
collectKalendarEvents(ja, calendarId, startDate, endDate);
return new JSONMediaResource(ja, "UTF-8");
} catch (JSONException e) {
log.error("", e);
return null;
}
}
Aggregations