當前位置: 首頁>>代碼示例>>Java>>正文


Java PortletPreferences.getMap方法代碼示例

本文整理匯總了Java中javax.portlet.PortletPreferences.getMap方法的典型用法代碼示例。如果您正苦於以下問題:Java PortletPreferences.getMap方法的具體用法?Java PortletPreferences.getMap怎麽用?Java PortletPreferences.getMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.portlet.PortletPreferences的用法示例。


在下文中一共展示了PortletPreferences.getMap方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doEdit

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
@Override
public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException {

  response.setContentType("text/html");

  PortletPreferences prefs = request.getPreferences();
  Map<String, String[]> map = prefs.getMap();
  Map<String, String> prefsMap = new HashMap<>();
  for (String key : map.keySet()) {
    String[] prefValue = map.get(key);
    prefsMap.put(key, prefValue == null || prefValue[0] == null ? "" : prefValue[0]);
  }
  request.setAttribute("prefs", prefsMap);

  PortletURL editPrefsURL = response.createActionURL();
  editPrefsURL.setParameter("action", "editPrefs");
  request.setAttribute("actionURL", editPrefsURL.toString());

  forward(editJsp, request, response);
}
 
開發者ID:km-works,項目名稱:reverse-web-proxy-portlet,代碼行數:21,代碼來源:ReverseProxyIFramePortlet.java

示例2: checkGetPreferenceNames

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
protected TestResult checkGetPreferenceNames(PortletRequest request) {
    TestResult result = new TestResult();
    result.setDescription("Ensure returned enumeration is valid.");
    result.setSpecPLT("14.1");

    PortletPreferences preferences = request.getPreferences();
    Map<String, String[]> prefMap = preferences.getMap();
    boolean hasAll = true;
    for (Enumeration<String> en = preferences.getNames(); 
    		en.hasMoreElements(); ) {
        if (!prefMap.containsKey(en.nextElement())) {
            hasAll = false;
            break;
        }
    }

    if (hasAll) {
    	result.setReturnCode(TestResult.PASSED);
    } else {
    	result.setReturnCode(TestResult.FAILED);
    	result.setResultMessage("At least one name is not found "
    			+ "in the preference map.");
    }
    return result;
}
 
開發者ID:apache,項目名稱:portals-pluto,代碼行數:26,代碼來源:PreferenceCommonTest.java

示例3: logPreferences

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
/**
 * Logs out the portlet preferences.
 * @param preferences  PortletPreferences to log.
 */
protected void logPreferences(PortletPreferences preferences) {
	StringBuffer buffer = new StringBuffer();
	Map<String, String[]> map = preferences.getMap();
	for (String key : map.keySet()) {
		String[] values = (String[]) map.get(key);
		buffer.append(key).append("=");
		if (values != null) {
			buffer.append("{");
			for (int i = 0; i < values.length; i++) {
				buffer.append(values[i]);
				if (i < values.length - 1) {
					buffer.append(",");
				}
			}
			buffer.append("}");
		} else {
			// Spec allows null values.
			buffer.append("NULL");
		}
		buffer.append(";");
	}
	LOG.debug("PortletPreferences: " + buffer.toString());
}
 
開發者ID:apache,項目名稱:portals-pluto,代碼行數:28,代碼來源:PreferenceCommonTest.java

示例4: doView

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
    String key;
    List<CommandBean> commandBeans = new ArrayList<CommandBean>();

    PortletPreferences preference = request.getPreferences();

    Map<String, String[]> preferenceMap = preference.getMap();
    for (Map.Entry<String, String[]> entry : preferenceMap.entrySet()) {
        key = entry.getKey().trim();
        if (!key.isEmpty() && !key.equalsIgnoreCase(SpeechConstants.KEY_PHRASE)) {
            commandBeans.add(new CommandBeanImpl(entry.getKey(), entry.getValue()[0]));
        }
    }
    request.setAttribute(SpeechConstants.VOICE_COMMAND_COUNT, commandBeans.size());
    request.setAttribute(SpeechConstants.VOICE_COMMAND_LIST, commandBeans);
    SessionMessages.clear(request);
    super.doView(request, response);
}
 
開發者ID:rivetlogic,項目名稱:liferay-voice-command,代碼行數:20,代碼來源:SpeechPortlet.java

