myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r600207 - in /myfaces/core/trunk_1.2.x/api/src: main/java/javax/faces/component/ main/java/javax/faces/convert/ main/java/javax/faces/validator/ test/java/javax/faces/validator/
Date Sat, 01 Dec 2007 22:51:42 GMT
Author: lu4242
Date: Sat Dec  1 14:51:41 2007
New Revision: 600207

URL: http://svn.apache.org/viewvc?rev=600207&view=rev
Log:
fixes MYFACES-1729 label attribute does not resolve EL expresion (JSR 252 Issue 6 related)

Added:
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/_LabeledFacesMessage.java
  (with props)
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/convert/_LabeledFacesMessage.java
  (with props)
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/validator/_LabeledFacesMessage.java
  (with props)
Modified:
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/_MessageUtils.java
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/convert/_MessageUtils.java
    myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/validator/_MessageUtils.java
    myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/validator/_MessageUtilsTest.java

Added: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/_LabeledFacesMessage.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/_LabeledFacesMessage.java?rev=600207&view=auto
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/_LabeledFacesMessage.java
(added)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/_LabeledFacesMessage.java
Sat Dec  1 14:51:41 2007
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package javax.faces.component;
+
+import javax.el.ValueExpression;
+import javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
+import javax.faces.context.FacesContext;
+
+/** 
+ * This class encapsulates a FacesMessage to evaluate the label
+ * expression on render response, where f:loadBundle is available
+ * 
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+class _LabeledFacesMessage extends FacesMessage{
+	
+	public _LabeledFacesMessage() {
+		super();
+	}
+
+	public _LabeledFacesMessage(Severity severity, String summary,
+			String detail, Object args[]) {
+		super(severity, summary, detail);
+		
+	}
+	
+	public _LabeledFacesMessage(Severity severity, String summary,
+			String detail) {
+		super(severity, summary, detail);
+	}
+
+	public _LabeledFacesMessage(String summary, String detail) {
+		super(summary, detail);
+	}
+
+	public _LabeledFacesMessage(String summary) {
+		super(summary);
+	}
+
+	@Override
+	public String getDetail() {
+		FacesContext facesContext = FacesContext.getCurrentInstance();
+    	ValueExpression value = facesContext.getApplication().getExpressionFactory().
+    		createValueExpression(facesContext.getELContext(), super.getDetail(), String.class);
+		return (String) value.getValue(facesContext.getELContext());
+	}
+
+	@Override
+	public String getSummary() {
+		FacesContext facesContext = FacesContext.getCurrentInstance();
+    	ValueExpression value = facesContext.getApplication().getExpressionFactory().
+    		createValueExpression(facesContext.getELContext(), super.getSummary(), String.class);
+		return (String) value.getValue(facesContext.getELContext());
+	}
+	
+}
+

Propchange: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/_LabeledFacesMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/_LabeledFacesMessage.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/_MessageUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/_MessageUtils.java?rev=600207&r1=600206&r2=600207&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/_MessageUtils.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/component/_MessageUtils.java Sat
Dec  1 14:51:41 2007
@@ -18,6 +18,7 @@
 import javax.el.ValueExpression;
 import javax.faces.application.FacesMessage;
 import javax.faces.context.FacesContext;
+
 import java.text.MessageFormat;
 import java.util.Locale;
 import java.util.MissingResourceException;
@@ -131,7 +132,7 @@
             }
         }
 
-        return new FacesMessage(severity, summary, detail);
+        return new _LabeledFacesMessage(severity, summary, detail);
     }
 
 
@@ -205,7 +206,8 @@
     	
     	ValueExpression expression = component.getValueExpression("label");
     	if(expression != null)
-    		return (String)expression.getValue(facesContext.getELContext());
+    		return expression.getExpressionString();
+    		//return (String)expression.getValue(facesContext.getELContext());
     	
     	//If no label is not specified, use clientId
     	return component.getClientId( facesContext );

Added: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/convert/_LabeledFacesMessage.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/convert/_LabeledFacesMessage.java?rev=600207&view=auto
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/convert/_LabeledFacesMessage.java
(added)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/convert/_LabeledFacesMessage.java
Sat Dec  1 14:51:41 2007
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package javax.faces.convert;
+
+import javax.el.ValueExpression;
+import javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
+import javax.faces.context.FacesContext;
+
+/** 
+ * This class encapsulates a FacesMessage to evaluate the label
+ * expression on render response, where f:loadBundle is available
+ *
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+class _LabeledFacesMessage extends FacesMessage{
+	
+	public _LabeledFacesMessage() {
+		super();
+	}
+
+	public _LabeledFacesMessage(Severity severity, String summary,
+			String detail, Object args[]) {
+		super(severity, summary, detail);
+		
+	}
+	
+	public _LabeledFacesMessage(Severity severity, String summary,
+			String detail) {
+		super(severity, summary, detail);
+	}
+
+	public _LabeledFacesMessage(String summary, String detail) {
+		super(summary, detail);
+	}
+
+	public _LabeledFacesMessage(String summary) {
+		super(summary);
+	}
+
+	@Override
+	public String getDetail() {
+		FacesContext facesContext = FacesContext.getCurrentInstance();
+    	ValueExpression value = facesContext.getApplication().getExpressionFactory().
+    		createValueExpression(facesContext.getELContext(), super.getDetail(), String.class);
+		return (String) value.getValue(facesContext.getELContext());
+	}
+
+	@Override
+	public String getSummary() {
+		FacesContext facesContext = FacesContext.getCurrentInstance();
+    	ValueExpression value = facesContext.getApplication().getExpressionFactory().
+    		createValueExpression(facesContext.getELContext(), super.getSummary(), String.class);
+		return (String) value.getValue(facesContext.getELContext());
+	}
+	
+}
+

Propchange: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/convert/_LabeledFacesMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/convert/_LabeledFacesMessage.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/convert/_MessageUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/convert/_MessageUtils.java?rev=600207&r1=600206&r2=600207&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/convert/_MessageUtils.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/convert/_MessageUtils.java Sat
Dec  1 14:51:41 2007
@@ -19,6 +19,7 @@
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
+
 import java.text.MessageFormat;
 import java.util.Locale;
 import java.util.MissingResourceException;
@@ -109,7 +110,7 @@
             }
         }
 
-        return new FacesMessage(severity, summary, detail);
+        return new _LabeledFacesMessage(severity, summary, detail);
     }
 
 
@@ -184,7 +185,8 @@
     	
     	ValueExpression expression = component.getValueExpression("label");
     	if(expression != null)
-    		return (String)expression.getValue(facesContext.getELContext());
+    		return expression.getExpressionString();
+    		//return (String)expression.getValue(facesContext.getELContext());
     	
     	//If no label is not specified, use clientId
     	return component.getClientId( facesContext );

Added: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/validator/_LabeledFacesMessage.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/validator/_LabeledFacesMessage.java?rev=600207&view=auto
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/validator/_LabeledFacesMessage.java
(added)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/validator/_LabeledFacesMessage.java
Sat Dec  1 14:51:41 2007
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package javax.faces.validator;
+
+import javax.el.ValueExpression;
+import javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
+import javax.faces.context.FacesContext;
+
+/** 
+ * This class encapsulates a FacesMessage to evaluate the label
+ * expression on render response, where f:loadBundle is available
+ * 
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+class _LabeledFacesMessage extends FacesMessage{
+	
+	public _LabeledFacesMessage() {
+		super();
+	}
+
+	public _LabeledFacesMessage(Severity severity, String summary,
+			String detail, Object args[]) {
+		super(severity, summary, detail);
+		
+	}
+	
+	public _LabeledFacesMessage(Severity severity, String summary,
+			String detail) {
+		super(severity, summary, detail);
+	}
+
+	public _LabeledFacesMessage(String summary, String detail) {
+		super(summary, detail);
+	}
+
+	public _LabeledFacesMessage(String summary) {
+		super(summary);
+	}
+
+	@Override
+	public String getDetail() {
+		FacesContext facesContext = FacesContext.getCurrentInstance();
+    	ValueExpression value = facesContext.getApplication().getExpressionFactory().
+    		createValueExpression(facesContext.getELContext(), super.getDetail(), String.class);
+		return (String) value.getValue(facesContext.getELContext());
+	}
+
+	@Override
+	public String getSummary() {
+		FacesContext facesContext = FacesContext.getCurrentInstance();
+    	ValueExpression value = facesContext.getApplication().getExpressionFactory().
+    		createValueExpression(facesContext.getELContext(), super.getSummary(), String.class);
+		return (String) value.getValue(facesContext.getELContext());
+	}
+	
+}
+

Propchange: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/validator/_LabeledFacesMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/validator/_LabeledFacesMessage.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/validator/_MessageUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/validator/_MessageUtils.java?rev=600207&r1=600206&r2=600207&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/validator/_MessageUtils.java (original)
+++ myfaces/core/trunk_1.2.x/api/src/main/java/javax/faces/validator/_MessageUtils.java Sat
Dec  1 14:51:41 2007
@@ -17,6 +17,7 @@
 
 import javax.el.ValueExpression;
 import javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import java.text.MessageFormat;
@@ -115,7 +116,7 @@
             }
         }
 
-        return new FacesMessage(severity, summary, detail);
+        return new _LabeledFacesMessage(severity, summary, detail);
     }
 
 
@@ -190,7 +191,8 @@
     	
     	ValueExpression expression = component.getValueExpression("label");
     	if(expression != null)
-    		return (String)expression.getValue(facesContext.getELContext());
+    		return expression.getExpressionString();
+    		//return (String)expression.getValue(facesContext.getELContext());
     	
     	//If no label is not specified, use clientId
     	return component.getClientId( facesContext );

Modified: myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/validator/_MessageUtilsTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/validator/_MessageUtilsTest.java?rev=600207&r1=600206&r2=600207&view=diff
==============================================================================
--- myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/validator/_MessageUtilsTest.java
(original)
+++ myfaces/core/trunk_1.2.x/api/src/test/java/javax/faces/validator/_MessageUtilsTest.java
Sat Dec  1 14:51:41 2007
@@ -18,17 +18,22 @@
  */
 package javax.faces.validator;
 
