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


Java PortletPreferences.setValues方法代碼示例

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


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

示例1: checkSetPreferencesReturnsFirst

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
protected TestResult checkSetPreferencesReturnsFirst(PortletRequest request) {
    TestResult result = new TestResult();
    result.setDescription("Ensure the first value set to a given "
    		+ "preference is returned first by PortletPreferences.getValue().");
    result.setSpecPLT("14.1");

    PortletPreferences preferences = request.getPreferences();
    try {
        preferences.setValues("TEST", new String[] { "FIRST", "SECOND" });
    } catch (ReadOnlyException ex) {
    	TestUtils.failOnException("Unable to set preference values.", ex, result);
    	return result;
    }

    String value = preferences.getValue("TEST", DEF_VALUE);
    if (value != null && value.equals("FIRST")) {
    	result.setReturnCode(TestResult.PASSED);
    } else {
    	TestUtils.failOnAssertion("preference value", value, "FIRST", result);
    }
    return result;
}
 
開發者ID:apache,項目名稱:portals-pluto,代碼行數:23,代碼來源:PreferenceCommonTest.java

示例2: storeMyBooks

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
private void storeMyBooks(PortletPreferences prefs, SortedSet<Book> myBooks) {
	ArrayList<String> keys = new ArrayList<String>();
	for (Iterator<Book> i = myBooks.iterator(); i.hasNext();) {
		Book book = i.next();
		keys.add(book.getKey().toString());
	}
	String[] keysArr = keys.toArray(new String[] {});
	try {
		prefs.setValues("myBooks", keysArr);
		prefs.store();
	} catch (Exception e) {
		logger.warn("unable to set portlet preference", e);
	}
}
 
開發者ID:sdeleuze,項目名稱:spring-portlet-sample,代碼行數:15,代碼來源:MyBooksController.java

示例3: checkSetPreferenceMultiValues

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
protected TestResult checkSetPreferenceMultiValues(PortletRequest request) {
    TestResult result = new TestResult();
    result.setDescription("Ensure multiple preference values can be set.");
    result.setSpecPLT("14.1");

    PortletPreferences preferences = request.getPreferences();
    try {
        preferences.setValues("TEST", new String[] {"ONE", "ANOTHER"});
    } catch (ReadOnlyException ex) {
    	TestUtils.failOnException("Unable to set preference values.", ex, result);
    	return result;
    }

    String[] values = preferences.getValues("TEST", new String[] { DEF_VALUE });
    if (values != null && values.length == 2
    		&& values[0].equals("ONE") && values[1].equals("ANOTHER")) {
    	result.setReturnCode(TestResult.PASSED);
    } else if (values == null) {
    	TestUtils.failOnAssertion("preference values",
    	                          values,
    	                          new String[] { "ONE", "ANOTHER" },
    	                          result);
    } else if (values.length != 2) {
    	TestUtils.failOnAssertion("length of preference values",
    	                          String.valueOf(values.length),
    	                          String.valueOf(2),
    	                          result);
    } else {
    	TestUtils.failOnAssertion("preference values",
    	                          values,
    	                          new String[] { "ONE", "ANOTHER" },
    	                          result);
    }
    return result;
}
 
開發者ID:apache,項目名稱:portals-pluto,代碼行數:36,代碼來源:PreferenceCommonTest.java

示例4: updateExcludedSites

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
/**
 * Updates excluded sites property
 *
 * @param preferences PortletPreferences
 * @param properties  Properties
 * @throws Exception
 */
private void updateExcludedSites(PortletPreferences preferences, Properties properties) throws Exception {

    // Set the value in portlet preferences
    preferences.setValues(
            PortletPropertiesKeys.EXCLUDED_SITES,
            properties.getExcludedSites()
    );

    // Persist
    preferences.store();

    // Save in Environment
    setupExcludedSites(preferences);
}
 
開發者ID:marcelmika,項目名稱:lims,代碼行數:22,代碼來源:PropertiesManagerImpl.java

示例5: updateBuddyListSocialRelations

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
/**
 * Updates buddy list social relations preferences
 *
 * @param preferences PortletPreferences
 * @param properties  Properties
 * @throws Exception
 */
private void updateBuddyListSocialRelations(PortletPreferences preferences, Properties properties) throws Exception {

    // Social relations needs to be mapped to the string alternatives so they can
    // be moved to the preferences
    Environment.BuddyListSocialRelation[] relations = properties.getBuddyListSocialRelations();
    String[] relationStrings = new String[relations.length];

    for (int i = 0; i < relationStrings.length; i++) {
        relationStrings[i] = String.valueOf(relations[i].getCode());
    }

    // Reset previous preferences
    preferences.reset(PortletPropertiesKeys.BUDDY_LIST_ALLOWED_SOCIAL_RELATION_TYPES);

    // Set the value in portlet preferences
    preferences.setValues(
            PortletPropertiesKeys.BUDDY_LIST_ALLOWED_SOCIAL_RELATION_TYPES,
            relationStrings
    );

    // Persist
    preferences.store();

    // Save in environment
    setupBuddyListSocialRelations(preferences);
}
 
