use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class UIShelf method encodeChildren.
/**
* @see javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
*/
public void encodeChildren(FacesContext context) throws IOException {
if (isRendered() == false) {
return;
}
ResponseWriter out = context.getResponseWriter();
// output each shelf group in turn
int index = 0;
for (Iterator i = this.getChildren().iterator(); i.hasNext(); index++) {
UIComponent child = (UIComponent) i.next();
if (child instanceof UIShelfGroup) {
UIShelfGroup group = (UIShelfGroup) child;
if (group.isRendered() == true) {
// output the surrounding structure then call the component to render itself and children
// TODO: get this from Shelf or ShelfGroup?
boolean isExpanded = group.isExpanded();
out.write("<tr><td>");
String contextPath = context.getExternalContext().getRequestContextPath();
// output appropriate panel start section and bgcolor
String groupPanel;
String groupBgcolor;
if (isExpanded == false) {
groupPanel = getGroupPanel();
groupBgcolor = getGroupBgcolor();
} else {
groupPanel = getSelectedGroupPanel();
groupBgcolor = getSelectedGroupBgcolor();
}
if (groupBgcolor == null) {
groupBgcolor = PanelGenerator.BGCOLOR_WHITE;
}
if (groupPanel != null) {
PanelGenerator.generatePanelStart(out, contextPath, groupPanel, groupBgcolor);
}
// output appropriate expanded icon state
out.write("<div style='padding-top:2px;padding-bottom:4px'><nobr>");
out.write("<a href='#' onclick=\"");
// encode value as the index of the ShelfGroup clicked and the new state
String value = Integer.toString(index) + NamingContainer.SEPARATOR_CHAR + Boolean.toString(!isExpanded);
out.write(Utils.generateFormSubmit(context, this, getHiddenFieldName(), value));
out.write("\">");
if (isExpanded == true) {
out.write(Utils.buildImageTag(context, WebResources.IMAGE_EXPANDED, 11, 11, ""));
} else {
out.write(Utils.buildImageTag(context, WebResources.IMAGE_COLLAPSED, 11, 11, ""));
}
out.write("</a> ");
// output title label text
String label = group.getLabel();
out.write("<span");
outputAttribute(out, group.getAttributes().get("style"), "style");
outputAttribute(out, group.getAttributes().get("styleClass"), "class");
out.write('>');
out.write(Utils.encode(label));
out.write("</span>");
out.write("</nobr></div>");
if (isExpanded == true) {
// if this is the expanded group, output the inner panel
String innerGroupPanel = getInnerGroupPanel();
String innerGroupBgcolor = getInnerGroupBgcolor();
if (innerGroupBgcolor == null) {
innerGroupBgcolor = PanelGenerator.BGCOLOR_WHITE;
}
if (innerGroupPanel != null) {
PanelGenerator.generatePanelStart(out, contextPath, innerGroupPanel, innerGroupBgcolor);
}
// allow child components to render themselves
Utils.encodeRecursive(context, group);
if (innerGroupPanel != null) {
PanelGenerator.generatePanelEnd(out, contextPath, innerGroupPanel);
}
}
// output panel and group end elements
PanelGenerator.generatePanelEnd(out, contextPath, groupPanel);
out.write("</td></tr>");
}
}
}
}
use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.
the class SeparatorRenderer 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;
}
ResponseWriter out = context.getResponseWriter();
int count = component.getChildCount();
if (count == 1) {
// there should be 3 columns so write out a td with colspan of 3
// then render the child component
out.write("<td colspan='3'>");
Utils.encodeRecursive(context, (UIComponent) component.getChildren().get(0));
// NOTE: we'll allow the property sheet's grid renderer close off the last <td>
}
}
use of javax.faces.context.ResponseWriter in project vaadin-jsf-integration by alejandro-du.
the class VaadinComponent method encodeBegin.
@Override
public void encodeBegin(FacesContext facesContext) throws IOException {
ResponseWriter writer = facesContext.getResponseWriter();
try {
String template = getTemplate();
String html = setVariables(template);
writer.write(html);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of javax.faces.context.ResponseWriter in project muikku by otavanopisto.
the class WidgetSpaceSetComponent method encodeBegin.
@Override
public void encodeBegin(FacesContext context) throws IOException {
int spaceLeft = GRID_SIZE;
ResponseWriter writer = context.getResponseWriter();
String styleClass = (String) getAttributes().get("styleClass");
String parentStyleClass = (String) getAttributes().get("parentStyleClass");
List<WidgetSpaceComponent> widgetSpaces = getWidgetSpaces();
List<WidgetSpaceComponent> maximizeWidgetSpaces = new ArrayList<>();
writer.startElement("div", this);
writer.writeAttribute("class", parentStyleClass, "class");
for (WidgetSpaceComponent widgetSpace : widgetSpaces) {
List<WidgetComponent> widgets = getWidgetComponents(widgetSpace);
widgetSpace.setEmpty(widgets.size() == 0);
if (widgetSpace.getStyleClass() == null)
widgetSpace.setStyleClass(styleClass);
if (widgetSpace.getSizing() != WidgetSpaceSizingStrategy.MAXIMIZE) {
int size = 0;
for (UIComponent widgetComponent : widgets) {
if (widgetComponent instanceof WidgetComponent) {
WidgetComponent widget = (WidgetComponent) widgetComponent;
if (widget.isRendered()) {
switch(widgetSpace.getSizing()) {
case MINIMIZE:
if (widget.getSize() > size) {
size = widget.getSize();
}
break;
case SUM:
size += widget.getSize();
break;
default:
break;
}
}
}
}
widgetSpace.setSize(size);
spaceLeft -= size;
} else {
maximizeWidgetSpaces.add(widgetSpace);
}
}
for (WidgetSpaceComponent widgetSpace : maximizeWidgetSpaces) {
widgetSpace.setSize(spaceLeft / maximizeWidgetSpaces.size());
}
super.encodeBegin(context);
}
use of javax.faces.context.ResponseWriter in project deltaspike by apache.
the class WindowIdHtmlRenderer method encodeBegin.
/**
* 'deltaspikeJsWindowId' will be used to:
* Write a simple hidden field into the form.
* This might change in the future...
* @param context
* @param component
* @throws IOException
*/
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
super.encodeBegin(context, component);
lazyInit();
ClientWindowConfig.ClientWindowRenderMode clientWindowRenderMode = clientWindowConfig.getClientWindowRenderMode(context);
// see DELTASPIKE-1113
boolean delegatedWindowMode = ClientWindowConfig.ClientWindowRenderMode.DELEGATED.equals(clientWindowRenderMode);
if (delegatedWindowMode) {
return;
}
String windowId = clientWindow.getWindowId(context);
// just to get sure if a user provides a own client window
windowId = secureWindowId(windowId);
ResponseWriter writer = context.getResponseWriter();
writer.write("<script type=\"text/javascript\">");
writer.write("(function(){");
writer.write("dswh.init('" + windowId + "','" + clientWindowRenderMode.name() + "'," + maxWindowIdLength + ",{");
writer.write("'tokenizedRedirect':" + clientWindowConfig.isClientWindowTokenizedRedirectEnabled());
writer.write(",'storeWindowTreeOnLinkClick':" + clientWindowConfig.isClientWindowStoreWindowTreeEnabledOnLinkClick());
writer.write(",'storeWindowTreeOnButtonClick':" + clientWindowConfig.isClientWindowStoreWindowTreeEnabledOnButtonClick());
// see #729
if (clientWindow.isInitialRedirectSupported(context)) {
Object cookie = ClientWindowHelper.getRequestWindowIdCookie(context, windowId);
if (cookie != null && cookie instanceof Cookie) {
Cookie servletCookie = (Cookie) cookie;
writer.write(",'initialRedirectWindowId':'" + secureWindowId(servletCookie.getValue()) + "'");
// expire/remove cookie
servletCookie.setMaxAge(0);
((HttpServletResponse) context.getExternalContext().getResponse()).addCookie(servletCookie);
}
}
writer.write("});");
writer.write("})();");
writer.write("</script>");
}
Aggregations