This methods generates the HTML code of the current b:icon.

@param context
the FacesContext.
@param component
the current b:icon.
@throws IOException
thrown if something goes wrong when writing the HTML code.
423357
@Override
	public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
		if (!component.isRendered()) {
			return;
		}
		Icon icon = (Icon) component;
		ResponseWriter writer = context.getResponseWriter();

		String nameOfIcon = icon.getName();
		if (null == nameOfIcon) {
			nameOfIcon = String.valueOf(icon.getValue());
			if (null == icon.getValue()) {
				if (icon instanceof IconAwesome) {
					throw new FacesException("Please specify the attribute 'value' of the icon. This attribute takes the name of the icon, minus the prefix 'fa-'.");
				} else {
					throw new FacesException("Please specify the attribute 'value' of the icon. This attribute takes the name of the icon, minus the prefix 'glyphicon-'.");
				}
			}
		}
		String styleClass = icon.getStyleClass();
		String responsiveCSS= Responsive.getResponsiveStyleClass(icon, false).trim();
		if (responsiveCSS.length()>0) {
			writer.startElement("div", component);
			writer.writeAttribute("class", responsiveCSS, null);
		}
		String style = icon.getStyle();
		String size = icon.getSize();
		String rotate = icon.getRotate();
		String flip = icon.getFlip();
		boolean spin = icon.isSpin();

		if (icon instanceof IconAwesome) {
			IconAwesome awesome = (IconAwesome) icon;
			encodeIcon(context.getResponseWriter(), icon, nameOfIcon, icon instanceof IconAwesome, size, rotate, flip, spin,
			 styleClass, style, icon.isDisabled(), icon.isAddon(), true, true,
			 awesome.isBrand(), awesome.isInverse(), awesome.isLight(), awesome.isPulse(), awesome.isRegular(), awesome.isSolid());
		} else {
			encodeIcon(context.getResponseWriter(), icon, nameOfIcon, icon instanceof IconAwesome, size, rotate, flip, spin,
					 styleClass, style, icon.isDisabled(), icon.isAddon(), true, true,
					 false, false, false, false, false, false);
		}
		if (responsiveCSS.length()>0) {
			writer.endElement("div");
		}

		Tooltip.activateTooltips(context, icon);
	}
746512
@Override
	public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
		if (FacesContext.getCurrentInstance().isPostback()) {
			ResponseWriter writer = context.getResponseWriter();
			writer.writeText("\n", null);
			writer.startElement("script", component);
			writer.write("if (window.jsfScope) {\n");
			List<String> beansAsJSon = PuiModelSync.getFacesModel();
			for (String bean : beansAsJSon) {
				writer.write("puiUpdateModel(" + bean + ");");
			}
			writer.writeText("\n}", null);
			writer.endElement("script");
		}
	}
340388
@Override
	public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
		if (!component.isRendered()) {
			return;
		}
		Slider slider = (Slider) component;
		ResponseWriter rw = context.getResponseWriter();
		encodeHTML(slider, context, rw);

		Tooltip.activateTooltips(context, slider);
	}
734598
@Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        PuiButton button = (PuiButton) component;
        writer.startElement("pui-button", component);
        String actionListener = button.getActionListener();
        if ((null != actionListener) && (!actionListener.contains("("))) {
            actionListener += "()";
        }
        renderNonEmptyAttribute(writer, "actionListener", actionListener);
        renderNonEmptyAttribute(writer, "disabled", button.getDisabled());
        renderNonEmptyAttribute(writer, "icon", button.getIcon());
        renderNonEmptyAttribute(writer, "iconPos", button.getIconPos());
        renderNonEmptyAttribute(writer, "value", button.getValue());
        writer.endElement("pui-button");
    }
1033178
@Override
	public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
		if (!component.isRendered()) {
			return;
		}
		RemoteCommand remoteCommand = (RemoteCommand) component;
		ResponseWriter rw = context.getResponseWriter();
		String clientId = remoteCommand.getClientId();

		String parameters=remoteCommand.getParameters();
		String parametersAsJson=null;
		if (null != parameters && parameters.length()>0) {
			parametersAsJson = "";
			String[] params = parameters.split(",");
			for (String p: params) {
				p=p.trim();
				parametersAsJson += "'" + p + "':" + p + ",";
			}
			parametersAsJson=parametersAsJson.substring(0, parametersAsJson.length()-1);
		}
		StringBuilder call = AJAXRenderer.generateAJAXCall(context, remoteCommand, null, parametersAsJson);
		String name = remoteCommand.getName();
		if (null == name) {
			throw new FacesException("b:remoteCommand: Please define the name of the JavaScript function calling the Java backend.");
		}
			
		rw.startElement("script", component);
		rw.writeAttribute("id", clientId, null);
		String c = call.toString().replace("callAjax(this,", "callAjax(document.getElementById('" + clientId + "'),");
		if (parameters!=null) {
			rw.append("function " + name + "(" + parameters + ", event){" + c + "}");
		} else {
			rw.append("function " + name + "(event){" + c + "}");
		}
		rw.endElement("script");

	}
