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


Java PortletPreferences.getValue方法代碼示例

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


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

示例1: readConfiguration

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
@Override
public FlashlightSearchConfiguration readConfiguration(PortletPreferences preferences) {
    // Get the ADT UUID
    String adtUUID = preferences.getValue(CONF_KEY_ADT_UUID, StringPool.BLANK);

    // Perform a search on startup?
    boolean doSearchOnStartup = preferences.getValue(CONF_KEY_DO_SEARCH_ON_STARTUP, StringPool.FALSE).equals(StringPool.TRUE);
    String doSearchOnStartupKeywords = preferences.getValue(CONF_KEY_DO_SEARCH_ON_STARTUP_KEYWORDS, FlashlightSearchService.CONFIGURATION_DEFAULT_SEARCH_KEYWORDS);

    // Get the tabs
    String[] tabIds = preferences.getValues(CONF_KEY_TABS, EMPTY_ARRAY);
    int tabIdsLength = tabIds.length;
    ArrayList<FlashlightSearchConfigurationTab> tabs = new ArrayList<>(tabIdsLength);

    // For each tabs, get its configuration
    for(int i = 0; i < tabIdsLength; i++) {
        tabs.add(this.readTabConfiguration(preferences, tabIds[i]));
    }

    return new FlashlightSearchConfiguration(adtUUID, doSearchOnStartup, doSearchOnStartupKeywords, tabs);
}
 
開發者ID:savoirfairelinux,項目名稱:flashlight-search,代碼行數:22,代碼來源:ConfigurationStorageV1.java

示例2: load

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
@Override
public DDMStructure load(final PortletPreferences preferences, final String key, final String defaultValue) {
	final String uuid = preferences.getValue(key, "");
	if (StringUtils.isEmpty(uuid)) {
		return null;
	}
	final long groupId = ServiceContextThreadLocal.getServiceContext().getScopeGroupId();
	try {
		return DDMStructureLocalServiceUtil.fetchDDMStructureByUuidAndGroupId(uuid, groupId);
	} catch (final SystemException e) {
		log.error("Could not load structure {} from group {}", new Object[] { uuid, groupId, e });
		return null;
	}
}
 
開發者ID:liefke,項目名稱:org.portletbeans,代碼行數:15,代碼來源:DdmStructurePreferenceHandler.java

示例3: load

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
@Override
public E load(final PortletPreferences preferences, final String key, final String defaultValue) {
	if (preferences.getValue(key, "") == null) {
		return null;
	}
	try {
		final E value = this.type.newInstance();
		PreferenceFieldRegistry.load(preferences, key + '.', value);
		for (final Method postConstruct : this.postConstructMethods) {
			postConstruct.setAccessible(true);
			postConstruct.invoke(value);
		}
		return value;
	} catch (final InstantiationException | IllegalAccessException | IllegalArgumentException
			| InvocationTargetException e) {
		throw new IllegalArgumentException("Can't instantiate " + this.type, e);
	}
}
 
開發者ID:liefke,項目名稱:org.portletbeans,代碼行數:19,代碼來源:PreferenceEntityHandler.java

示例4: load

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
@Override
public Date load(final PortletPreferences preferences, final String key, final String defaultValue) {
	final String value = preferences.getValue(key, defaultValue);
	if (value == null) {
		return null;
	}
	try {
		return parseValue(value);
	} catch (final ParseException e) {
		log.error("Could not parse date object " + key + " from preferences: " + value, e);
		if (!value.equals(defaultValue)) {
			// Try to return the default value
			try {
				return parseValue(defaultValue);
			} catch (final ParseException e2) {
				// Ignore - we already logged an exception
			}
		}
		return null;
	}
}
 
開發者ID:liefke,項目名稱:org.portletbeans,代碼行數:22,代碼來源:DateFieldHandler.java

