HTML and CSS Reference
In-Depth Information
Listing 8-8. Representing the Composite Component Root Specified as the
componentType in Listing 8-3
import javax.el.ValueExpression;
import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponent;
import javax.faces.component.UINamingContainer;
import javax.faces.context.FacesContext;
* Composite component for the {@code <audio/>} and {@code <video/>} elements.
public class UIMediaComponent extends UINamingContainer {
private static final String ELEMENT_ID = "media-player";
private static final String ATTRIBUTE_AUTOPLAY = "autoplay";
private static final String ATTRIBUTE_LOOP = "loop";
private static final String ATTRIBUTE_MUTED = "muted";
private static final String ATTRIBUTE_CONTROLS = "controls";
private static final String ATTRIBUTE_POSTER = "poster";
private static final String ATTRIBUTE_WIDTH = "width";
private static final String ATTRIBUTE_HEIGHT = "height";
public String getElementId() {
return ELEMENT_ID;
public void encodeBegin(FacesContext context) throws IOException {
UIComponent element = findMediaElement();
addAttributeIfTrue(element, ATTRIBUTE_AUTOPLAY);
addAttributeIfTrue(element, ATTRIBUTE_LOOP);
addAttributeIfTrue(element, ATTRIBUTE_MUTED);
addAttributeIfTrue(element, ATTRIBUTE_CONTROLS);
addAttributeIfNotNull(element, ATTRIBUTE_POSTER);
addAttributeIfNotNull(element, ATTRIBUTE_WIDTH);
addAttributeIfNotNull(element, ATTRIBUTE_HEIGHT);
private void addAttributeIfNotNull(UIComponent component, String attributeName) {
Object attributeValue = getAttribute(attributeName);
if (attributeValue != null) {
component.getPassThroughAttributes().put(attributeName, attributeValue);
Search WWH ::

Custom Search