*/
public void encodeInitialScript(FacesContext context,
UIComponent component, String state) throws IOException {
ResponseWriter writer = context.getResponseWriter();
UIProgressBar progressBar = (UIProgressBar) component;
ComponentVariables variables = ComponentsVariableResolver.getVariables(
this, component);
StringBuffer script = new StringBuffer();
String clientId = component.getClientId(context);
String containerId = ((UIComponent) AjaxRendererUtils
.findAjaxContainer(context, component)).getClientId(context);
String mode = (String) component.getAttributes().get("mode");
UIComponent form = AjaxRendererUtils.getNestingForm(component);
String formId = "";
if (form != null) {
formId = form.getClientId(context);
} else if ("ajax".equals(mode)) {
// Ignore form absent. It can be rendered by forcing from any
// component
// throw new FaceletException("Progress bar component in ajax mode
// should be placed inside the form");
}
Number minValue = getNumber(component.getAttributes().get("minValue"));
Number maxValue = getNumber(component.getAttributes().get("maxValue"));
Number value = (Number) variables.getVariable("value");
StringBuffer markup = getMarkup(context, component);
script.append("new ProgressBar('").append(clientId).append("','") // id
.append(containerId).append("','") // containerId
.append(formId).append("','") // formId