1304007
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WSection section = (WSection) component;
		XmlStringBuilder xml = renderContext.getWriter();

		boolean renderChildren = isRenderContent(section);

		xml.appendTagOpen("ui:section");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		if (SectionMode.LAZY.equals(section.getMode())) {
			xml.appendOptionalAttribute("hidden", !renderChildren, "true");
		} else {
			xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
		}

		SectionMode mode = section.getMode();
		if (mode != null) {
			switch (mode) {
				case LAZY:
					xml.appendAttribute("mode", "lazy");
					break;
				case EAGER:
					xml.appendAttribute("mode", "eager");
					break;
				default:
					throw new SystemException("Unknown section mode: " + section.getMode());
			}
		}

		xml.appendClose();

		// Render margin
		MarginRendererUtil.renderMargin(section, renderContext);

		if (renderChildren) {
			// Label
			section.getDecoratedLabel().paint(renderContext);
			// Content
			section.getContent().paint(renderContext);
		}

		xml.appendEndTag("ui:section");
	}
106878
protected void renderCaptionFacet(FacesContext facesContext, ResponseWriter writer, UIComponent component)
            throws IOException
    {
        HtmlRendererUtils.renderTableCaption(facesContext, writer, component);
    }
1020474
private static void decorateComponent(UIComponent parent, UIComponent comp, FacesContext ctx, ResponseWriter rw)
			throws IOException {
		if (comp instanceof Icon)
			((Icon) comp).setAddon(true); // modifies the id of the icon

		String classToApply = "input-group-addon";
		if (comp.getClass().getName().endsWith("Button") || comp.getChildCount() > 0)
			classToApply = "input-group-btn";

		if (comp instanceof HtmlOutputText) {
			HtmlOutputText out = (HtmlOutputText)comp;
			
			String sc = out.getStyleClass();
			if (sc == null)
				sc = classToApply;
			else
				sc = sc + " " + classToApply;
			out.setStyleClass(sc);
			comp.encodeAll(ctx);
		}
		else {
			rw.startElement("span", parent);
			rw.writeAttribute("class", classToApply, "class");
			comp.encodeAll(ctx);
		 rw.endElement("span");
		}
	}
1167929
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WColumn col = (WColumn) component;
		XmlStringBuilder xml = renderContext.getWriter();

		xml.appendTagOpen("ui:column");
		xml.appendAttribute("id", component.getId());
		xml.appendOptionalAttribute("class", component.getHtmlClass());
		xml.appendOptionalAttribute("track", component.isTracking(), "true");
		int width = col.getWidth();
		xml.appendOptionalAttribute("width", width > 0, width);

		switch (col.getAlignment()) {
			case LEFT:
				// left is assumed if omitted
				break;

			case RIGHT:
				xml.appendAttribute("align", "right");
				break;

			case CENTER:
				xml.appendAttribute("align", "center");
				break;

			default:
				throw new IllegalArgumentException("Invalid alignment: " + col.getAlignment());
		}

		xml.appendClose();

		// Paint column contents
		paintChildren(col, renderContext);

		xml.appendEndTag("ui:column");
	}
