Search in sources :

Example 36 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class BaseDebugComponent method encodeBegin.

/**
 * @see javax.faces.component.UIComponent#encodeBegin(javax.faces.context.FacesContext)
 */
public void encodeBegin(FacesContext context) throws IOException {
    if (isRendered() == false) {
        return;
    }
    ResponseWriter out = context.getResponseWriter();
    out.write("<table cellpadding='2' cellspacing='2' border='0' style='border: 1px solid #aaaaaa;border-collapse: collapse;border-spacing: 0px;'>");
    if (this.getTitle() != null) {
        out.write("<tr><td colspan='2'>");
        out.write(this.getTitle());
        out.write("</td></tr>");
    }
    out.write("<tr style='border: 1px solid #dddddd;'><th align='left'>");
    out.write(Application.getMessage(context, COMPONENT_PROPERTY));
    out.write("</th><th align='left'>");
    out.write(Application.getMessage(context, COMPONENT_VALUE));
    out.write("</th></tr>");
    Map session = getDebugData();
    for (Object key : session.keySet()) {
        out.write("<tr style='border: 1px solid #dddddd;'><td>");
        out.write(Utils.encode(key.toString()));
        out.write("</td><td>");
        Object obj = session.get(key);
        if (obj == null) {
            out.write("null");
        } else {
            String value = obj.toString();
            if (value.length() == 0) {
                out.write("&nbsp;");
            } else {
                // replace any ; characters with ;<space> as that will help break up long lines
                value = value.replaceAll(";", "; ");
                out.write(Utils.encode(value));
            }
        }
        out.write("</td></tr>");
    }
    out.write("</table>");
    super.encodeBegin(context);
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) Map(java.util.Map)

Example 37 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class BaseMultiValueRenderer method encodeEnd.

/**
 * @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
 */
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
    if (component.isRendered() == false) {
        return;
    }
    if (component instanceof UIMultiValueEditor) {
        ResponseWriter out = context.getResponseWriter();
        UIMultiValueEditor editor = (UIMultiValueEditor) component;
        // get hold of the node service
        NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
        // render the area between the component and current items list
        renderPostWrappedComponent(context, out, editor);
        // show the currently selected items
        out.write("<tr><td style='padding-top:8px'>");
        out.write(editor.getSelectedItemsMsg());
        out.write("</td></tr>");
        out.write("<tr><td><table cellspacing='0' cellpadding='2' border='0' class='selectedItems'>");
        out.write("<tr><td colspan='2' class='selectedItemsHeader'>");
        out.write(Application.getMessage(context, "name"));
        out.write("</td></tr>");
        List currentItems = (List) editor.getValue();
        ;
        if (currentItems != null && currentItems.size() > 0) {
            for (int x = 0; x < currentItems.size(); x++) {
                Object obj = currentItems.get(x);
                if (obj != null) {
                    if (obj instanceof NodeRef) {
                        if (nodeService.exists((NodeRef) obj)) {
                            renderExistingItem(context, component, out, nodeService, x, obj);
                        } else {
                            // remove invalid NodeRefs from the list
                            currentItems.remove(x);
                        }
                    } else {
                        renderExistingItem(context, component, out, nodeService, x, obj);
                    }
                }
            }
        } else {
            out.write("<tr><td class='selectedItemsRow'>");
            out.write(editor.getNoSelectedItemsMsg());
            out.write("</td></tr>");
        }
        // close tables
        out.write("</table></td></tr></table>\n");
        // output a hidden field containing the current value
        out.write("<input type='hidden' id='");
        out.write(component.getClientId(context));
        out.write("_current_value");
        out.write("' name='");
        out.write(component.getClientId(context));
        out.write("_current_value");
        out.write("' value='");
        if (currentItems != null && currentItems.size() > 0) {
            out.write(currentItems.toString());
        }
        out.write("' />");
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) UIMultiValueEditor(org.alfresco.web.ui.repo.component.UIMultiValueEditor) ResponseWriter(javax.faces.context.ResponseWriter) NodeService(org.alfresco.service.cmr.repository.NodeService) List(java.util.List)

Example 38 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class YahooTreeRenderer method encodeBegin.