示例5: doCheckDefaultPreference

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
/**
 * Private method that checks if a preference is not defined or has no
 * value in <code>portlet.xml</code>, the default values are returned.
 * @param request  the portlet request.
 * @param preferenceName  the preference name which is not defined or has no
 *        value in <code>portlet.xml</code>.
 * @return the test result.
 */
private TestResult doCheckDefaultPreference(PortletRequest request,
                                            String preferenceName) {
	TestResult result = new TestResult();
	result.setDescription("Ensure proper default is returned when "
			+ "a non-existing/value-undefined preference is requested.");
	result.setSpecPLT("14.1");

	PortletPreferences preferences = request.getPreferences();
	String value =  preferences.getValue(preferenceName, DEF_VALUE);
	String[] values = preferences.getValues(preferenceName,
	                                        new String[] { DEF_VALUE });
	if (DEF_VALUE.equals(value)
			&& values != null && values.length == 1
			&& DEF_VALUE.equals(values[0])) {
		result.setReturnCode(TestResult.PASSED);
	} else if (!DEF_VALUE.equals(value)) {
		TestUtils.failOnAssertion("preference value", value, DEF_VALUE, result);
	} else {
		TestUtils.failOnAssertion("preference values",
		                          values,
		                          new String[] { DEF_VALUE },
		                          result);
	}
	return result;
}
 
開發者ID:apache,項目名稱:portals-pluto,代碼行數:34,代碼來源:PreferenceCommonTest.java

示例6: checkSetPreferenceSingleValue

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

    PortletPreferences preferences = request.getPreferences();
    try {
        preferences.setValue("TEST", "TEST_VALUE");
    } catch (ReadOnlyException ex) {
    	TestUtils.failOnException("Unable to set preference value.", ex, result);
        return result;
    }

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

示例7: checkSetPreferenceNull

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

    PortletPreferences preferences = request.getPreferences();
    try {
        preferences.setValue("TEST", null);
    } catch (ReadOnlyException ex) {
    	TestUtils.failOnException("Unable to set preference value.", ex, result);
        return result;
    }

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

示例8: 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

示例9: initBinder

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
/**
 * Registers a PropertyEditor with the data binder for handling Dates
 * using the format as currently specified in the PortletPreferences.
 */
@InitBinder
public void initBinder(PortletRequestDataBinder binder, PortletPreferences preferences) {
	String formatString = preferences.getValue("dateFormat", PetService.DEFAULT_DATE_FORMAT);
	SimpleDateFormat dateFormat = new SimpleDateFormat(formatString);
	binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
	binder.setAllowedFields(new String[] {"species", "breed", "name", "birthdate"});
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:12,代碼來源:PetsController.java

示例10: checkArticleOnLayout

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
public static boolean checkArticleOnLayout(Layout layout, String articleId, String columnId, long companyId) {
	boolean result = false;
	
	try {

		long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT;
		int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT;
		
		LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();

		List<Portlet> portlets = layoutTypePortlet.getAllPortlets(columnId);
		if (portlets != null) {
			for (Portlet portlet: portlets) {
				//m_objLog.debug("Found portlet "+portlet.getPortletId()+" =? "+PortletKeys.JOURNAL_CONTENT);
				if (portlet.getPortletId().startsWith(PortletKeys.JOURNAL_CONTENT+"_INSTANCE")) {
					PortletPreferences prefs = PortletPreferencesLocalServiceUtil.getPreferences(companyId,
			                ownerId,
			                ownerType,
			                layout.getPlid(),
			                portlet.getPortletId());
					String jArticleId = prefs.getValue("articleId", "");
					if (jArticleId.equals(articleId)) {
						result = true;
						break;
					}
				}
			}
		}
	} catch (Throwable t) {
		m_objLog.warn(t);
	}
	return result;
}
 
開發者ID:fraunhoferfokus,項目名稱:particity,代碼行數:34,代碼來源:ParticityInitializer.java

示例11: load

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
@Override
public DDMTemplate load(final PortletPreferences preferences, final String key, final String defaultValue) {
	final String uuid = preferences.getValue(key, "");
	if (StringUtils.isEmpty(uuid)) {
		return null;
	}
	final long groupId = ServiceContextThreadLocal.getServiceContext().getScopeGroupId();
	try {
		return DDMTemplateLocalServiceUtil.fetchDDMTemplateByUuidAndGroupId(uuid, groupId);
	} catch (final SystemException e) {
		log.error("Could not load template {} from group {}", new Object[] { uuid, groupId, e });
		return null;
	}
}
 
開發者ID:liefke,項目名稱:org.portletbeans,代碼行數:15,代碼來源:DdmTemplatePreferenceHandler.java

示例12: dateToJsp

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
private String dateToJsp(PortletRequest request, Date date) {
	PortletPreferences prefs = request.getPreferences();
	ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
			WebKeys.THEME_DISPLAY);
	SimpleDateFormat format = new SimpleDateFormat(prefs.getValue("module-date-format", "yyyy/MM/dd"));
	format.setTimeZone(themeDisplay.getTimeZone());
	return format.format(date);
}
 