495675
protected void renderInputBegin(FacesContext facesContext,
            UIComponent component) throws IOException
    {
        ResponseWriter writer = facesContext.getResponseWriter();

        String clientId = component.getClientId(facesContext);

        writer.startElement(HTML.INPUT_ELEM, component);
        writer.writeAttribute(HTML.ID_ATTR, clientId, null);
        writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
        
        //allow extending classes to modify html input element's type
        String inputHtmlType = getInputHtmlType(component);
        writer.writeAttribute(HTML.TYPE_ATTR, inputHtmlType, null);

        renderValue(facesContext, component, writer);

        Map<String, List<ClientBehavior>> behaviors = null;
        if (component instanceof ClientBehaviorHolder)
        {
            behaviors = ((ClientBehaviorHolder) component).getClientBehaviors();
            
            long commonPropertiesMarked = 0L;
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(component);
            }
            if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderChangeEventProperty(writer, 
                        commonPropertiesMarked, component);
                CommonPropertyUtils.renderEventProperties(writer, 
                        commonPropertiesMarked, component);
                CommonPropertyUtils.renderFieldEventPropertiesWithoutOnchange(writer, 
                        commonPropertiesMarked, component);
            }
            else
            {
                HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, component, behaviors);
                if (isCommonEventsOptimizationEnabled(facesContext))
                {
                    Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(component);
                    CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
                            commonPropertiesMarked, commonEventsMarked, component, behaviors);
                    CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
                        facesContext, writer, commonPropertiesMarked, commonEventsMarked, component, behaviors);
                }
                else
                {
                    HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, component, behaviors);
                    HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
                            facesContext, writer, component, behaviors);
                }
            }
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderInputPassthroughPropertiesWithoutDisabledAndEvents(writer, 
                        commonPropertiesMarked, component);
            }
            else
            {
                HtmlRendererUtils.renderHTMLAttributes(writer, component, 
                        HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
            }
        }
        else
        {
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderInputPassthroughPropertiesWithoutDisabled(writer, 
                        CommonPropertyUtils.getCommonPropertiesMarked(component), component);
            }
            else
            {
                HtmlRendererUtils.renderHTMLAttributes(writer, component, 
                        HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
            }
        }

        if (isDisabled(facesContext, component))
        {
            writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
        }

        if (isAutocompleteOff(facesContext, component))
        {
            writer.writeAttribute(HTML.AUTOCOMPLETE_ATTR, AUTOCOMPLETE_VALUE_OFF, HTML.AUTOCOMPLETE_ATTR);
        }
    }
544510
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WPanel panel = (WPanel) component;
		XmlStringBuilder xml = renderContext.getWriter();
		GridLayout layout = (GridLayout) panel.getLayout();
		Size hgap = layout.getHorizontalGap();
		String hgapString = hgap == null ? null : hgap.toString();
		Size vgap = layout.getVerticalGap();
		String vgapString = vgap == null ? null : vgap.toString();
		int rows = layout.getRows();
		int cols = layout.getCols();

		xml.appendTagOpen("ui:gridlayout");

		xml.appendAttribute("rows", rows > 0 ? String.valueOf(rows) : "0");
		xml.appendAttribute("cols", cols > 0 ? String.valueOf(cols) : "0");
		xml.appendOptionalAttribute("hgap", hgapString);
		xml.appendOptionalAttribute("vgap", vgapString);

		xml.appendClose();

		int size = panel.getChildCount();

		for (int i = 0; i < size; i++) {
			xml.appendTag("ui:cell");
			WComponent child = panel.getChildAt(i);
			child.paint(renderContext);
			xml.appendEndTag("ui:cell");
		}

		xml.appendEndTag("ui:gridlayout");
	}
545564
protected void renderSelectTag(FacesContext context, ResponseWriter rw, String clientId, SelectOneMenu menu,
			String outerClientId) throws IOException {
		renderSelectTag(rw, menu);
		renderSelectTagAttributes(rw, clientId, menu, outerClientId);
		renderOptions(context, rw, menu);

		renderInputTagEnd(rw);
		renderJQueryAfterComponent(rw, clientId, menu);
	}