@SuppressWarnings("unchecked")
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
    // get the root nodes
    UITree tree = (UITree) component;
    List<TreeNode> rootNodes = tree.getRootNodes();
    if (rootNodes != null && rootNodes.size() > 0) {
        ResponseWriter out = context.getResponseWriter();
        String treeContainerId = component.getClientId(context) + "Container";
        // write out the JavaScript specific to the Tree component,
        // make sure it's only done once
        Object present = context.getExternalContext().getRequestMap().get(TREE_SCRIPTS_WRITTEN);
        if (present == null) {
            String reqPath = context.getExternalContext().getRequestContextPath();
            out.write("<link rel=\"stylesheet\" href=\"");
            out.write(reqPath);
            out.write("/css/yahoo-tree.css\" type=\"text/css\">");
            out.write("<script type=\"text/javascript\" src=\"");
            out.write(reqPath);
            out.write("/scripts/ajax/yahoo/treeview/treeview-min.js\"></script>");
            out.write("<script type=\"text/javascript\" src=\"");
            out.write(reqPath);
            out.write("/scripts/ajax/yahoo-tree.js\"></script>");
            context.getExternalContext().getRequestMap().put(TREE_SCRIPTS_WRITTEN, Boolean.TRUE);
        }
        // output the div container for the tree
        out.write("<div id=\"");
        out.write(treeContainerId);
        out.write("\"></div>\n");
        // generate the startup
        out.write("<script type=\"text/javascript\">\n");
        out.write("var tree;\n");
        if (tree.getRetrieveChildrenUrl() != null) {
            out.write("setLoadDataUrl('");
            out.write(tree.getRetrieveChildrenUrl());
            out.write("');\n");
        }
        if (tree.getNodeCollapsedUrl() != null) {
            out.write("setCollapseUrl('");
            out.write(tree.getNodeCollapsedUrl());
            out.write("');\n");
        }
        if (tree.getNodeSelectedCallback() != null) {
            out.write("setNodeSelectedHandler('");
            out.write(tree.getNodeSelectedCallback());
            out.write("');\n");
        }
        out.write("function initTree() {\n");
        out.write("      tree = new YAHOO.widget.TreeView(\"");
        out.write(treeContainerId);
        out.write("\");\n");
        out.write("      var root = tree.getRoot();\n");
        if (tree.getNodeExpandedCallback() != null) {
            out.write("      tree.subscribe('expand', ");
            out.write(tree.getNodeExpandedCallback());
            out.write(");\n");
        }
        if (tree.getNodeCollapsedCallback() != null) {
            out.write("      tree.subscribe('collapse', ");
            out.write(tree.getNodeCollapsedCallback());
            out.write(");\n");
        }
        // generate script for each root node
        this.nodeCounter = 0;
        for (TreeNode node : rootNodes) {
            generateNode(node, out, null);
        }
        out.write("      tree.draw();\n");
        out.write("      tree.setDynamicLoad(loadDataForNode);\n}\n");
        out.write("YAHOO.util.Event.on(window, \"load\", window.initTree);");
        out.write("</script>\n");
    } else if (logger.isDebugEnabled()) {
        logger.debug("There weren't any nodes to render");
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) TreeNode(org.alfresco.web.ui.repo.component.UITree.TreeNode) UITree(org.alfresco.web.ui.repo.component.UITree)

Example 39 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class UIShelf method encodeEnd.

/**
 * @see javax.faces.component.UIComponentBase#encodeEnd(javax.faces.context.FacesContext)
 */
public void encodeEnd(FacesContext context) throws IOException {
    if (isRendered() == false) {
        return;
    }
    ResponseWriter out = context.getResponseWriter();
    out.write("</table></div>");
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter)

Example 40 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class UIShelf method encodeBegin.

/**
 * @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
 */
public void encodeBegin(FacesContext context) throws IOException {
    if (isRendered() == false) {
        return;
    }
    ResponseWriter out = context.getResponseWriter();
    out.write("<div id=\"shelf\" class=\"shelf\">");
    out.write("<table border=\"0\" cellspacing=\"4\" cellpadding=\"0\" width=\"100%\">");
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter)

Aggregations

ResponseWriter (javax.faces.context.ResponseWriter)88 Map (java.util.Map)16 UIComponent (javax.faces.component.UIComponent)14 FacesContext (javax.faces.context.FacesContext)14 NodeRef (org.alfresco.service.cmr.repository.NodeRef)13 ResourceBundle (java.util.ResourceBundle)10 NodeService (org.alfresco.service.cmr.repository.NodeService)10 Iterator (java.util.Iterator)9 IOException (java.io.IOException)7 HashMap (java.util.HashMap)7 List (java.util.List)7 TreeNode (org.alfresco.web.ui.repo.component.UITree.TreeNode)7 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)5 UserTransaction (javax.transaction.UserTransaction)5 UIModeList (org.alfresco.web.ui.common.component.UIModeList)5 Serializable (java.io.Serializable)4 Node (org.alfresco.web.bean.repository.Node)4 QuickSort (org.alfresco.web.data.QuickSort)3 UIListItem (org.alfresco.web.ui.common.component.UIListItem)3