use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class UIMenu method encodeEnd.
/**
* @see javax.faces.component.UIComponentBase#encodeEnd(javax.faces.context.FacesContext)
*/
public void encodeEnd(FacesContext context) throws IOException {
if (!isRendered()) {
return;
}
ResponseWriter out = context.getResponseWriter();
// end the menu table and the hidden DIV section
out.write("</table></div>");
}
use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class UISelectList method encodeBegin.
/**
* @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
*/
public void encodeBegin(FacesContext context) throws IOException {
if (!isRendered()) {
return;
}
// Prepare the data-binding variable "var" ready for the each cycle of
// renderering for the child components.
String var = (String) getAttributes().get("var");
Map requestMap = context.getExternalContext().getRequestMap();
ResponseWriter out = context.getResponseWriter();
out.write("<table cellspacing=0 cellpadding=0");
String style = (String) getAttributes().get("style");
if (style != null) {
out.write(" style='");
out.write(style);
out.write('\'');
}
String styleClass = (String) getAttributes().get("styleClass");
if (styleClass != null) {
out.write(" class=");
out.write(styleClass);
}
out.write('>');
// get the child components and look for compatible ListItem objects
this.itemCount = 0;
setRowIndex(-1);
for (final UIComponent child : (List<UIComponent>) this.getChildren()) {
if (child instanceof UIListItems) {
// get the value of the list items component and iterate through it's collection
Object listItems = ((UIListItems) child).getValue();
if (listItems instanceof Collection) {
for (final UIListItem item : (Collection<UIListItem>) listItems) {
if (item.isRendered()) {
if (var != null) {
requestMap.put(var, item);
}
setRowIndex(this.itemCount);
renderItem(context, out, item);
}
this.itemCount++;
}
}
} else if (child instanceof UIListItem) {
if (child.isRendered()) {
// found a valid UIListItem child to render
UIListItem item = (UIListItem) child;
if (var != null) {
requestMap.put(var, item);
}
setRowIndex(this.itemCount);
renderItem(context, out, item);
}
this.itemCount++;
}
}
setRowIndex(-1);
if (var != null) {
requestMap.remove(var);
}
out.write("</table>");
}
use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class UIStatusMessage method encodeBegin.
/**
* @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
*/
public void encodeBegin(FacesContext context) throws IOException {
if (!isRendered()) {
return;
}
ResponseWriter out = context.getResponseWriter();
String bgColor = getBgcolor();
if (bgColor == null) {
bgColor = PanelGenerator.BGCOLOR_WHITE;
}
String panel = getBorder();
if (panel != null) {
PanelGenerator.generatePanelStart(out, context.getExternalContext().getRequestContextPath(), panel, bgColor);
}
// Previous Message icon image - clicking shows previous message
out.write("<table style'width:100%;' cellspacing='0' cellpadding='0'><tr><td>");
String field = getHiddenFieldName();
String leftValue = getClientId(context) + NamingContainer.SEPARATOR_CHAR + Integer.toString(ACTION_PREVIOUS);
String leftOnclick = Utils.generateFormSubmit(context, this, field, leftValue);
out.write(Utils.buildImageTag(context, WebResources.IMAGE_MOVELEFT, 12, 12, null, leftOnclick, "middle"));
out.write("</td><td style='width:100%;' align='center'>");
// get messages for the component and crop the stack to the maximum history size
Iterator<FacesMessage> msgIterator = context.getMessages(STATUS_MESSAGE);
while (msgIterator.hasNext()) {
if (messages.size() >= HISTORY_SIZE) {
messages.remove(HISTORY_SIZE);
}
// add new messages to the stack in turn
messages.add(0, msgIterator.next());
// reset current message to top if new one added
currentMessage = 0;
}
// TODO: show different icon depending on SEVERITY of the message?
// Message text
String style = CSS_ERROR;
String icon = WebResources.IMAGE_INFO;
FacesMessage msg = messages.get(currentMessage);
if (msg.getSeverity() == FacesMessage.SEVERITY_INFO) {
style = CSS_INFO;
} else if (msg.getSeverity() == FacesMessage.SEVERITY_WARN) {
style = CSS_WARNING;
}
out.write(Utils.buildImageTag(context, icon, null, "middle"));
out.write(" <span class='");
out.write(style);
out.write("'>");
out.write(Utils.encode(msg.getSummary()));
out.write(" - ");
out.write(Utils.encode(msg.getDetail()));
out.write("</span>");
out.write("</td><td>");
// Next Message icon image - clicking shows next message
String rightValue = getClientId(context) + NamingContainer.SEPARATOR_CHAR + Integer.toString(ACTION_NEXT);
String rightOnclick = Utils.generateFormSubmit(context, this, field, rightValue);
out.write(Utils.buildImageTag(context, WebResources.IMAGE_MOVERIGHT, 12, 12, null, rightOnclick, "middle"));
out.write("</td></tr></table>");
if (panel != null) {
PanelGenerator.generatePanelEnd(out, context.getExternalContext().getRequestContextPath(), panel);
}
}
use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class UploadInput method encodeBegin.
public void encodeBegin(FacesContext context) throws IOException {
ResponseWriter writer = context.getResponseWriter();
String contextPath = context.getExternalContext().getRequestContextPath();
String path = Application.inPortalServer() ? AlfrescoFacesPortlet.getResourceURL(context, "/uploadFileServlet") : contextPath + "/uploadFileServlet";
writer.write("<script type='text/javascript' src='");
writer.write(contextPath);
writer.write("/scripts/upload_helper.js'></script>\n");
writer.write("<script type='text/javascript'>");
writer.write("function handle_upload(target)\n");
writer.write("{\n");
writer.write("handle_upload_helper(target, '', upload_complete, '" + path + "', '')\n");
writer.write("}\n");
writer.write("function upload_complete(id, path, filename)\n");
writer.write("{\n");
writer.write("var schema_file_input = document.getElementById('" + framework + ":" + framework + "-body:" + getId() + "');\n");
writer.write("schema_file_input.value = filename;\n");
writer.write("schema_file_input.form.submit();\n");
writer.write("}\n");
writer.write("</script>\n");
super.encodeBegin(context);
writer.write("\n<input id='" + framework + ":" + framework + "-body:file-input' contentEditable='false' type='file' size='35' name='alfFileInput' onchange='javascript:handle_upload(this)'/>");
}
use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class ImagePickerRadioRenderer method encodeChildren.
/**
* @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
@SuppressWarnings("unchecked")
public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
if (component.isRendered() == false) {
return;
}
UIImagePicker imagePicker = (UIImagePicker) component;
Map attrs = imagePicker.getAttributes();
Integer cols = (Integer) attrs.get("columns");
if (cols != null && cols instanceof Integer) {
this.columns = cols.intValue();
}
// retrieve the onclick handler, if there is one
String onclick = (String) attrs.get("onclick");
ResponseWriter out = context.getResponseWriter();
// determine whether the options should be pulled from config or
// from the child components
String configSection = (String) attrs.get("configSection");
if (configSection != null && configSection.length() > 0) {
// render all the icons from the list that appear in the given
// config section
ConfigService cfgService = Application.getConfigService(context);
Config cfg = cfgService.getConfig(configSection);
if (cfg != null) {
ConfigElement iconsCfg = cfg.getConfigElement("icons");
if (iconsCfg != null) {
for (ConfigElement icon : iconsCfg.getChildren()) {
String iconName = icon.getAttribute("name");
String iconPath = icon.getAttribute("path");
if (iconName != null && iconPath != null) {
UIListItem item = new UIListItem();
item.setValue(iconName);
item.setImage(iconPath);
renderItem(context, out, imagePicker, item, onclick);
}
}
}
}
} else {
try {
// get the child components
for (Iterator i = imagePicker.getChildren().iterator(); i.hasNext(); ) /**/
{
UIComponent child = (UIComponent) i.next();
if (child instanceof UIListItems) {
// get the value of the list items component and iterate
// through it's collection
Object listItems = ((UIListItems) child).getValue();
if (listItems instanceof Collection) {
Iterator iter = ((Collection) listItems).iterator();
while (iter.hasNext()) {
UIListItem item = (UIListItem) iter.next();
if (item.isRendered()) {
renderItem(context, out, imagePicker, item, onclick);
}
}
}
} else if (child instanceof UIListItem && child.isRendered() == true) {
// found a valid UIListItem child to render
UIListItem item = (UIListItem) child;
renderItem(context, out, imagePicker, item, onclick);
}
}
} catch (PropertyNotFoundException pnfe) {
// method specified in the value binding expression
if (logger.isWarnEnabled())
logger.warn("Failed to retrieve icons: " + pnfe.toString());
out.write(Application.getMessage(context, "no_icons_found"));
}
}
// if we are in the middle of a row, close it
if (open) {
out.write("</tr>\n");
}
}
Aggregations