開發者ID:TelefonicaED,項目名稱:liferaylms-portlet,代碼行數:9,代碼來源:modulePortlet.java

示例13: getCorrectProperty

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
public String getCorrectProperty(PortletRequest request, String propName, String defaultValue)
{
	Placement placement = ToolManager.getCurrentPlacement();
	String propertyName = placement.getToolId() + "." + propName;
	String propValue = ServerConfigurationService.getString(propertyName,null);
	if ( propValue != null && propValue.trim().length() > 0 ) {
		log.debug("Sakai.home {}={}", propName, propValue);
		return propValue;
	}

	Properties config = placement.getConfig();
	propValue = getSakaiProperty(config, "imsti."+propName);
	if ( propValue != null && "true".equals(config.getProperty("final."+propName)) )
	{
		log.debug("Frozen {} ={}", propName, propValue);
		return propValue;
	}

	PortletPreferences prefs = request.getPreferences();
	propValue = prefs.getValue("imsti."+propName, null);
	if ( propValue != null ) {
		log.debug("Portlet {} ={}", propName, propValue);
		return propValue;
	}

	propValue = getSakaiProperty(config, "imsti."+propName);
	if ( propValue != null ) {
		log.debug("Tool {} ={}", propName, propValue);
		return propValue;
	}

	if ( defaultValue != null ) {
		log.debug("Default {} ={}", propName, defaultValue);
		return defaultValue;
	}
	log.debug("Fell through {}", propName);
	return null;
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:39,代碼來源:IMSBLTIPortlet.java

示例14: load

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
@Override
public E load(final PortletPreferences preferences, final String key, final String defaultValue) {
	try {
		final String name = preferences.getValue(key, defaultValue);
		return StringUtils.isEmpty(name) ? null : Enum.valueOf(this.enumClass, name);
	} catch (final IllegalArgumentException e) {
		// A previous element does not exist anymore
		return StringUtils.isEmpty(defaultValue) ? null : Enum.valueOf(this.enumClass, defaultValue);
	}
}
 
開發者ID:liefke,項目名稱:org.portletbeans,代碼行數:11,代碼來源:EnumFieldHandler.java

示例15: load

import javax.portlet.PortletPreferences; //導入方法依賴的package包/類
@Override
public Serializable load(final PortletPreferences preferences, final String key, final String defaultValue) {
	final String value = preferences.getValue(key, defaultValue);
	if (StringUtils.isEmpty(value)) {
		return null;
	}
	try {
		return (Serializable) new ObjectInputStream(new ByteArrayInputStream(
				DatatypeConverter.parseBase64Binary(value))).readObject();
	} catch (final IOException | ClassNotFoundException e) {
		log.error("Could not deserialize object from preferences: " + value, e);
		return null;
	}
}
 
開發者ID:liefke,項目名稱:org.portletbeans,代碼行數:15,代碼來源:SerializableFieldHandler.java


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