javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2689

Composite Component Default attr values not available programmatically when default value is a El

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.1.18
    • Component/s: None
    • Labels:
      None

      Description

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

      For now, I must evaluate programmatically #

      {cc.attrs.myattribute}

      to retrieve the attribute value.

      Sample composite :

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
      	xmlns:ui="http://java.sun.com/jsf/facelets"
      	xmlns:f="http://java.sun.com/jsf/core"
      	xmlns:h="http://java.sun.com/jsf/html"
      	xmlns:c="http://java.sun.com/jsp/jstl/core"
      	xmlns:cc="http://java.sun.com/jsf/composite">
      
      	<cc:interface componentType="org.jboss.seam.faces.InputContainer">
      		<cc:attribute name="styleClass" default="control-group #{cc.attrs.invalid ? 'error' : ''}"/>
      	</cc:interface>
      	<cc:implementation>
              blabla
      	</cc:implementation>
      </ui:composition>
      
      @FacesComponent(UIInputContainer.COMPONENT_TYPE)
      public class UIInputContainer extends UIComponentBase implements
      		NamingContainer {
      
      	@Override
      	public void encodeBegin(final FacesContext context) throws IOException {
      		if (!isRendered()) {
      			return;
      		}
      		//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
      				.getApplication()
      				.getExpressionFactory()
      				.createValueExpression(elContext, "#{cc.attrs.styleClass}",
      						Object.class);
      		Object attribute2 = targetExpression.getValue(elContext);
      		...
      	}
      }
      

        Issue Links

          Activity

            People

            • Assignee:
              Manfred Riem
              Reporter:
              gonzalad
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: