protected void encodeMarkup(FacesContext context, Organigram component) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        String clientId = component.getClientId(context);
        OrganigramNode root = component.getValue();
        Map<String, UIOrganigramNode> nodeMapping = lookupNodeMapping(component);

        // checks if a node is currently selected to render the node as selected later
        boolean selectionEnabled = component.getValueExpression("selection") != null;
        OrganigramNode selection = null;

        if (selectionEnabled) {
            selection = component.getSelection();
            if (selection != null) {
                // check if selected node still exists
                OrganigramNode node = OrganigramHelper.findTreeNode(component.getValue(), selection);
                if (node == null) {
                    // reset selection
                    selection = null;
                    assignSelection(context, component, null);
                }
            }
        }

        if (root != null) {
            if (root.getRowKey() == null) {
                root.setRowKey("root");
            }

            OrganigramHelper.buildRowKeys(root);
        }

        // render container
        String styleClass = "ui-widget ui-organigram";
        if (component.getStyleClass() != null) {
            styleClass += " " + component.getStyleClass();
        }

        writer.startElement("div", component);
        writer.writeAttribute("id", clientId, null);
        writer.writeAttribute("class", styleClass, null);
        if (component.getStyle() != null) {
            writer.writeAttribute("style", component.getStyle(), null);
        }

        // render target container
        writer.startElement("div", null);
        writer.writeAttribute("id", clientId + "_target", null);
        writer.writeAttribute("class", "target", null);
        writer.endElement("div");

        // render source container
        writer.startElement("ul", null);
        writer.writeAttribute("id", clientId + "_source", null);

        renderNode(context, writer, nodeMapping, component, root, selection, selectionEnabled);

        writer.endElement("ul");
        writer.endElement("div");
    }
Checks if the current request is a selection request and
assigns the found {@link OrganigramNode} to the <code>selection</code> value expression.

@param context    The current {@link FacesContext}.
@param component The {@link Organigram} component.
primefaces/src/main/java/org/primefaces/component/organigram/OrganigramRenderer.java