use of javax.faces.context.ResponseWriter 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");
}
use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class ModeListRenderer method encodeChildren.
/**
* @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
if (!component.isRendered()) {
return;
}
UIModeList list = (UIModeList) component;
ResponseWriter out = context.getResponseWriter();
// get the child components
for (Iterator i = list.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, list, item);
}
}
}
} else if (child instanceof UIListItem && child.isRendered()) {
// found a valid UIListItem child to render
renderItem(context, out, list, (UIListItem) child);
}
}
}
use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class ModeListRenderer 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;
}
UIModeList list = (UIModeList) component;
ResponseWriter out = context.getResponseWriter();
Map attrs = list.getAttributes();
if (!list.isMenu()) {
// start outer table container the list items
out.write("<table cellspacing='1' cellpadding='0'");
outputAttribute(out, attrs.get("styleClass"), "class");
outputAttribute(out, attrs.get("style"), "style");
outputAttribute(out, attrs.get("width"), "width");
out.write('>');
// horizontal rendering outputs a single row with each item as a column cell
if (list.isHorizontal()) {
out.write("<tr>");
}
// output title row if present
if (list.getLabel() != null) {
// first column contains an icon if present, second column contains text
if (!list.isHorizontal()) {
out.write("<tr>");
}
out.write("<td><table cellpadding='0' style='width:100%;'");
outputAttribute(out, attrs.get("itemSpacing"), "cellspacing");
out.write("><tr>");
// output icon column
if (list.getIconColumnWidth() != 0) {
out.write("<td style='width:");
out.write(String.valueOf(list.getIconColumnWidth()));
out.write("px'></td>");
}
// output title label
out.write("<td><span");
outputAttribute(out, attrs.get("labelStyle"), "style");
outputAttribute(out, attrs.get("labelStyleClass"), "class");
out.write('>');
out.write(Utils.encode(list.getLabel()));
out.write("</span></td></tr></table></td>");
if (!list.isHorizontal()) {
out.write("</tr>");
}
}
} else {
// render as a pop-up menu
// TODO: show the image set for the individual item if available?
out.write("<table cellspacing='0' cellpadding='0' style='white-space:nowrap'><tr>");
String selectedImage = (String) attrs.get("selectedImage");
if (selectedImage != null) {
out.write("<td style='padding-right:4px'>");
out.write(Utils.buildImageTag(context, selectedImage, null, "middle"));
out.write("</td>");
}
String menuId = UIMenu.getNextMenuId(list, context);
out.write("<td style='white-space: nowrap;'><a href='#' onclick=\"javascript:_toggleMenu(event, '");
out.write(menuId);
out.write("');return false;\">");
// use default label if available
String label = list.getLabel();
if (label == null || label.length() == 0) {
// else get the child components and walk to find the selected
for (Iterator i = list.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 selected render as the label
if (item.getValue().equals(list.getValue())) {
label = item.getLabel();
break;
}
}
}
} else if (child instanceof UIListItem && child.isRendered()) {
// found a valid UIListItem child to render
UIListItem item = (UIListItem) child;
// if selected render as the label
if (item.getValue().equals(list.getValue())) {
label = item.getLabel();
break;
}
}
}
}
// render the label
if (label != null && label.length() != 0) {
out.write("<span");
outputAttribute(out, attrs.get("labelStyle"), "style");
outputAttribute(out, attrs.get("labelStyleClass"), "class");
out.write('>');
out.write(Utils.encode(label));
out.write("</span> ");
}
// output image
if (list.getMenuImage() != null) {
out.write(Utils.buildImageTag(context, list.getMenuImage(), null, "-4px"));
}
out.write("</a></td></tr></table>");
// output the hidden DIV section to contain the menu item table
out.write("<div id='");
out.write(menuId);
out.write("' style='position:absolute;display:none;padding-left:2px;'>");
// start outer table container the list items
out.write("<table cellspacing='1' cellpadding='0'");
outputAttribute(out, attrs.get("styleClass"), "class");
outputAttribute(out, attrs.get("style"), "style");
outputAttribute(out, attrs.get("width"), "width");
out.write('>');
}
}
use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class RichListRenderer method encodeChildren.
/**
* @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
if (component.isRendered() == true) {
// the RichList component we are working with
UIRichList richList = (UIRichList) component;
// prepare the component current row against the current page settings
richList.bind();
// collect child column components so they can be passed to the renderer
List<UIColumn> columnList = new ArrayList<UIColumn>(8);
for (Iterator i = richList.getChildren().iterator(); i.hasNext(); ) /**/
{
UIComponent child = (UIComponent) i.next();
if (child instanceof UIColumn) {
columnList.add((UIColumn) child);
}
}
UIColumn[] columns = new UIColumn[columnList.size()];
columnList.toArray(columns);
// get the renderer instance
IRichListRenderer renderer = (IRichListRenderer) richList.getViewRenderer();
if (renderer == null) {
throw new IllegalStateException("IRichListRenderer must be available in UIRichList!");
}
// call render-before to output headers if required
ResponseWriter out = context.getResponseWriter();
out.write("<thead>");
renderer.renderListBefore(context, richList, columns);
out.write("</thead>");
out.write("<tbody>");
if (richList.isDataAvailable() == true) {
while (richList.isDataAvailable() == true) {
// render each row in turn
renderer.renderListRow(context, richList, columns, richList.nextRow());
}
} else {
// if no items present, render the facet with the "no items found" message
UIComponent emptyComponent = richList.getEmptyMessage();
if (emptyComponent != null) {
emptyComponent.encodeBegin(context);
emptyComponent.encodeChildren(context);
emptyComponent.encodeEnd(context);
}
}
// call render-after to output footers if required
renderer.renderListAfter(context, richList, columns);
out.write("</tbody>");
}
}
use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class RichListRenderer 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 {
// always check for this flag - as per the spec
if (component.isRendered() == true) {
ResponseWriter out = context.getResponseWriter();
out.write("</table>");
}
}
Aggregations