本文整理汇总了Java中javax.portlet.ActionRequest.getParameter方法的典型用法代码示例。如果您正苦于以下问题:Java ActionRequest.getParameter方法的具体用法?Java ActionRequest.getParameter怎么用?Java ActionRequest.getParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.portlet.ActionRequest
的用法示例。
在下文中一共展示了ActionRequest.getParameter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateMeasurement
import javax.portlet.ActionRequest; //导入方法依赖的package包/类
protected Measurement updateMeasurement(ActionRequest actionRequest) throws Exception {
long measurementId = ParamUtil.getLong(actionRequest, "measurementId");
ServiceContext serviceContext = ServiceContextFactory.getInstance(Measurement.class.getName(), actionRequest);
PortletPreferences portletPreferences = actionRequest.getPreferences();
String jsonSchema = portletPreferences.getValue("jsonSchema", "{}");
com.liferay.portal.kernel.json.JSONObject jsonSchemaObj = JSONFactoryUtil.createJSONObject(jsonSchema);
Iterator<String> keys = null;
if (jsonSchemaObj != null) {
com.liferay.portal.kernel.json.JSONObject itemsObj = jsonSchemaObj.getJSONObject("items");
if (itemsObj != null) {
com.liferay.portal.kernel.json.JSONObject propertiesObj = itemsObj.getJSONObject("properties");
keys = propertiesObj.keys();
}
}
String data = null;
String id = null;
String name = null;
Date timestamp = null;
String unit = null;
String value = null;
DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd'T'HH:mm:ss");
if (keys != null) {
com.liferay.portal.kernel.json.JSONObject dataObj = JSONFactoryUtil.createJSONObject();
while (keys.hasNext()) {
String key = keys.next();
// TODO: json fields must be prefixed with json-namespace
String val = actionRequest.getParameter(key);
dataObj.put(key, val);
}
data = dataObj.toJSONString();
} else {
data = ParamUtil.getString(actionRequest, DataManagerField.DATA);
id = ParamUtil.getString(actionRequest, DataManagerField.ID);
name = ParamUtil.getString(actionRequest, DataManagerField.NAME);
timestamp = ParamUtil.getDate(actionRequest, DataManagerField.TIMESTAMP, dateFormat);
unit = ParamUtil.getString(actionRequest, DataManagerField.UNIT);
value = ParamUtil.getString(actionRequest, DataManagerField.VALUE);
}
// TODO: validate data against configured JSON-schema
Measurement measurement = null;
if (measurementId <= 0) {
// Add measurement
measurement = _measurementService.addMeasurement(data, id, name, timestamp, unit, value, serviceContext);
} else {
// Update measurement
measurement = _measurementService.updateMeasurement(measurementId, data, id, name, timestamp, unit, value,
serviceContext);
}
return measurement;
}