1292492
@Override
	public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
		SelectMultiMenu menu = (SelectMultiMenu) component;

		if (!menu.isRendered()) {
			return;
		}
		ResponseWriter rw = context.getResponseWriter();
		String clientId = menu.getClientId(context).replace(":", "-");
		String span=null;
		boolean clientIdHasBeenRendered=false;
		if (!isHorizontalForm(component)) {
			span = startColSpanDiv(rw, menu, menu.getClientId(context), clientIdHasBeenRendered);
			if (null != span) {
				Tooltip.generateTooltip(context, menu, rw);
				clientIdHasBeenRendered=true;
			}
		}
		rw.startElement("div", menu);
		writeAttribute(rw, "dir", menu.getDir(), "dir");
		if (!clientIdHasBeenRendered) {
			writeAttribute(rw, "id", menu.getClientId(context));
			Tooltip.generateTooltip(context, menu, rw);
			clientIdHasBeenRendered=true;
		}

                rw.writeAttribute("class", getWithFeedback(getInputMode(menu.isInline()), component), "class");
                
		addLabel(rw, clientId + "Inner", menu);

		if (isHorizontalForm(component)) {
			span = startColSpanDiv(rw, menu, menu.getClientId(context), clientIdHasBeenRendered);
		}	
		UIComponent prependingAddOnFacet = menu.getFacet("prepend");
		UIComponent appendingAddOnFacet = menu.getFacet("append");
		final boolean hasAddon = startInputGroupForAddOn(rw, (prependingAddOnFacet != null),
				(appendingAddOnFacet != null), menu);

		addPrependingAddOnToInputGroup(context, rw, prependingAddOnFacet, (prependingAddOnFacet != null), menu);
		renderSelectTag(context, rw, clientId + "Inner", clientId, menu);
		addAppendingAddOnToInputGroup(context, rw, appendingAddOnFacet, (appendingAddOnFacet != null), menu);

		closeInputGroupForAddOn(rw, hasAddon);
		rw.endElement("div"); // form-group
		closeColSpanDiv(rw, span);
		Tooltip.activateTooltips(context, menu);

		String options = "";
		int maxHeight = menu.getMaxHeight();
		if (maxHeight > 0) {
			options += "," + "maxHeight:" + String.valueOf(maxHeight);
		}
		String nonSelectedText = menu.getNonSelectedText();
		if (nonSelectedText != null) {
			options += "," + "nonSelectedText:'" + nonSelectedText + "'";
		}
		String nSelectedText = menu.getNSelectedText();
		nSelectedText = (String) menu.getAttributes().get("nSelectedText"); // workaround
																			// -
																			// the
																			// regular
																			// getter
																			// always
																			// yields
																			// null
		if (nSelectedText != null) {
			options += "," + "nSelectedText:'" + nSelectedText + "'";
		}
		String allSelectedText = menu.getAllSelectedText();
		if (allSelectedText != null) {
			options += "," + "allSelectedText:'" + allSelectedText + "'";
		}
		int numberDisplayed = menu.getNumberDisplayed();
		if (numberDisplayed > 0) {
			options += "," + "numberDisplayed:" + String.valueOf(numberDisplayed);
		}

		if (menu.isIncludeSelectAllOption()) {
			options += "," + "includeSelectAllOption:" + "true";
		}

		String selectAllText = menu.getSelectAllText();
		if (selectAllText != null) {
			options += "," + "selectAllText:'" + selectAllText + "'";
		}

		if (menu.isEnableFiltering()) {
			options += "," + "enableFiltering:true";
		}

		String filterPlaceholder = menu.getFilterPlaceholder();
		if (filterPlaceholder != null) {
			options += "," + "filterPlaceholder:'" + filterPlaceholder + "'";
		}

		boolean enableCaseInsensitiveFiltering = menu.isEnableCaseInsensitiveFiltering();
		if (enableCaseInsensitiveFiltering) {
			options += "," + "enableCaseInsensitiveFiltering:" + "true";
		}

		boolean disableIfEmpty = menu.isDisableIfEmpty();
		if (disableIfEmpty) {
			options += "," + "disableIfEmpty:" + "true";
		}

		boolean dropRight = menu.isDropRight();
		if (dropRight) {
			options += "," + "dropRight:" + "true";
		}

		String buttonClass = menu.getButtonClass();
		if (buttonClass != null) {
			options += "," + "buttonClass:'" + buttonClass + "'";
		}

		String buttonContainer = menu.getButtonContainer();
		if (buttonContainer != null) {
			options += "," + "buttonContainer:'" + buttonClass + "'";
			if (menu.getStyleClass() != null)
				throw new FacesException(
						"b:selectMultiMenu can't process the styleClass attribute if the buttonContainer attribute is set.");
		} else {
			String styleClass = menu.getStyleClass();
			String blockStyle = "display:block";

			if (menu.isInline()) {
				blockStyle = "display:inline-block";
			} else {
				UIForm currentForm = AJAXRenderer.getSurroundingForm((UIComponent)component, true);
				if (null != currentForm && currentForm instanceof Form) {
					if (((Form) currentForm).isInline()) {
						blockStyle = "display:inline-block";
					}
				}
			}
			if (menu.getStyle()!=null) {
				blockStyle += ";" + menu.getStyle();
			}

			if (styleClass != null) {
				options += "," + "buttonContainer:'<div class=\"" + styleClass + "\"  style=\"" + blockStyle + "\"/>'";
			} else {
				options += "," + "buttonContainer:'<div class=\"btn-group\" style=\"" + blockStyle + "\" />'";
			}
		}

		int buttonWidth = menu.getButtonWidth();
		if (buttonWidth > 0) {
			options += "," + "buttonWidth:'" + buttonWidth + "px'";
		}
		
		for (String event: menu.getJQueryEvents().keySet()) {
			String optionalParameterList="event";
			if (menu.getJQueryEventParameterLists()!=null) {
				if (menu.getJQueryEventParameterLists().get(event) != null) {
					optionalParameterList = menu.getJQueryEventParameterLists().get(event);
				}
			}
			StringBuilder code = new StringBuilder();
			AJAXRenderer.generateAJAXCallForASingleEvent(context, menu,
					null, code, null, null, true, 
					event, null, optionalParameterList);
			if (code.length()>0) {
				String result = menu.getJQueryEvents().get(event);
				result += ":";
				String realCode = code.toString().replace(".callAjax(this", ".callAjax(document.getElementById('" + clientId + "Inner')" );
				if (!realCode.startsWith("function")) {
					result += "function(" + optionalParameterList + ")";
					result += "{";
					result += realCode;
					result += "}";
				} else {  // backward compatibility to BootsFaces 1.0.0 and earlier
					result += realCode;
				}
				options += "," + result;
			}
		}


		if (options.length() > 0) {
			options = "{" + options.substring(1, options.length()) + "}";
		}
		String js = "$(document).ready(function() {$('#" + clientId + "Inner').multiselect(" + options + ");});\n";
		context.getResponseWriter().write("<script type='text/javascript'>\r\n" + js + "\r\n</script>");
	}