-import org.apache.shale.test.mock.MockFacesContext12;
 import static org.easymock.EasyMock.expect;
-import org.easymock.classextension.EasyMock;
-import org.easymock.classextension.IMocksControl;
 import static org.testng.Assert.assertEquals;
-import org.testng.annotations.Test;
 
+import java.util.Locale;
+
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
 import javax.faces.application.Application;
 import javax.faces.application.ViewHandler;
 import javax.faces.component.UIViewRoot;
-import java.util.Locale;
+
+import org.apache.shale.test.mock.MockFacesContext12;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.testng.annotations.Test;
 
 /**
  * @author Mathias Broekelmann (latest modification by $Author$)
@@ -49,12 +54,20 @@
         IMocksControl mocksControl = EasyMock.createControl();
         Application application = mocksControl.createMock(Application.class);
         ViewHandler viewHandler = mocksControl.createMock(ViewHandler.class);
+        ELContext elContext = mocksControl.createMock(ELContext.class);
+        ExpressionFactory expressionFactory = mocksControl.createMock(ExpressionFactory.class);
+        ValueExpression valueExpression = mocksControl.createMock(ValueExpression.class);
         facesContext.setApplication(application);
         facesContext.setViewRoot(root);
-
+        facesContext.setELContext(elContext);
+        
         expect(application.getViewHandler()).andReturn(viewHandler);
         expect(viewHandler.calculateLocale(facesContext)).andReturn(Locale.ENGLISH);
         expect(application.getMessageBundle()).andReturn("javax.faces.Messages");
+        expect(application.getExpressionFactory()).andReturn(expressionFactory);
+        String s = "xxx: Validation Error: Value is greater than allowable maximum of \"xyz\"";
+        expect(expressionFactory.createValueExpression(elContext,s,String.class)).andReturn(valueExpression);
+        expect(valueExpression.getValue(elContext)).andReturn(s);
         mocksControl.replay();
 
         assertEquals(_MessageUtils.getErrorMessage(facesContext, "javax.faces.validator.DoubleRangeValidator.MAXIMUM",



Mime
View raw message