Author: nbelaevski
Date: 2008-06-19 15:29:51 -0400 (Thu, 19 Jun 2008)
New Revision: 9122
Removed:
trunk/sandbox/api/src/main/java/org/richfaces/messages/SandboxMessageUtil.java
Log:
Excess class removed from sandbox API
Deleted: trunk/sandbox/api/src/main/java/org/richfaces/messages/SandboxMessageUtil.java
===================================================================
---
trunk/sandbox/api/src/main/java/org/richfaces/messages/SandboxMessageUtil.java 2008-06-19
19:21:31 UTC (rev 9121)
+++
trunk/sandbox/api/src/main/java/org/richfaces/messages/SandboxMessageUtil.java 2008-06-19
19:29:51 UTC (rev 9122)
@@ -1,119 +0,0 @@
-/**
- *
- */
-package org.richfaces.messages;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import javax.faces.application.Application;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-
-/**
- * @author pawelgo
- *
- */
-public class SandboxMessageUtil {
-
- public static final String MESSAGES = "org.richfaces.sandbox.Messages";
-
- private static final ResourceBundle getResourceBundle(String baseName, Locale locale,
ClassLoader loader) {
- if (loader != null) {
- return ResourceBundle.getBundle(baseName, locale, loader);
- } else {
- return ResourceBundle.getBundle(baseName, locale);
- }
- }
-
- private static final FacesMessage getMessage(FacesContext context, String messageId,
- Object[] parameters, Locale locale) {
- String summary = null;
- String detail = null;
-
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
- if (context != null) {
- Application application = context.getApplication();
- if (application != null) {
- String messageBundleName = application.getMessageBundle();
-
- if (messageBundleName != null) {
- ResourceBundle bundle = getResourceBundle(messageBundleName, locale, loader);
- if (bundle != null) {
- try {
- summary = bundle.getString(messageId);
- detail = bundle.getString(messageId + "_detail");
- } catch (MissingResourceException e) {
- //do nothing
- }
- }
- }
- }
- }
-
- if (summary == null) {
- ResourceBundle bundle = getResourceBundle(MESSAGES, locale, loader);
- if (bundle != null) {
- try {
- summary = bundle.getString(messageId);
- detail = bundle.getString(messageId + "_detail");
- } catch (MissingResourceException e) {
- //do nothing
- }
- }
- }
-
- if (summary == null) {
- ResourceBundle bundle = getResourceBundle(FacesMessage.FACES_MESSAGES, locale,
loader);
- try {
- summary = bundle.getString(messageId);
-
- if (summary == null) {
- return null;
- }
-
- detail = bundle.getString(messageId + "_detail");
- } catch (MissingResourceException e) {
- //do nothing
- }
- }
-
- String formattedSummary = MessageFormat.format(summary, parameters);
- String formattedDetail = null;
- if (detail != null) {
- formattedDetail = MessageFormat.format(detail, parameters);
- }
-
- return new FacesMessage(formattedSummary, formattedDetail);
- }
-
- public static final FacesMessage getMessage(FacesContext context, String messageId,
- Object[] parameters) {
-
- Locale locale;
- FacesMessage result = null;
-
- if (context != null) {
- UIViewRoot viewRoot = context.getViewRoot();
- if (viewRoot != null) {
- locale = viewRoot.getLocale();
-
- if (locale != null) {
- result = getMessage(context, messageId, parameters, locale);
- }
- }
- }
-
- if (result == null) {
- locale = Locale.getDefault();
- result = getMessage(context, messageId, parameters, locale);
- }
-
- return result;
- }
-
-}
Show replies by date