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


Java PortletConfig.getResourceBundle方法代码示例

本文整理汇总了Java中javax.portlet.PortletConfig.getResourceBundle方法的典型用法代码示例。如果您正苦于以下问题:Java PortletConfig.getResourceBundle方法的具体用法?Java PortletConfig.getResourceBundle怎么用?Java PortletConfig.getResourceBundle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.portlet.PortletConfig的用法示例。


在下文中一共展示了PortletConfig.getResourceBundle方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRegistrationStates

import javax.portlet.PortletConfig; //导入方法依赖的package包/类
private List<JSONObject> getRegistrationStates(ThemeDisplay themeDisplay) {

		JSONObject regObject = JSONFactoryUtil.createJSONObject();
		List<JSONObject> registrationState = new ArrayList<>();
		
		PortletConfig portletConfig = PortletConfigFactoryUtil.get(
				themeDisplay.getPortletDisplay().getId());
		ResourceBundle resourceBundle =
				portletConfig.getResourceBundle(themeDisplay.getLocale());

		for (int i=0; i<4; i++) {
			regObject = JSONFactoryUtil.createJSONObject();
			regObject.put("value", i);
			regObject.put("text", LanguageUtil.get(resourceBundle, "registration-state"+i));
			registrationState.add(regObject);
		}

		return registrationState;
	}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:20,代码来源:FrontendWebRegisterPortlet.java

示例2: getCustomModeDecorationName

import javax.portlet.PortletConfig; //导入方法依赖的package包/类
/**
   * Obtains decoration name for a portlet managed mode from the portlet's resource bundle
   * as defined in PLT.8.4 of the JSR-286 spec using the key 
   * javax.portlet.app.custom-portlet-mode.<custom mode>.decoration-name where
   * custom mode is the name of the custom mode as defined in portlet.xml
   * (//portlet-app/custom-portlet-mode/portlet-mode element). If the decoration
   * name is not found in the resource bundle, this method returns the uppercased
   * mode name.
   * 
   * @param driverConfig the driver config object found in the session.
   * @param mode the portlet managed custom mode that will be searched for decoration name
   * in the resource bundle.
   * @return the decoration name for a portlet managed mode in the resource bundle
   * using the key javax.portlet.app.custom-portlet-mode.<custom mode>.decoration-name 
   * where custom mode is the name of the custom mode as defined in portlet.xml
   * (//portlet-app/custom-portlet-mode/portlet-mode element). If the decoration
   * name is not found in the resource bundle, the uppercased
   * mode name is returned.
   */
  private String getCustomModeDecorationName(DriverConfiguration driverConfig, 
  		PortletMode mode) {
  	//decoration name is mode name by default
String decorationName = mode.toString().toUpperCase();
ResourceBundle bundle;
StringBuffer res;
try {
	PortletConfig config = driverConfig.getPortletConfig(evaluatedPortletId);
	ServletRequest request = pageContext.getRequest();
	Locale defaultLocale = request.getLocale();
	bundle = config.getResourceBundle(defaultLocale);
	res = new StringBuffer();
	res.append("javax.portlet.app.custom-portlet-mode.");
	res.append(mode.toString());
	res.append(".decoration-name");
	decorationName = bundle.getString(res.toString());
} catch (Exception e) {
	LOG.debug("Problem finding decoration-name for custom mode: " + mode.toString());
}
return decorationName;
  }
 
开发者ID:apache,项目名称:portals-pluto,代码行数:41,代码来源:PortletModeDropDownTag.java

示例3: checkResourceBundleExists

