Package org.apache.myfaces.tobago.renderkit.html.scarborough.mozilla_4_7.tag

Source Code of org.apache.myfaces.tobago.renderkit.html.scarborough.mozilla_4_7.tag.ProgressRenderer

package org.apache.myfaces.tobago.renderkit.html.scarborough.mozilla_4_7.tag;

/*
* Copyright 2002-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* Created 07.02.2003 16:00:00.
* : $
*/

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.renderkit.RendererBase;

import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.swing.BoundedRangeModel;
import javax.swing.DefaultBoundedRangeModel;
import java.io.IOException;

public class ProgressRenderer extends RendererBase {

  private static final Log LOG = LogFactory.getLog(ProgressRenderer.class);
      
  public void encodeEndTobago(FacesContext facesContext,
      UIComponent uiComponent) throws IOException {

    UIOutput component = (UIOutput) uiComponent;

    BoundedRangeModel model = (BoundedRangeModel) component.getValue();

    if (model == null) {
      LOG.warn("'null' value found! Using dummy Model instead!");
      model = new DefaultBoundedRangeModel(4, 1, 0, 10);
    }

    ResponseWriter writer = facesContext.getResponseWriter();

    writer.startElement("table", null);
    writer.writeAttribute("border", "0", null);
    writer.writeAttribute("cellspacing", "0", null);
    writer.writeAttribute("cellpadding", "0", null);
    writer.writeAttribute("summary", "", null);

    writer.startElement("tr", null);

    writer.startElement("td", null);
    writer.writeAttribute("style", "background-color: #aabbcc;", null);
    writer.writeAttribute("width", Integer.toString(model.getValue()), null);
    writer.write(" ");
    writer.endElement("td");

    writer.startElement("td", null);
    writer.writeAttribute("style", "background-color: #ddeeff;", null);
    writer.writeAttribute("width",
        Integer.toString(model.getMaximum() - model.getValue()), null);
    writer.write(" ");
    writer.endElement("td");

    writer.endElement("tr");
    writer.endElement("table");           
  }

// ///////////////////////////////////////////// bean getter + setter

}
TOP

Related Classes of org.apache.myfaces.tobago.renderkit.html.scarborough.mozilla_4_7.tag.ProgressRenderer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.