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 2012/08/29 05:19:16 UTC

svn commit: r1378432 - /myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java

Author: lu4242
Date: Wed Aug 29 03:19:15 2012
New Revision: 1378432

URL: http://svn.apache.org/viewvc?rev=1378432&view=rev
Log:
MYFACES-3591 Labels with EL expressions are not shown in messages if partial state saving is disabled 

Modified:
    myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java

Modified: myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java?rev=1378432&r1=1378431&r2=1378432&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java (original)
+++ myfaces/commons/trunk/myfaces-commons-utils/src/main/java/org/apache/myfaces/commons/util/MessageUtils.java Wed Aug 29 03:19:15 2012
@@ -646,12 +646,33 @@ public final class MessageUtils
     public static Object getLabel(FacesContext facesContext, UIComponent component)
     {
         Object label = component.getAttributes().get("label");
+        ValueExpression expression = null;
+        if (label != null && 
+            label instanceof String && ((String)label).length() == 0 )
+        {
+            // Note component.getAttributes().get("label") internally try to 
+            // evaluate the EL expression for the label, but in some cases, 
+            // when PSS is disabled and f:loadBundle is used, when the view is 
+            // restored the bundle is not set to the EL expression returns an 
+            // empty String. It is not possible to check if there is a 
+            // hardcoded label, but we can check if there is
+            // an EL expression set, so the best in this case is use that, and if
+            // there is an EL expression set, use it, otherwise use the hardcoded
+            // value. See MYFACES-3591 for details.
+            expression = component.getValueExpression("label");
+            if (expression != null)
+            {
+                // Set the label to null and use the EL expression instead.
+                label = null;
+            }
+        }
+            
         if(label != null)
         {
             return label;
         }
-
-        ValueExpression expression = component.getValueExpression("label");
+        
+        expression = (expression == null) ? component.getValueExpression("label") : expression;
         if(expression != null)
         {
             return expression;