// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java
// public class MaterialWidgetBuilder extends WidgetBuilder {
// 
// 	private static final String KEY = MaterialWidgetBuilder.class.getName();
// 
// 	public static MaterialWidgetBuilder getInstance(final FacesContext context) {
// 
// 		MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY);
// 
// 		if (wb == null) {
// 			wb = new MaterialWidgetBuilder(context);
// 
// 			context.getExternalContext().getRequestMap().put(KEY, wb);
// 		}
// 
// 		return wb;
// 	}
//     
//     public MaterialWidgetBuilder(FacesContext context) {
//         super(context);
//     }
// 
//     protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException {
//     	this.endFunction = endFunction;
// 
//         context.getResponseWriter().write("MaterialPrime.cw(\"");
//         context.getResponseWriter().write(widgetClass);
//         context.getResponseWriter().write("\",\"");
//         context.getResponseWriter().write(widgetVar);
//         context.getResponseWriter().write("\",{");
//         context.getResponseWriter().write("id:\"");
//         context.getResponseWriter().write(id);
//         if (widgetVar == null) {
//         	context.getResponseWriter().write("\"");
//         } else {
// 	        context.getResponseWriter().write("\",widgetVar:\"");
// 	        context.getResponseWriter().write(widgetVar);
// 	        context.getResponseWriter().write("\"");
//         }
// 
//         return this;
//     }
// }


import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.ConverterException;
import org.primefaces.material.MaterialWidgetBuilder;
import org.primefaces.renderkit.CoreRenderer;
import org.primefaces.util.ComponentUtils;
import org.primefaces.util.WidgetBuilder;
		
		writer.startElement("p", checkbox);		
			writer.writeAttribute("id", checkbox.getClientId(), null);
			
			writer.startElement("input", null);
				writer.writeAttribute("id", inputId, null);
				writer.writeAttribute("class", "checkbox", null);
				writer.writeAttribute("name", inputId, null);
				if(checkbox.getTabindex() != null){
		        	writer.writeAttribute("tabindex", checkbox.getTabindex(), null);
		        }
				if(checkbox.isDisabled()){
					writer.writeAttribute("disabled", checkbox.isDisabled(), null);
				}
				writer.writeAttribute("type", "checkbox", null);
				writer.writeAttribute("checked",  checked, null);
			writer.endElement("input");				
			
			writer.startElement("label", null);
				writer.writeAttribute("for", inputId, null);
				writer.write(checkbox.getItemLabel());		
			writer.endElement("label");		
			
		writer.endElement("p");
	}
	
	private void encodeScript(FacesContext context, Checkbox checkbox) throws IOException {
		String clientId = checkbox.getClientId();
		String widgetVar = checkbox.resolveWidgetVar();
		 
// Path: src/main/java/org/primefaces/material/MaterialWidgetBuilder.java
// public class MaterialWidgetBuilder extends WidgetBuilder {
// 
// 	private static final String KEY = MaterialWidgetBuilder.class.getName();
// 
// 	public static MaterialWidgetBuilder getInstance(final FacesContext context) {
// 
// 		MaterialWidgetBuilder wb = (MaterialWidgetBuilder) context.getExternalContext().getRequestMap().get(KEY);
// 
// 		if (wb == null) {
// 			wb = new MaterialWidgetBuilder(context);
// 
// 			context.getExternalContext().getRequestMap().put(KEY, wb);
// 		}
// 
// 		return wb;
// 	}
//     
//     public MaterialWidgetBuilder(FacesContext context) {
//         super(context);
//     }
// 
//     protected WidgetBuilder init(String widgetClass, String widgetVar, String id, boolean endFunction) throws IOException {
//     	this.endFunction = endFunction;
// 
//         context.getResponseWriter().write("MaterialPrime.cw(\"");
//         context.getResponseWriter().write(widgetClass);
//         context.getResponseWriter().write("\",\"");
//         context.getResponseWriter().write(widgetVar);
//         context.getResponseWriter().write("\",{");
//         context.getResponseWriter().write("id:\"");
//         context.getResponseWriter().write(id);
//         if (widgetVar == null) {
//         	context.getResponseWriter().write("\"");
//         } else {
// 	        context.getResponseWriter().write("\",widgetVar:\"");
// 	        context.getResponseWriter().write(widgetVar);
// 	        context.getResponseWriter().write("\"");
//         }
// 
//         return this;
//     }
// }


// Path: src/main/java/org/primefaces/material/component/checkbox/CheckboxRenderer.java
import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.ConverterException;
import org.primefaces.material.MaterialWidgetBuilder;
import org.primefaces.renderkit.CoreRenderer;
import org.primefaces.util.ComponentUtils;
import org.primefaces.util.WidgetBuilder;

		
		writer.startElement("p", checkbox);		
			writer.writeAttribute("id", checkbox.getClientId(), null);
			
			writer.startElement("input", null);
				writer.writeAttribute("id", inputId, null);
				writer.writeAttribute("class", "checkbox", null);
				writer.writeAttribute("name", inputId, null);
				if(checkbox.getTabindex() != null){
		        	writer.writeAttribute("tabindex", checkbox.getTabindex(), null);
		        }
				if(checkbox.isDisabled()){
					writer.writeAttribute("disabled", checkbox.isDisabled(), null);
				}
				writer.writeAttribute("type", "checkbox", null);
				writer.writeAttribute("checked",  checked, null);
			writer.endElement("input");				
			
			writer.startElement("label", null);
				writer.writeAttribute("for", inputId, null);
				writer.write(checkbox.getItemLabel());		
			writer.endElement("label");		
			
		writer.endElement("p");
	}
	
	private void encodeScript(FacesContext context, Checkbox checkbox) throws IOException {
		String clientId = checkbox.getClientId();
		String widgetVar = checkbox.resolveWidgetVar();
		 
		WidgetBuilder wb = MaterialWidgetBuilder.getInstance(context);