示例5: deleteVoiceCommand

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
public static PortletPreferences deleteVoiceCommand(ActionRequest request, String voiceCommand) 
        throws PortalException, SystemException, ReadOnlyException, ValidatorException, IOException {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    long plid = themeDisplay.getLayout().getPlid();
    long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT;
    int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT;
    long companyId = themeDisplay.getCompanyId();

    PortletPreferences preference = request.getPreferences();
    Map<String, String[]> preferencesMap = new HashMap<String, String[]>(preference.getMap());
    preferencesMap.remove(voiceCommand);

    PortletPreferencesLocalServiceUtil.deletePortletPreferences(ownerId, ownerType, plid, SpeechConstants.PORTLET_NAMESPACE);

    preference = PortletPreferencesLocalServiceUtil.getPreferences(companyId, ownerId, ownerType, plid,
            SpeechConstants.PORTLET_NAMESPACE);
    
    for (Map.Entry<String, String[]> entry : preferencesMap.entrySet()) {
        preference.setValue(entry.getKey(), entry.getValue()[0]);
    }
    preference.store();
    return preference;
}
 
開發者ID:rivetlogic,項目名稱:liferay-voice-command,代碼行數:24,代碼來源:SpeechUtil.java

示例6: checkPreferenceValueNotModified

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
/**
 * Check (xci) SPEC 91, PLT 14.1: Preferences values are not modified
 * if the values in the Map are altered.
 */
protected TestResult checkPreferenceValueNotModified(PortletRequest request) {
	TestResult result = new TestResult();
	result.setDescription("Preferences values are not modified if "
			+ "the values in the returned preference Map are altered.");
	result.setSpecPLT("14.1");

	PortletPreferences preferences = request.getPreferences();
    if (LOG.isDebugEnabled()) {
    	LOG.debug("Original Preferences:");
    	logPreferences(preferences);
    }

    // Modify the returned preference map.
	Map<String, String[]> prefMap = preferences.getMap();
	String[] values = (String[]) prefMap.get(PREF_NAME);
	String originalValue = null;
	String modifiedValue = "Value modified in preferences map.";
	if (values != null && values.length == 1) {
		originalValue = values[0];
		values[0] = modifiedValue;
	}

	// Check if the value held by portlet preferences is modified.
    if (LOG.isDebugEnabled()) {
    	LOG.debug("Modified Preferences:");
    	logPreferences(preferences);
    }
	String newValue = preferences.getValue(PREF_NAME, DEF_VALUE);
	if (newValue != null && newValue.equals(originalValue)) {
		result.setReturnCode(TestResult.PASSED);
	} else {
		result.setReturnCode(TestResult.FAILED);
		result.setResultMessage("Preference value modified according to "
				+ "the preference map.");
	}
	return result;
}
 
開發者ID:apache,項目名稱:portals-pluto,代碼行數:42,代碼來源:PreferenceCommonTest.java

示例7: doStartTag

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
/**
 * Processes the <CODE>defineObjects</CODE> tag.
 * @return <CODE>SKIP_BODY</CODE>
 */
public int doStartTag() throws JspException {
	
	ServletRequest servletRequest = pageContext.getRequest();
	
	PortletRequest portletRequest = 
		(PortletRequest) servletRequest.getAttribute(Constants.PORTLET_REQUEST);
	
	PortletResponse portletResponse = 
		(PortletResponse) servletRequest.getAttribute(Constants.PORTLET_RESPONSE);
	
	PortletConfig portletConfig = 
		(PortletConfig) servletRequest.getAttribute(Constants.PORTLET_CONFIG);
	
	PortletSession portletSession = portletRequest.getPortletSession(false);
	
	Map<String, Object> portletSessionScope = null;
	if(portletSession != null){
		portletSessionScope = (Map<String, Object>)portletSession.getAttributeMap();// getMap();
	}
	else{
		portletSessionScope = new HashMap<String, Object>();
	}
	
	PortletPreferences portletPreferences = portletRequest.getPreferences();
	
	Map<String, String[]> portletPreferencesValues = null;
	if(portletPreferences != null){
		portletPreferencesValues = portletPreferences.getMap();
	}
	else{
		portletPreferencesValues = new HashMap<String, String[]>();
	}
	
	// set attributes render and request
	setPortletRequestResponseAttribute(portletRequest, portletResponse);
	
	// set attribute portletConfig
	setAttribute(portletConfig, "portletConfig");
	
	// set attribute portletSession
	setAttribute(portletSession, "portletSession");
	
	//set attribute portletSession
	setAttribute(portletSessionScope, "portletSessionScope");
	
	// set attribute portletPreferences
	setAttribute(portletPreferences, "portletPreferences");
	
	// set attribute portletPreferences
	setAttribute(portletPreferencesValues, "portletPreferencesValues");    	
	
    return SKIP_BODY;
}
 
開發者ID:apache,項目名稱:portals-pluto,代碼行數:58,代碼來源:DefineObjectsTag286.java


注:本文中的javax.portlet.PortletPreferences.getMap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。