当前位置: 首页>>代码示例>>Java>>正文


Java ActionRequest.getPreferences方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:savoirfairelinux,项目名称:flashlight-search,代码行数:26,代码来源:FlashlightSearchPortlet.java

示例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);
    }
}
 
开发者ID:savoirfairelinux,项目名称:flashlight-search,代码行数:28,代码来源:FlashlightSearchPortlet.java

示例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;

    }
 
开发者ID:inofix,项目名称:ch-inofix-data-manager,代码行数:81,代码来源:EditMeasurementMVCActionCommand.java


注:本文中的javax.portlet.ActionRequest.getPreferences方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。