use of org.alfresco.web.ui.common.component.UIImagePicker 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");
}
}
use of org.alfresco.web.ui.common.component.UIImagePicker in project acs-community-packaging by Alfresco.
the class ImagePickerRadioRenderer method encodeBegin.
/**
* @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
if (component.isRendered() == false) {
return;
}
// setup counters
this.columns = 1;
this.position = 0;
this.open = false;
this.imageSelected = false;
ResponseWriter out = context.getResponseWriter();
UIImagePicker imagePicker = (UIImagePicker) component;
Map attrs = imagePicker.getAttributes();
out.write("<table cellpadding='0'");
outputAttribute(out, attrs.get("spacing"), "cellspacing");
outputAttribute(out, attrs.get("styleClass"), "class");
outputAttribute(out, attrs.get("style"), "style");
out.write(">\n");
}
Aggregations