import javax.portlet.PortletConfig; //导入方法依赖的package包/类
protected TestResult checkResourceBundleExists(PortletConfig config,
                                               PortletRequest request) {
    TestResult result = new TestResult();
    result.setDescription("Ensure the resource bundle is not null.");

    ResourceBundle bundle = config.getResourceBundle(request.getLocale());
    if (bundle != null) {
    	result.setReturnCode(TestResult.PASSED);
    } else {
    	result.setReturnCode(TestResult.FAILED);
        result.setResultMessage("Unable to retrieve resource bundle "
        		+ "for locale: " + request.getLocale());
    }
    return result;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:16,代码来源:ResourceBundleTest.java

示例4: checkGetNames

import javax.portlet.PortletConfig; //导入方法依赖的package包/类
protected TestResult checkGetNames(PortletConfig config,
                                   PortletRequest request) {
    TestResult result = new TestResult();
    result.setDescription("Retrieve the property names and ensure that "
    		+ "the required keys are present.");

    List<String> requiredKeys = new ArrayList<String>();
    requiredKeys.add(TITLE_KEY);
    requiredKeys.add(SHORT_TITLE_KEY);
    requiredKeys.add(KEYWORDS_KEY);

    ResourceBundle bundle = config.getResourceBundle(request.getLocale());
    if (bundle == null) {
    	result.setReturnCode(TestResult.WARNING);
    	result.setResultMessage("A function upon which this test depends "
    			+ "failed to execute as expected. "
    			+ "Check the other test results in this test suite.");
    	return result;
    }

    for (Enumeration<String> en = bundle.getKeys(); 
    			en.hasMoreElements(); ) {
        String key = (String) en.nextElement();
        requiredKeys.remove(key);
    }

    if (requiredKeys.isEmpty()) {
    	result.setReturnCode(TestResult.PASSED);
    } else {
    	result.setReturnCode(TestResult.FAILED);
        StringBuffer buffer = new StringBuffer();
        for (Iterator<String> it = requiredKeys.iterator(); it.hasNext(); ) {
        	buffer.append(it.next()).append(", ");
        }
        result.setResultMessage("Required keys [" + buffer.toString()
        		+ "] are missing in the resource bundle.");
    }
    return result;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:40,代码来源:ResourceBundleTest.java

示例5: generateNotiIntervals

import javax.portlet.PortletConfig; //导入方法依赖的package包/类
private List<JSONObject> generateNotiIntervals(RenderRequest renderRequest) {
	
	ThemeDisplay themeDisplay =
		(ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
	PortletConfig portletConfig = PortletConfigFactoryUtil.get(
		themeDisplay.getPortletDisplay().getId());

	ResourceBundle resourceBundle =
		portletConfig.getResourceBundle(themeDisplay.getLocale());
	
	List<JSONObject> intervals = new ArrayList<JSONObject>();
	JSONObject interval1 = JSONFactoryUtil.createJSONObject();
	interval1.put("value", "minutely");
	interval1.put("text", LanguageUtil.get(resourceBundle, "minutely"));
	intervals.add(interval1);

	JSONObject interval2 = JSONFactoryUtil.createJSONObject();
	interval2.put("value", "5-mins");
	interval2.put("text", LanguageUtil.get(resourceBundle, "5-mins"));
	intervals.add(interval2);

	JSONObject interval3 = JSONFactoryUtil.createJSONObject();
	interval3.put("value", "15-mins");
	interval3.put("text", LanguageUtil.get(resourceBundle, "15-mins"));
	intervals.add(interval3);

	JSONObject interval4 = JSONFactoryUtil.createJSONObject();
	interval4.put("value", "30-mins");
	interval4.put("text", LanguageUtil.get(resourceBundle, "30-mins"));
	intervals.add(interval4);

	JSONObject interval5 = JSONFactoryUtil.createJSONObject();
	interval5.put("value", "hourly");
	interval5.put("text", LanguageUtil.get(resourceBundle, "hourly"));
	intervals.add(interval5);

	JSONObject interval6 = JSONFactoryUtil.createJSONObject();
	interval6.put("value", "daily");
	interval6.put("text", LanguageUtil.get(resourceBundle, "daily"));
	intervals.add(interval6);
	
	return intervals;
	
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:45,代码来源:AdminPortlet.java

示例6: doGenericLocaleRequiredFields

import javax.portlet.PortletConfig; //导入方法依赖的package包/类
private TestResult doGenericLocaleRequiredFields(PortletConfig config,
                                                 PortletRequest request,
                                                 Locale locale) {
    TestResult result = new TestResult();
    result.setDescription("Retrieve the title and ensure it's set properly "
    		+ "under locale " + locale);

    // Retrieve title, short title and keywords from portlet resource bundle.
    ResourceBundle bundle = config.getResourceBundle(locale);
    if (bundle == null) {
    	result.setReturnCode(TestResult.WARNING);
    	result.setResultMessage("A function upon which this test depends "
    			+ "failed to execute as expected. "
    			+ "Check the other test results in this test suite.");
    	return result;
    }
    String title = bundle.getString(TITLE_KEY);
    String shortTitle = bundle.getString(SHORT_TITLE_KEY);
    String keywords = bundle.getString(KEYWORDS_KEY);

    // Retrieve expected title, short title and keywords from test config.
    String suffix = isBundleDeclared() ? ("_" + locale.getLanguage()) : "";
    Map<String, String> initParams = getInitParameters();
    String expectedTitle = (String) initParams.get(
    		TITLE_PARAM + suffix);
    String expectedShortTitle = (String) initParams.get(
    		SHORT_TITLE_PARAM + suffix);
    String expectedKeywords = (String) initParams.get(
    		KEYWORDS_PARAM + suffix);

    // Assert that values retrieved from resource bundler are expected.
    boolean inconsistent = false;
    StringBuffer buffer = new StringBuffer();
    buffer.append("The following information is not correct: ");
    if (title == null || expectedTitle == null
    		|| !title.trim().equals(expectedTitle.trim())) {
    	inconsistent = true;
        buffer.append("Inconsistent title: '")
        		.append(title).append("' != '")
        		.append(expectedTitle).append("'; ");
    }
    if (shortTitle == null || expectedShortTitle == null
    		|| !shortTitle.trim().equals(expectedShortTitle.trim())) {
    	inconsistent = true;
        buffer.append("Inconsistent short title: '")
        		.append(shortTitle).append("' != '")
        		.append(expectedShortTitle).append("'; ");
    }
    if (keywords == null || expectedKeywords == null
    		|| !keywords.trim().equals(expectedKeywords.trim())) {
    	inconsistent = true;
        buffer.append("Inconsistent keywords: '")
        		.append(keywords).append("' != '")
        		.append(expectedKeywords).append("'; ");
    }

    if (!inconsistent) {
    	result.setReturnCode(TestResult.PASSED);
    } else {
    	result.setReturnCode(TestResult.FAILED);
        result.setResultMessage(buffer.toString());
    }
    return result;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:65,代码来源:ResourceBundleTest.java

示例7: doStartTag

import javax.portlet.PortletConfig; //导入方法依赖的package包/类
/**
 * Method invoked when the start tag is encountered. This method retrieves the portlet title and print it to the
 * page.
 * 
 * @see org.apache.pluto.container.services.PortalCallbackService#setTitle(HttpServletRequest, PortletWindow, String)
 * @see org.apache.pluto.driver.services.container.PortalCallbackServiceImpl#setTitle(HttpServletRequest,
 *      PortletWindow, String)
 * 
 * @throws JspException
 */
@SuppressWarnings("unchecked")
public int doStartTag() throws JspException {

   // Ensure that the portlet title tag resides within a portlet tag.
   PortletTag parentTag = (PortletTag) TagSupport.findAncestorWithClass(this, PortletTag.class);
   if (parentTag == null) {
      throw new JspException("Portlet title tag may only reside " + "within a pluto:portlet tag.");
   }

   // Print out the portlet title to page.
   try {

      Map<String, String> titles = (Map<String, String>) pageContext.getRequest().getAttribute(AttributeKeys.PORTLET_TITLE);

      String portletId = parentTag.getEvaluatedPortletId();

      String title = null;
      if (titles != null) {
         title = titles.get(portletId);
      }

      if (title == null) {

         PortletWindowConfig windowConfig = PortletWindowConfig.fromId(portletId);

         try {
            ServletContext servletContext = pageContext.getServletContext();
            DriverConfiguration driverConfig = (DriverConfiguration) servletContext.getAttribute(AttributeKeys.DRIVER_CONFIG);
            PortletConfig config = driverConfig.getPortletConfig(portletId);
            ServletRequest request = pageContext.getRequest();
            Locale defaultLocale = request.getLocale();
            ResourceBundle bundle = config.getResourceBundle(defaultLocale);
            title = bundle.getString("javax.portlet.title");
         } catch (Throwable th) {
            if (LOG.isDebugEnabled()) {
               StringBuilder txt = new StringBuilder(128);
               txt.append("Could not obtain title for: " + windowConfig.getPortletName() + "\n");
               StringWriter sw = new StringWriter();
               PrintWriter pw = new PrintWriter(sw);
               th.printStackTrace(pw);
               pw.flush();
               txt.append(sw.toString());
               LOG.warn(txt.toString());
            }
         }

         if (title == null) {
            title = "[ " + windowConfig.getPortletName() + " ]";
         }
      }

      pageContext.getOut().print(title);
   } catch (IOException ex) {
      throw new JspException(ex);
   }
   return SKIP_BODY;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:68,代码来源:PortletTitleTag.java


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