開發者ID:marcelmika,項目名稱:lims,代碼行數:34,代碼來源:PropertiesManagerImpl.java

示例6: updateBuddyListSiteExcludes

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
/**
 * Updates buddy list site excludes property
 *
 * @param preferences PortletPreferences
 * @param properties  Properties
 * @throws Exception
 */
private void updateBuddyListSiteExcludes(PortletPreferences preferences, Properties properties) throws Exception {

    // Set the value in portlet preferences
    preferences.setValues(
            PortletPropertiesKeys.BUDDY_LIST_SITE_EXCLUDES,
            properties.getBuddyListSiteExcludes()
    );

    // Persist
    preferences.store();

    // Save in Environment
    setupBuddyListSiteExcludes(preferences);
}
 
開發者ID:marcelmika,項目名稱:lims,代碼行數:22,代碼來源:PropertiesManagerImpl.java

示例7: updateBuddyListGroupExcludes

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
/**
 * Updates buddy list group excludes property
 *
 * @param preferences PortletPreferences
 * @param properties  Properties
 * @throws Exception
 */
private void updateBuddyListGroupExcludes(PortletPreferences preferences, Properties properties) throws Exception {

    // Set the value in portlet preferences
    preferences.setValues(
            PortletPropertiesKeys.BUDDY_LIST_GROUP_EXCLUDES,
            properties.getBuddyListGroupExcludes()
    );

    // Persist
    preferences.store();

    // Save in Environment
    setupBuddyListGroupExcludes(preferences);
}
 
開發者ID:marcelmika,項目名稱:lims,代碼行數:22,代碼來源:PropertiesManagerImpl.java

示例8: deleteConfigurationTab

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
@Override
public void deleteConfigurationTab(String tabId, PortletPreferences preferences) throws ReadOnlyException, ValidatorException, IOException {
    // First, delete any reference to this tab
    List<String> tabIds = Arrays.asList(preferences.getValues(CONF_KEY_TABS, EMPTY_ARRAY))
        .stream()
        .filter(tab -> !tab.equals(tabId))
        .collect(Collectors.toList());
    preferences.setValues(CONF_KEY_TABS, tabIds.toArray(new String[tabIds.size()]));

    // Then, flush out any singular value
    String assetTypeKey = format(CONF_KEY_FORMAT_ASSET_TYPE, tabId);
    String journalArticleViewTemplateKey = format(CONF_KEY_FORMAT_JOURNAL_ARTICLE_VIEW_TEMPLATE, tabId);
    String orderKey = format(CONF_KEY_FORMAT_ORDER, tabId);
    String pageSizeKey = format(CONF_KEY_FORMAT_PAGE_SIZE, tabId);
    String fullPageSizeKey = format(CONF_KEY_FORMAT_FULL_PAGE_SIZE, tabId);
    String loadMoreSizeKey = format(CONF_KEY_FORMAT_LOAD_MORE_PAGE_SIZE, tabId);
    String sortByKey = format(CONF_KEY_FORMAT_SORT_BY, tabId);
    String sortReverseKey = format(CONF_KEY_FORMAT_SORT_REVERSE, tabId);

    preferences.reset(orderKey);
    preferences.reset(assetTypeKey);
    preferences.reset(journalArticleViewTemplateKey);
    preferences.reset(pageSizeKey);
    preferences.reset(fullPageSizeKey);
    preferences.reset(loadMoreSizeKey);
    preferences.reset(sortByKey);
    preferences.reset(sortReverseKey);

    // Finally, flush out composed values
    Enumeration<String> prefKeys = preferences.getNames();
    Pattern journalArticleTemplatesKeyPattern = Pattern.compile(format(CONF_KEY_PATTERN_FORMAT_JOURNAL_ARTICLE_TEMPLATES, tabId));
    Pattern dlFileEntryTemplatesKeyPattern = Pattern.compile(format(CONF_KEY_PATTERN_FORMAT_DL_FILE_ENTRY_TYPE_TEMPLATES, tabId));
    Pattern titleKeyPattern = Pattern.compile(format(CONF_KEY_PATTERN_FORMAT_TITLE, tabId));
    Pattern searchFacetPattern = Pattern.compile(format(CONF_KEY_PATTERN_FORMAT_SEARCH_FACET, tabId));

    while(prefKeys.hasMoreElements()) {
        String key = prefKeys.nextElement();
        boolean journalArticleTemplatesMatches = journalArticleTemplatesKeyPattern.matcher(key).matches();
        boolean dlFileEntryTemplatesMatches = dlFileEntryTemplatesKeyPattern.matcher(key).matches();
        boolean titleMatches = titleKeyPattern.matcher(key).matches();
        boolean searchFacetMatches = searchFacetPattern.matcher(key).matches();

        if(journalArticleTemplatesMatches || dlFileEntryTemplatesMatches || titleMatches || searchFacetMatches) {
            preferences.reset(key);
        }
    }

    preferences.store();
}
 
開發者ID:savoirfairelinux,項目名稱:flashlight-search,代碼行數:50,代碼來源:ConfigurationStorageV1.java


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