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(" ");
} 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);
}
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("' />");
}
}
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");
}
}
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>");
}
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%\">");
}
Aggregations