[JAVASERVERFACES-2689]  Composite Component Default attr values not available programmatically when default value is a El Created: 15/Jan/13  Updated: 29/Jan/13  Resolved: 29/Jan/13

Status: Closed
Project: javaserverfaces
Component/s: None
Affects Version/s: None
Fix Version/s: 2.1.18

Type: Bug Priority: Major
Reporter: gonzalad Assignee: Manfred Riem
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
duplicates JAVASERVERFACES-1909 Composite attribute 'default': EL exp... Closed


When default attribute value in a composite component is an El, calling getAttributes().get("myattribute") returns null.

For now, I must evaluate programmatically #


to retrieve the attribute value.

Sample composite :

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<ui:composition xmlns="http://www.w3.org/1999/xhtml"

	<cc:interface componentType="org.jboss.seam.faces.InputContainer">
		<cc:attribute name="styleClass" default="control-group #{cc.attrs.invalid ? 'error' : ''}"/>
public class UIInputContainer extends UIComponentBase implements
		NamingContainer {

	public void encodeBegin(final FacesContext context) throws IOException {
		if (!isRendered()) {
		//this one returns null
		Object attribute1 = getAttributes().get("styleClass");
		//this one returns the real value
		FacesContext facesContext = FacesContext.getCurrentInstance();
		ELContext elContext = facesContext.getELContext();
		ValueExpression targetExpression = facesContext
				.createValueExpression(elContext, "#{cc.attrs.styleClass}",
		Object attribute2 = targetExpression.getValue(elContext);

Comment by Ed Burns [ 16/Jan/13 ]

The implementation of the cc:interface handler builds up a composite component metadata data structure that stores the default value. The implementation of that data structure either evaluates the EL expression for the default or saves it as a ValueExpression. I'm not sure which at this point. Need more investigation.

Comment by Manfred Riem [ 22/Jan/13 ]

Can you please let us know which version is affected?

Comment by gonzalad [ 23/Jan/13 ]

Thanks for taking this issue.
Affected version is 2.1.5.
Do you need a testcase ?

Comment by Manfred Riem [ 23/Jan/13 ]

A testcase is always welcome. Have you tried it on the latest 2.1 release?

Comment by Ed Burns [ 23/Jan/13 ]

Manfred asserted that code from PropertyHandlerManager.java could be backported from JSF 2.2 to 2.1 to handle this. Specifically lines 83 and 253 - 286.

I noticed that Imre had committed these lines as part of the fix for JAVASERVERFACES-1966.

That makes sense to me, but I'd like to get Imre's input.

Comment by gonzalad [ 24/Jan/13 ]

Sorry for being late, I've uploaded a little testcase on my github repo https://github.com/gonzalad/mojarra2869.

I didn't see the button to add a file in this JIRA (missed my googles ?).

Testcase shows the issue on mojarra 2.1.17.

To use it :

  • mvn package
  • install resulting war on Tomcat (tested it on 7.0.29).
  • browse http://localhost:8080/mojarra2869/index.jsf
  • this should show that getAttributes().get("value") returns null instead of 'control-group true'.
Comment by Manfred Riem [ 29/Jan/13 ]

Applied to 2.1 branch,

svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2689, r=rogerk, allow for evaluation of EL expressions in cc:attribute default values."
Sending jsf-ri\src\main\java\com\sun\faces\facelets\tag\composite\PropertyHandlerManager.java
Adding test\agnostic\facelets\cc\nb-configuration.xml
Adding test\agnostic\facelets\cc\src\main\webapp\defaultEl.xhtml
Adding test\agnostic\facelets\cc\src\main\webapp\defaultEl2.xhtml
Adding test\agnostic\facelets\cc\src\main\webapp\resources\defaultEl
Adding test\agnostic\facelets\cc\src\main\webapp\resources\defaultEl\component.xhtml
Adding test\agnostic\facelets\cc\src\test\java\com\sun\faces\test\agnostic\facelets\composite\Issue2689IT.java
Transmitting file data ......
Committed revision 11482.

Generated at Mon Apr 27 01:53:34 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.