Search in sources :

Example 31 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class RichListRenderer method encodeBegin.

// ------------------------------------------------------------------------------
// Renderer implemenation
/**
 * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
 */
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
    // always check for this flag - as per the spec
    if (component.isRendered() == true) {
        ResponseWriter out = context.getResponseWriter();
        Map attrs = component.getAttributes();
        out.write("<table cellspacing=0 cellpadding=0");
        outputAttribute(out, attrs.get("styleClass"), "class");
        outputAttribute(out, attrs.get("style"), "style");
        outputAttribute(out, attrs.get("width"), "width");
        out.write(">");
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) Map(java.util.Map)

Example 32 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class UIMenu 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();
    // output a textual label with an optional icon to show the menu
    String menuId = getNextMenuId(this, context);
    out.write("<a href='#' onclick=\"javascript:_toggleMenu(event, '");
    out.write(menuId);
    out.write("');return false;\"");
    outputAttribute(out, getAttributes().get("style"), "style");
    outputAttribute(out, getAttributes().get("styleClass"), "class");
    outputAttribute(out, getTooltip(), "title");
    out.write('>');
    // output label text
    String label = getLabel();
    if (label != null) {
        out.write(Utils.encode(label));
    }
    // output image
    if (getAttributes().get("image") != null) {
        out.write(Utils.buildImageTag(context, (String) getAttributes().get("image"), tooltip, "-4px"));
    }
    out.write("</a>");
    // output the hidden DIV section to contain the menu item table
    out.write("<br><div id='");
    out.write(menuId);
    // NOTE: the use of "*width:0px" is an IE6/7 specific hack to ensure that the CSS is processed
    // only by IE (which needs the width value) and _not_ FireFox which doesn't...!
    // Changed the width to "auto" to support IE 10, see MNT-10027
    out.write("' style=\"position:absolute;display:none;padding-left:2px;*width:auto\">");
    out.write("<table border='0' cellpadding='0'");
    outputAttribute(out, getAttributes().get("itemSpacing"), "cellspacing");
    outputAttribute(out, getAttributes().get("menuStyle"), "style");
    outputAttribute(out, getAttributes().get("menuStyleClass"), "class");
    out.write(">");
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter)

Example 33 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class UIOutputText method encodeBegin.

/**
 * @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
 */
