You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/05/02 03:35:24 UTC

svn commit: r940139 - in /myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces: custom/fileupload/AbstractHtmlInputFileUpload.java validator/ValidatorBase.java

Author: lu4242
Date: Sun May  2 01:35:24 2010
New Revision: 940139

URL: http://svn.apache.org/viewvc?rev=940139&view=rev
Log:
MYFACES-2691 Enhance MessageUtils adding methods when custom library bundle should be scanned

Modified:
    myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/custom/fileupload/AbstractHtmlInputFileUpload.java
    myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/validator/ValidatorBase.java

Modified: myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/custom/fileupload/AbstractHtmlInputFileUpload.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/custom/fileupload/AbstractHtmlInputFileUpload.java?rev=940139&r1=940138&r2=940139&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/custom/fileupload/AbstractHtmlInputFileUpload.java (original)
+++ myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/custom/fileupload/AbstractHtmlInputFileUpload.java Sun May  2 01:35:24 2010
@@ -28,6 +28,7 @@ import org.apache.myfaces.component.Alig
 import org.apache.myfaces.component.UserRoleAware;
 import org.apache.myfaces.component.UserRoleUtils;
 import org.apache.myfaces.shared_tomahawk.util.MessageUtils;
+import org.apache.myfaces.tomahawk.util.Constants;
 
 /**
  * Creates a file-selection widget in the rendered page which allows a user to select
@@ -143,8 +144,8 @@ public abstract class AbstractHtmlInputF
                 {
                   Integer maxSize =
                     (Integer) context.getExternalContext().getRequestMap().get(FILEUPLOAD_MAX_SIZE);
-                  MessageUtils.addMessage(FacesMessage.SEVERITY_ERROR,
-                              SIZE_LIMIT_MESSAGE_ID, new Object[] { getLabel(context, this),
+                  MessageUtils.addMessage(Constants.TOMAHAWK_DEFAULT_BUNDLE, FacesMessage.SEVERITY_ERROR,
+                              SIZE_LIMIT_MESSAGE_ID, new Object[] { MessageUtils.getLabel(context, this),
                                       maxSize},
                               getClientId(context), context);
                   setValid(false);
@@ -155,8 +156,8 @@ public abstract class AbstractHtmlInputF
                         (Integer) context.getExternalContext().getRequestMap().get(FILEUPLOAD_MAX_SIZE);
                     if (maxSize != null)
                     {
-                        MessageUtils.addMessage(FacesMessage.SEVERITY_ERROR,
-                                SIZE_LIMIT_MESSAGE_ID, new Object[] { getLabel(context, this),
+                        MessageUtils.addMessage(Constants.TOMAHAWK_DEFAULT_BUNDLE, FacesMessage.SEVERITY_ERROR,
+                                SIZE_LIMIT_MESSAGE_ID, new Object[] { MessageUtils.getLabel(context, this),
                                         maxSize},
                                 getClientId(context), context);
                     }
@@ -166,8 +167,8 @@ public abstract class AbstractHtmlInputF
                                 "org.apache.myfaces.custom.fileupload."+this.getClientId(context)+".maxSize");
                         if (maxSize != null)
                         {
-                            MessageUtils.addMessage(FacesMessage.SEVERITY_ERROR,
-                                    SIZE_LIMIT_MESSAGE_ID, new Object[] { getLabel(context, this),
+                            MessageUtils.addMessage(Constants.TOMAHAWK_DEFAULT_BUNDLE, FacesMessage.SEVERITY_ERROR,
+                                    SIZE_LIMIT_MESSAGE_ID, new Object[] { MessageUtils.getLabel(context, this),
                                             maxSize},
                                     getClientId(context), context);
                         }
@@ -185,19 +186,4 @@ public abstract class AbstractHtmlInputF
              }
          }
      }
-    
-    //TODO: Move this method to org.apache.myfaces.shared.util.MessageUtils
-    private static String getLabel(FacesContext facesContext, UIComponent component) {
-        Object label = component.getAttributes().get("label");
-        if(label != null)
-            return label.toString();
-        
-        ValueExpression expression = component.getValueExpression("label");
-        if(expression != null)
-            return expression.getExpressionString();
-            //return (String)expression.getValue(facesContext.getELContext());
-        
-        //If no label is not specified, use clientId
-        return component.getClientId( facesContext );
-    }
 }

Modified: myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/validator/ValidatorBase.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/validator/ValidatorBase.java?rev=940139&r1=940138&r2=940139&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/validator/ValidatorBase.java (original)
+++ myfaces/tomahawk/trunk/core12/src/main/java/org/apache/myfaces/validator/ValidatorBase.java Sun May  2 01:35:24 2010
@@ -35,6 +35,7 @@ import javax.faces.validator.Validator;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFValidator;
 import org.apache.myfaces.shared_tomahawk.util.MessageUtils;
+import org.apache.myfaces.tomahawk.util.Constants;
 
 /**
  * Base validator implementation for Apache MyFaces Commons Validators.
@@ -150,7 +151,7 @@ public abstract class ValidatorBase impl
 
         if (getSummaryMessage() == null && getDetailMessage() == null)
         {
-            msg = MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, defaultMessage, args);
+            msg = MessageUtils.getMessage(Constants.TOMAHAWK_DEFAULT_BUNDLE, FacesMessage.SEVERITY_ERROR, defaultMessage, args);
         } else {
             Locale locale = MessageUtils.getCurrentLocale();
             String summaryText = MessageUtils.substituteParams(locale, getSummaryMessage(), args);