HTML and CSS Reference
In-Depth Information
// Add an event listener for the “timeupdate” event of the media player
media.addEventListener("timeupdate", function() {
var percent = Math.floor((100 / media.duration) * media.currentTime);
bar.value = percent;
});
}
The FacesComponent behind the composite component in Listing 8-16 is necessary to calculate the client
identifier of the component specified in the for attribute.
Listing 8-16. UIProgress FacesComponent Used by the Progress Composite Component
package com.apress.projsf2html5.components.progress;
import java.io.IOException;
import javax.el.ValueExpression;
import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponent;
import javax.faces.component.UINamingContainer;
/**
* Composite component for the {@code <progress/>} element.
*/
@FacesComponent("UIProgress")
public class UIProgress extends UINamingContainer {
private static final String ATTRIBUTE_FOR = "for";
private UIComponent forComponent;
/**
* Finds the component specified in the {@code for} attribute.
*
* @return {@link UIComponent} specified in the {@code for} attribute
* @throws IOException If a {@link UIComponent} with the name specified in
* the {@code for} attribute could not be found
*/
public UIComponent getForComponent() throws IOException {
if (getAttributes().containsKey(ATTRIBUTE_FOR)) {
String forAttribute = (String) getAttribute(ATTRIBUTE_FOR);
this.forComponent = findComponent(forAttribute);
if (this.forComponent == null) {
throw new IOException("Component with ID "
+ forAttribute + " could not be found");
}
} else {
throw new IOException("The for attribute was not set on the component");
}
return forComponent;
}
 
Search WWH ::




Custom Search