use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class UINodeInfo method encodeBegin.
@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
if (!isRendered())
return;
// if AJAX is disabled don't render anything
if (Application.getClientConfig(context).isNodeSummaryEnabled()) {
ResponseWriter out = context.getResponseWriter();
outputNodeInfoScripts(context, out);
// wrap the child components in a <span> that has the onmouseover
// event which kicks off the request for node information
// we key the node info panel by the noderef string of the current node
String noderef = Repository.getStoreRef().toString() + '/' + (String) this.getValue();
out.write("<span onclick=\"AlfNodeInfoMgr.toggle('");
out.write(noderef);
out.write("',this);\">");
}
}
use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class UIOpenSearch method encodeBegin.
@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
if (!isRendered())
return;
ResponseWriter out = context.getResponseWriter();
List<OpenSearchEngine> engines = getRegisteredEngines(context);
if (engines != null && engines.size() == 0) {
out.write(Application.getMessage(context, "no_engines_registered"));
return;
}
String clientId = this.getId();
// write out the JavaScript specific to the OpenSearch component,
// make sure it's only done once
Object present = context.getExternalContext().getRequestMap().get(SCRIPTS_WRITTEN);
if (present == null) {
out.write("<link rel=\"stylesheet\" href=\"");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/css/opensearch.css\" type=\"text/css\">");
out.write("<script type=\"text/javascript\" src=\"");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/scripts/ajax/opensearch.js\"></script>");
context.getExternalContext().getRequestMap().put(SCRIPTS_WRITTEN, Boolean.TRUE);
}
// we use summary info panel pop-ups so need scripts for that object
UINodeInfo.outputNodeInfoScripts(context, out);
// write out the javascript initialisation required
out.write("<script type='text/javascript'>\n");
out.write("var ");
out.write(clientId);
out.write(" = new Alfresco.OpenSearchClient('");
out.write(clientId);
out.write("');\n");
// ADB-133: Synchronizing lengths of search fields
final Integer searchMinimum = Application.getClientConfig(FacesContext.getCurrentInstance()).getSearchMinimum();
// register the engines on the client
for (OpenSearchEngine engine : engines) {
out.write(clientId);
out.write(".registerOpenSearchEngine('");
out.write(engine.getId());
out.write("', '");
out.write(engine.getLabel());
out.write("', '");
out.write(engine.getUrl());
out.write("', ");
out.write(searchMinimum.toString());
out.write(");\n");
}
// pass in NLS strings
out.write(clientId);
out.write(".setMsgNoResults(\"");
out.write(Application.getMessage(context, "no_results"));
out.write("\");\n");
out.write(clientId);
out.write(".setMsgOf(\"");
out.write(Application.getMessage(context, "of"));
out.write("\");\n");
out.write(clientId);
out.write(".setMsgFailedGenerateUrl(\"");
out.write(Application.getMessage(context, "failed_gen_url"));
out.write("\");\n");
out.write(clientId);
out.write(".setMsgFailedSearch(\"");
out.write(Application.getMessage(context, "failed_search"));
out.write("\");\n");
out.write(clientId);
out.write(".setMsgFirstPage(\"");
out.write(Application.getMessage(context, "first_page"));
out.write("\");\n");
out.write(clientId);
out.write(".setMsgPreviousPage(\"");
out.write(Application.getMessage(context, "prev_page"));
out.write("\");\n");
out.write(clientId);
out.write(".setMsgNextPage(\"");
out.write(Application.getMessage(context, "next_page"));
out.write("\");\n");
out.write(clientId);
out.write(".setMsgLastPage(\"");
out.write(Application.getMessage(context, "last_page"));
out.write("\");\n");
out.write(clientId);
out.write(".setMsgInvalidTermLength(\"");
out.write(Application.getMessage(context, "search_minimum"));
out.write("\");\n");
out.write("</script>\n");
// write out the HTML
String styleClass = (String) this.getAttributes().get("styleClass");
String style = (String) this.getAttributes().get("style");
if (styleClass != null || style != null) {
out.write("<div");
if (styleClass != null && styleClass.length() > 0) {
out.write(" class='");
out.write(styleClass);
out.write("'");
}
if (style != null && style.length() > 0) {
out.write(" style='");
out.write(style);
out.write("'");
}
out.write(">\n");
}
out.write("<div class='osPanel'><div class='osControls'>");
out.write("<table border='0' cellpadding='2' cellspacing='0'><tr>");
out.write("<td><input id='");
out.write(clientId);
out.write("-search-term' name='");
out.write(clientId);
out.write("-search-term' type='text' size='30' onkeyup='return ");
out.write(clientId);
out.write(".handleKeyPress(event);' />");
out.write("</td><td><img src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/images/icons/search_icon.gif' style='cursor:pointer' onclick='");
out.write(clientId);
out.write(".executeQuery()' title='");
out.write(Application.getMessage(context, "search"));
out.write("' /></td></tr></table>\n");
out.write("<table border='0' cellpadding='2' cellspacing='0' style='margin-top: 2px;'><tr><td><img src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/images/icons/expanded.gif' style='cursor:pointer' onclick='");
out.write(clientId);
out.write(".toggleOptions(this)' class='expanded' title='");
out.write(Application.getMessage(context, "toggle_options"));
out.write("' /></td><td><img src='");
out.write(context.getExternalContext().getRequestContextPath());
out.write("/images/icons/opensearch_controls.gif' /></td><td>");
out.write(Application.getMessage(context, "options"));
out.write("</td></tr></table>\n");
out.write("<div id='");
out.write(clientId);
out.write("-os-options' class='osOptions'>");
out.write(Application.getMessage(context, "show"));
out.write("<input id='");
out.write(clientId);
out.write("-page-size' name='");
out.write(clientId);
out.write("-page-size' type='text' value='5' style='width: 25px; margin-left: 5px; margin-right: 5px;' />");
out.write(Application.getMessage(context, "items_per_page"));
out.write("<div style='margin-top: 6px; margin-bottom: 4px;'>");
out.write(Application.getMessage(context, "search_in"));
out.write(":</div><table border='0' cellpadding='2' cellspacing='0'>");
for (OpenSearchEngine engine : engines) {
out.write("<tr><td><input id='");
out.write(clientId);
out.write("-");
out.write(engine.getId());
out.write("-engine-enabled' name='");
out.write(clientId);
out.write("-");
out.write(engine.getId());
out.write("-engine-enabled' type='checkbox' checked='checked' />");
out.write("</td><td>");
out.write(Utils.encode(engine.getLabel()));
out.write("</td></tr>");
}
out.write("</table></div></div>\n");
out.write("<div id='");
out.write(clientId);
out.write("-os-results'></div>\n</div>\n");
if (styleClass != null || style != null) {
out.write("</div>\n");
}
}
use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class UIShortcutsShelfItem 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();
List<Node> items = (List<Node>) getValue();
out.write(SHELF_START);
if (items != null) {
DictionaryService dd = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getDictionaryService();
for (int i = 0; i < items.size(); i++) {
Node item = items.get(i);
out.write("<tr><td width=16>");
if (dd.isSubClass(item.getType(), ContentModel.TYPE_FOLDER)) {
// start row with correct node icon
String icon = (String) item.getProperties().get("app:icon");
if (icon != null) {
icon = "/images/icons/" + icon + "-16.gif";
} else {
icon = WebResources.IMAGE_SPACE;
}
out.write(Utils.buildImageTag(context, icon, 16, 16, null, null, "absmiddle"));
} else if (dd.isSubClass(item.getType(), ContentModel.TYPE_CONTENT)) {
String image = FileTypeImageUtils.getFileTypeImage(item.getName(), true);
out.write(Utils.buildImageTag(context, image, null, "absmiddle"));
}
// output cropped item label - we also output with no breaks, this is ok
// as the copped label will ensure a sensible maximum width
out.write("</td><td width=100%><nobr> ");
out.write(buildActionLink(ACTION_CLICK_ITEM, i, item.getName()));
// output actions
out.write("</nobr></td><td align=right><nobr>");
out.write(buildActionLink(ACTION_REMOVE_ITEM, i, Application.getMessage(context, MSG_REMOVE_ITEM), WebResources.IMAGE_REMOVE));
// TODO: add view details action here?
// end actions cell and end row
out.write("</nobr></td></tr>");
}
}
out.write(SHELF_END);
}
use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class UIClipboardShelfItem 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();
List<ClipboardItem> items = getCollections();
out.write(SHELF_START);
if (items.size() != 0) {
DictionaryService dd = Repository.getServiceRegistry(context).getDictionaryService();
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
ResourceBundle bundle = Application.getBundle(context);
for (int i = 0; i < items.size(); i++) {
ClipboardItem item = items.get(i);
// check that the item has not been deleted since added to the clipboard
if (nodeService.exists(item.getNodeRef()) == false) {
// remove from clipboard
items.remove(i--);
continue;
}
// start row with cut/copy state icon
out.write("<tr><td width=16>");
if (item.getMode() == ClipboardStatus.COPY) {
out.write(Utils.buildImageTag(context, WebResources.IMAGE_COPY, 14, 16, bundle.getString(MSG_COPY), null, "absmiddle"));
} else {
out.write(Utils.buildImageTag(context, WebResources.IMAGE_CUT, 13, 16, bundle.getString(MSG_CUT), null, "absmiddle"));
}
out.write("</td><td width=16>");
boolean isFolder = (dd.isSubClass(item.getType(), ContentModel.TYPE_FOLDER));
if (isFolder) {
// start row with correct node icon
String icon = (String) item.getIcon();
if (icon != null) {
icon = "/images/icons/" + icon + "-16.gif";
} else {
icon = WebResources.IMAGE_SPACE;
}
out.write(Utils.buildImageTag(context, icon, 16, 16, null, null, "absmiddle"));
} else {
String image = FileTypeImageUtils.getFileTypeImage(item.getName(), true);
out.write(Utils.buildImageTag(context, image, null, "absmiddle"));
}
// output cropped item label - we also output with no breaks, this is ok
// as the copped label will ensure a sensible maximum width
out.write("</td><td width=100%><nobr> ");
if (isFolder) {
out.write(Utils.cropEncode(item.getName()));
} else {
// output as a content download link
out.write("<a href='");
out.write(context.getExternalContext().getRequestContextPath());
out.write(generateBrowserURL(dd, nodeService, item));
out.write("' target='new'>");
out.write(Utils.cropEncode(item.getName()));
out.write("</a>");
}
// output actions
out.write("</nobr></td><td align=right><nobr>");
out.write(buildActionLink(ACTION_REMOVE_ITEM, i, bundle.getString(MSG_REMOVE_ITEM), WebResources.IMAGE_REMOVE));
out.write(" ");
out.write(buildActionLink(ACTION_PASTE_ITEM, i, bundle.getString(MSG_PASTE_ITEM), WebResources.IMAGE_PASTE));
if (item.supportsLink() && item.getMode() == ClipboardStatus.COPY && dd.isSubClass(item.getType(), ContentModel.TYPE_LINK) == false) {
out.write(" ");
out.write(buildActionLink(ACTION_PASTE_LINK, i, bundle.getString(MSG_PASTE_LINK), WebResources.IMAGE_PASTE_LINK));
}
// end actions cell and end row
out.write("</nobr></td></tr>");
}
// output general actions if any clipboard items are present
out.write("<tr><td colspan=4 style='padding-top:3px' align='center'><nobr>");
out.write(buildActionLink(ACTION_PASTE_ALL, -1, bundle.getString(MSG_PASTE_ALL), null));
out.write(" | ");
out.write(buildActionLink(ACTION_REMOVE_ALL, -1, bundle.getString(MSG_REMOVE_ALL), null));
out.write("</nobr></td><td></td></tr>");
}
out.write(SHELF_END);
}
use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class UIRecentSpacesShelfItem 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();
List<Node> items = (List<Node>) getValue();
out.write(SHELF_START);
for (int i = 0; i < items.size(); i++) {
Node item = items.get(i);
// start row with correct node icon
out.write("<tr><td width=16>");
String icon = (String) item.getProperties().get("app:icon");
if (icon != null) {
icon = "/images/icons/" + icon + "-16.gif";
} else {
icon = WebResources.IMAGE_SPACE;
}
out.write(Utils.buildImageTag(context, icon, 16, 16, null, null, "absmiddle"));
// output cropped item label - we also output with no breaks, this is ok
// as the copped label will ensure a sensible maximum width
out.write("</td><td width=100%><nobr> ");
out.write(buildActionLink(ACTION_NAVIGATE_ITEM, i, item.getName()));
// end actions cell and end row
out.write("</nobr></td></tr>");
}
out.write(SHELF_END);
}
Aggregations