/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.corejsf;

import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.Renderer;

/**
 *
 * @author Glavni Administrator
 */
public class AccordionPanelRenderer extends Renderer {

    public boolean getRendersChildren() {
        return false;
    }

    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {

        String panelClass = (String) component.getParent().getAttributes().get("panelClass");
        String headerClass = (String) component.getParent().getAttributes().get("headerClass");
        String contentClass = (String) component.getParent().getAttributes().get("contentClass");
        String heading = (String) component.getAttributes().get("heading");
        ResponseWriter writer = context.getResponseWriter();
        //div za panel
        writer.write("<div ");
        if (panelClass != null) {
            writer.write("class='" + panelClass + "'");
        }
        writer.write(">");
        //div heder panela
        writer.write("<div ");
        if (headerClass != null) {
            writer.write("class='" + headerClass + "'");
        }
        writer.write(">");
        writer.write(heading);
        writer.write("</div>");
        //kraj div heder panela pocetak div content panela
        writer.write("<div ");
        if (contentClass != null) {
            writer.write("class='" + contentClass + "'");
        }
        writer.write(">");
    }
    public void encodeEnd(FacesContext context,UIComponent component)throws IOException{
        ResponseWriter writer=context.getResponseWriter();
        writer.write("</div>");
        writer.write("</div>");
    
    }
}
