Search in sources :

Example 41 with ResponseWriter

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>&nbsp;");
                // 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>");
            }
        }
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) Iterator(java.util.Iterator) UIComponent(javax.faces.component.UIComponent)

Example 42 with ResponseWriter

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>
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter)

Example 43 with ResponseWriter

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);
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) IOException(java.io.IOException)

Example 44 with ResponseWriter

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);
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) ArrayList(java.util.ArrayList) UIComponent(javax.faces.component.UIComponent)

Example 45 with ResponseWriter

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>");
}
Also used : Cookie(javax.servlet.http.Cookie) ResponseWriter(javax.faces.context.ResponseWriter) ClientWindowConfig(org.apache.deltaspike.jsf.spi.scope.window.ClientWindowConfig) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Aggregations

ResponseWriter (javax.faces.context.ResponseWriter)88 Map (java.util.Map)16 UIComponent (javax.faces.component.UIComponent)14 FacesContext (javax.faces.context.FacesContext)14 NodeRef (org.alfresco.service.cmr.repository.NodeRef)13 ResourceBundle (java.util.ResourceBundle)10 NodeService (org.alfresco.service.cmr.repository.NodeService)10 Iterator (java.util.Iterator)9 IOException (java.io.IOException)7 HashMap (java.util.HashMap)7 List (java.util.List)7 TreeNode (org.alfresco.web.ui.repo.component.UITree.TreeNode)7 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)5 UserTransaction (javax.transaction.UserTransaction)5 UIModeList (org.alfresco.web.ui.common.component.UIModeList)5 Serializable (java.io.Serializable)4 Node (org.alfresco.web.bean.repository.Node)4 QuickSort (org.alfresco.web.data.QuickSort)3 UIListItem (org.alfresco.web.ui.common.component.UIListItem)3