public void encodeBegin(FacesContext context) throws IOException {
    if (isRendered() == false) {
        return;
    }
    Object value = getValue();
    if (value != null) {
        Converter converter = getConverter();
        if (converter != null) {
            value = converter.getAsString(context, this, value);
        }
        ResponseWriter out = context.getResponseWriter();
        if (isEncodeForJavaScript()) {
            out.write(URLEncoder.encode((String) getValue()));
        } else {
            String style = (String) getAttributes().get("style");
            String styleClass = (String) getAttributes().get("styleClass");
            if (style != null || styleClass != null) {
                out.write("<span");
                if (style != null) {
                    out.write(" style='");
                    out.write(style);
                    out.write('\'');
                }
                if (styleClass != null) {
                    out.write(" class=");
                    out.write(styleClass);
                }
                out.write('>');
                out.write(Utils.encode(value.toString()));
                out.write("</span>");
            } else {
                out.write(Utils.encode(value.toString()));
            }
        }
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) Converter(javax.faces.convert.Converter)

Example 34 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class UIPanel method encodeBegin.

/**
 * @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
 */
public void encodeBegin(FacesContext context) throws IOException {
    if (isRendered() == false) {
        return;
    }
    ResponseWriter out = context.getResponseWriter();
    // determine if we have a component on the header
    UIComponent titleComponent = getTitleComponent();
    // determine whether we have any adornments
    String label = getLabel();
    if (label != null) {
        label = Utils.encode(label);
    }
    if (label != null || isProgressive() == true || titleComponent != null) {
        this.hasAdornments = true;
    }
    // make sure we have a default background color for the content area
    String bgcolor = getBgcolor();
    if (bgcolor == null) {
        bgcolor = PanelGenerator.BGCOLOR_WHITE;
    }
    // the content area border defined as well
    if (getTitleBgcolor() != null && getTitleBorder() != null && getBorder() != null && this.hasAdornments) {
        this.hasBorderedTitleArea = true;
    }
    // output first part of border table
    if (this.hasBorderedTitleArea) {
        PanelGenerator.generatePanelStart(out, context.getExternalContext().getRequestContextPath(), getTitleBorder(), getTitleBgcolor());
    } else if (getBorder() != null) {
        PanelGenerator.generatePanelStart(out, context.getExternalContext().getRequestContextPath(), getBorder(), bgcolor);
    }
    if (this.hasAdornments) {
        // start the containing table if we have any adornments
        out.write("<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr><td>");
    }
    // TODO: manage state of this icon via component Id!
    if (isProgressive() == true) {
        out.write("<a href='#' onclick=\"");
        String value = getClientId(context) + NamingContainer.SEPARATOR_CHAR + Boolean.toString(!isExpanded());
        out.write(Utils.generateFormSubmit(context, this, getHiddenFieldName(context), value));
        out.write("\">");
        if (isExpanded() == true) {
            out.write(Utils.buildImageTag(context, WebResources.IMAGE_EXPANDED, 11, 11, getLabel()));
        } else {
            out.write(Utils.buildImageTag(context, WebResources.IMAGE_COLLAPSED, 11, 11, getLabel()));
        }
        out.write("</a>&nbsp;&nbsp;");
    }
    // output textual label
    if (label != null) {
        out.write("<span");
        Utils.outputAttribute(out, getAttributes().get("style"), "style");
        Utils.outputAttribute(out, getAttributes().get("styleClass"), "class");
        out.write('>');
        // already encoded above
        out.write(label);
        out.write("</span>");
    }
    if (this.hasAdornments) {
        out.write("</td>");
    }
    // render the title component if supplied
    if (titleComponent != null) {
        out.write("<td align='right'>");
        Utils.encodeRecursive(context, titleComponent);
        out.write("</td>");
    }
    if (this.hasAdornments) {
        out.write("</tr></table>");
    }
    // if we have the titled border area, output the middle section
    if (this.hasBorderedTitleArea && isExpanded()) {
        if (getExpandedTitleBorder() != null) {
            PanelGenerator.generateExpandedTitledPanelMiddle(out, context.getExternalContext().getRequestContextPath(), getTitleBorder(), getExpandedTitleBorder(), getBorder(), getBgcolor());
        } else {
            PanelGenerator.generateTitledPanelMiddle(out, context.getExternalContext().getRequestContextPath(), getTitleBorder(), getBorder(), getBgcolor());
        }
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) UIComponent(javax.faces.component.UIComponent)

Example 35 with ResponseWriter

use of javax.faces.context.ResponseWriter in project acs-community-packaging by Alfresco.

the class UIDataPager method encodeBegin.

// ------------------------------------------------------------------------------
// Component implementation
/**
 * @see javax.faces.component.UIComponent#encodeBegin(javax.faces.context.FacesContext)
 */
public void encodeBegin(FacesContext context) throws IOException {
    IDataContainer dataContainer = getDataContainer();
    if (dataContainer == null) {
        throw new IllegalStateException("Must nest UISortLink inside component implementing IDataContainer!");
    }
    // with a valid "pageSize" property
    if (isRendered() == false || dataContainer.getPageSize() == -1) {
        return;
    }
    final String formClientId = Utils.getParentForm(context, this).getClientId(context);
    final String pageInputId = getPageInputId();
    final String hiddenFieldName = getHiddenFieldName();
    ResponseWriter out = context.getResponseWriter();
    ResourceBundle bundle = Application.getBundle(context);
    StringBuilder buf = new StringBuilder(512);
    int currentPage = dataContainer.getCurrentPage();
    int pageCount = dataContainer.getPageCount();
    Object displayInput = getAttributes().get("displayInput");
    String beginTag = "<span";
    String endTag = "</span>";
    String divStyle = "";
    String inputStyle = "height:13px;";
    String imageVericalAlign = null;
    String imageStyle = "margin-top:0px;";
    StringBuilder inputPageNumber = new StringBuilder(128);
    if (displayInput != null && ((Boolean) displayInput) == false) {
        imageStyle = null;
        inputPageNumber.append(currentPage + 1);
    } else {
        final boolean isIE = Utils.USER_AGENT_MSIE.equals(Utils.getUserAgent(context));
        if (isIE) {
            beginTag = "<div";
            endTag = "</div>";
            divStyle = "padding:1px;";
            inputStyle = "height:13px; vertical-align:middle;";
            imageVericalAlign = "middle";
            imageStyle = "margin-top:0px;";
            inputPageNumber.append("<input type=\"text\" maxlength=\"3\" value=\"").append(currentPage + 1).append("\" style=\"width: 24px; margin-left: 4px;").append(inputStyle).append("\" ");
            inputPageNumber.append("onkeydown=\"").append(generateIE6InputOnkeydownScript(pageInputId, formClientId, hiddenFieldName)).append("\" ");
            inputPageNumber.append("id=\"").append(pageInputId).append("\" />");
        } else {
            inputPageNumber.append("<input type=\"text\" maxlength=\"3\" value=\"").append(currentPage + 1).append("\" style=\"width: 24px; margin-left: 4px;").append(inputStyle).append("\" ");
            inputPageNumber.append("onkeypress=\"").append(generateInputOnkeyPressScript(pageInputId, formClientId, hiddenFieldName)).append("\" ");
            inputPageNumber.append("onkeydown=\"").append(generateInputOnkeydownScript()).append("\" ");
            inputPageNumber.append("id=\"").append(pageInputId).append("\" />");
        }
    }
    buf.append(beginTag);
    if (getAttributes().get("style") != null) {
        buf.append(" style=\"").append(getAttributes().get("style")).append(divStyle).append('"');
    }
    if (getAttributes().get("styleClass") != null) {
        buf.append(" class=").append(getAttributes().get("styleClass"));
    }
    buf.append('>');
    // output Page X of Y text
    buf.append(MessageFormat.format(bundle.getString(MSG_PAGEINFO), new Object[] { // current page can be zero if no data present
    inputPageNumber.toString(), Integer.toString(pageCount) }));
    buf.append("&nbsp;&nbsp;");
    // first page
    if (currentPage != 0) {
        buf.append("<a href='#' onclick=\"");
        buf.append(generateEventScript(0, hiddenFieldName));
        buf.append("\">");
        buf.append(Utils.buildImageTag(context, WebResources.IMAGE_FIRSTPAGE, 16, 16, bundle.getString(FIRST_PAGE), null, imageVericalAlign, imageStyle));
        buf.append("</a>");
    } else {
        buf.append(Utils.buildImageTag(context, WebResources.IMAGE_FIRSTPAGE_NONE, 16, 16, null, null, imageVericalAlign, imageStyle));
    }
    buf.append("&nbsp;");
    // previous page
    if (currentPage != 0) {
        buf.append("<a href='#' onclick=\"");
        buf.append(generateEventScript(currentPage - 1, hiddenFieldName));
        buf.append("\">");
        buf.append(Utils.buildImageTag(context, WebResources.IMAGE_PREVIOUSPAGE, 16, 16, bundle.getString(PREVIOUS_PAGE), null, imageVericalAlign, imageStyle));
        buf.append("</a>");
    } else {
        buf.append(Utils.buildImageTag(context, WebResources.IMAGE_PREVIOUSPAGE_NONE, 16, 16, null, null, imageVericalAlign, imageStyle));
    }
    buf.append("&nbsp;");
    Object objType = getAttributes().get("dataPagerType");
    PagerType type = PagerType.TRACKPAGE;
    if (objType instanceof String) {
        try {
            type = PagerType.valueOf((String) objType);
        } catch (Throwable ex) {
            s_logger.warn("DataPager id:" + this.getId() + " with incorrect 'numberPageType' attribute");
        }
    }
    switch(type) {
        case STANDARD:
            encodeType0(buf, currentPage, pageCount);
            break;
        case DECADES:
            encodeType1(buf, currentPage, pageCount);
            break;
        case TRACKPAGE:
            encodeType2(buf, currentPage, pageCount);
            break;
        default:
            encodeType2(buf, currentPage, pageCount);
    }
    // next page
    if ((dataContainer.getCurrentPage() < dataContainer.getPageCount() - 1) == true) {
        buf.append("<a href='#' onclick=\"");
        buf.append(generateEventScript(currentPage + 1, hiddenFieldName));
        buf.append("\">");
        buf.append(Utils.buildImageTag(context, WebResources.IMAGE_NEXTPAGE, 16, 16, bundle.getString(NEXT_PAGE), null, imageVericalAlign, imageStyle));
        buf.append("</a>");
    } else {
        buf.append(Utils.buildImageTag(context, WebResources.IMAGE_NEXTPAGE_NONE, 16, 16, null, null, imageVericalAlign, imageStyle));
    }
    buf.append("&nbsp;");
    // last page
    if ((dataContainer.getCurrentPage() < dataContainer.getPageCount() - 1) == true) {
        buf.append("<a href='#' onclick=\"");
        buf.append(generateEventScript(dataContainer.getPageCount() - 1, hiddenFieldName));
        buf.append("\">");
        buf.append(Utils.buildImageTag(context, WebResources.IMAGE_LASTPAGE, 16, 16, bundle.getString(LAST_PAGE), null, imageVericalAlign, imageStyle));
        buf.append("</a>");
    } else {
        buf.append(Utils.buildImageTag(context, WebResources.IMAGE_LASTPAGE_NONE, 16, 16, null, null, imageVericalAlign, imageStyle));
    }
    buf.append(endTag);
    out.write(buf.toString());
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) IDataContainer(org.alfresco.web.data.IDataContainer) ResourceBundle(java.util.ResourceBundle)

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