本文整理汇总了Java中javax.portlet.ActionRequest.getPreferences方法的典型用法代码示例。如果您正苦于以下问题:Java ActionRequest.getPreferences方法的具体用法?Java ActionRequest.getPreferences怎么用?Java ActionRequest.getPreferences使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.portlet.ActionRequest
的用法示例。
在下文中一共展示了ActionRequest.getPreferences方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionSaveFacetConfig
import javax.portlet.ActionRequest; //导入方法依赖的package包/类
/**
* This action saves the Liferay facet configuration for a given tab
*
* @param request The request
* @param response The response
* @throws PortletException If something goes wrong
* @throws IOException If something goes wrong
*/
@ProcessAction(name = ACTION_NAME_SAVE_FACET_CONFIG)
public void actionSaveFacetConfig(ActionRequest request, ActionResponse response) throws PortletException, IOException {
String tabId = ParamUtil.get(request, PortletRequestParameter.TAB_ID.getName(), StringPool.BLANK);
String facetClassName = ParamUtil.get(request, FORM_FIELD_FACET_CLASS_NAME, StringPool.BLANK);
String redirectUrl = ParamUtil.get(request, FORM_FIELD_REDIRECT_URL, StringPool.BLANK);
PortletPreferences preferences = request.getPreferences();
FlashlightSearchConfiguration configuration = this.searchService.readConfiguration(preferences);
SearchFacet targetFacet = this.getSearchFacetFromRequest(tabId, facetClassName, configuration);
if(targetFacet != null) {
JSONObject facetConfiguration = targetFacet.getJSONData(request);
targetFacet.getFacetConfiguration().setDataJSONObject(facetConfiguration);
this.searchService.saveSearchFacetConfig(configuration.getTabs().get(tabId), targetFacet, preferences);
SessionMessages.add(request, SESSION_MESSAGE_CONFIG_SAVED);
response.sendRedirect(redirectUrl);
}
}
示例2: actionDeleteTab
import javax.portlet.ActionRequest; //导入方法依赖的package包/类
/**
* Deletes a tab from the configuration
*
* @param request The request
* @param response The response
* @throws PortletException If something goes wrong
* @throws IOException If something goes wrong
*/
@ProcessAction(name = ACTION_NAME_DELETE_TAB)
public void actionDeleteTab(ActionRequest request, ActionResponse response) throws PortletException, IOException {
String tabId = ParamUtil.get(request, PortletRequestParameter.TAB_ID.getName(), StringPool.BLANK);
String redirectUrl = ParamUtil.get(request, FORM_FIELD_REDIRECT_URL, StringPool.BLANK);
if (tabId != null && PATTERN_UUID.matcher(tabId).matches()) {
PortletPreferences preferences = request.getPreferences();
Map<String, FlashlightSearchConfigurationTab> tabs = this.searchService.readConfiguration(preferences).getTabs();
if (tabs.containsKey(tabId)) {
this.searchService.deleteConfigurationTab(tabId, preferences);
}
}
SessionMessages.add(request, SESSION_MESSAGE_CONFIG_SAVED);
if (!redirectUrl.isEmpty()) {
response.sendRedirect(redirectUrl);
}
}
示例3: 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;
}