123246
protected void renderSpacerCell(FacesContext facesContext, ResponseWriter writer, UIComponent component)
        throws IOException 
    {
        UIComponent spacer = getNewspaperTableSpacer(component);
        if(spacer == null)
        {
            return;
        }
         
         writer.startElement(HTML.TD_ELEM, null); // component);
         //RendererUtils.renderChild(facesContext, spacer);
         spacer.encodeAll(facesContext);
         writer.endElement(HTML.TD_ELEM);
     }
658175
public static void renderUnhandledFacesMessages(FacesContext facesContext)
            throws IOException
    {
        // create and configure HtmlMessages component
        HtmlMessages messages = (HtmlMessages) facesContext.getApplication()
                .createComponent(HtmlMessages.COMPONENT_TYPE);
        messages.setId("javax_faces_developmentstage_messages");
        messages.setTitle("Project Stage[Development]: Unhandled Messages");
        messages.setStyle("color:orange");
        messages.setRedisplay(false);
        // render the component
        messages.encodeAll(facesContext);
    }
579721
public static String getImageSource(FacesContext context, UIComponent component) {
		Image image = (Image) component;
		ResourceHandler handler = context.getApplication().getResourceHandler();
		String resourceName = image.getName();
		String value = image.getValue();
		if (value != null && value.length() > 0) {
			if (resourceName != null && image.getLibrary() != null) {
				if (FacesContext.getCurrentInstance().isProjectStage(ProjectStage.Development)) {
					LOGGER.warning(
							"Please use either the 'value' attribute of b:image, or the 'name' and 'library' attribute pair. If all three attributes are provided, BootsFaces uses the 'value' attributes, ignoring both 'name' and 'library'.");
				}
			}
			if (handler.isResourceURL(value)) {
				return value;
			} else {
				value = context.getApplication().getViewHandler().getResourceURL(context, value);
				return (context.getExternalContext().encodeResourceURL(value));
			}
		}

		String library = image.getLibrary();
		Resource res = handler.createResource(resourceName, library);
		if (res == null) {
			if (context.isProjectStage(ProjectStage.Development)) {
				String msg = "Unable to find resource " + resourceName;
				FacesMessages.error(component.getClientId(context), msg, msg);
			}
			return "RES_NOT_FOUND";
		} else {
			return (context.getExternalContext().encodeResourceURL(res.getRequestPath()));
		}
	}
291167
public static void iconComponent(Component component, UiIcon icon)
	{
		component.add(AttributeModifier.append("class", "ui-icon " + icon.getCssClass()));
	}