Search in sources :

Example 76 with ResponseWriter

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

the class UISortLink method encodeBegin.

/**
 * @see javax.faces.component.UIComponent#encodeBegin(javax.faces.context.FacesContext)
 */
public void encodeBegin(FacesContext context) throws IOException {
    ResponseWriter out = context.getResponseWriter();
    IDataContainer dataContainer = getDataContainer();
    if (dataContainer == null) {
        throw new IllegalStateException("Must nest UISortLink inside component implementing IDataContainer!");
    }
    // swap sort direction if we were last sorted column
    boolean bPreviouslySorted = false;
    boolean descending = true;
    String lastSortedColumn = dataContainer.getCurrentSortColumn();
    if (lastSortedColumn != null && lastSortedColumn.equals(getValue())) {
        descending = !dataContainer.isCurrentSortDescending();
        bPreviouslySorted = true;
    }
    // render sort link
    StringBuilder buf = new StringBuilder(256);
    buf.append("<nobr><a href='#' onclick=\"");
    // generate some JavaScript to set a hidden form field and submit
    // a form which request attributes that we can decode
    buf.append(Utils.generateFormSubmit(context, this, getHiddenFieldName(context), getClientId(context)));
    buf.append('"');
    if (getAttributes().get("style") != null) {
        buf.append(" style=\"").append(getAttributes().get("style")).append('"');
    }
    if (getAttributes().get("styleClass") != null) {
        buf.append(" class=").append(getAttributes().get("styleClass"));
    }
    if (getAttributes().get("tooltip") != null) {
        buf.append(" title=\"").append(getAttributes().get("tooltip")).append('"');
    }
    buf.append('>');
    // output column label
    buf.append(Utils.encode((String) getAttributes().get("label")));
    if (bPreviouslySorted == true) {
        if (descending == true) {
            buf.append(" ").append(Utils.buildImageTag(context, WebResources.IMAGE_SORTUP, 10, 6, null));
        } else {
            buf.append(" ").append(Utils.buildImageTag(context, WebResources.IMAGE_SORTDOWN, 10, 6, null));
        }
    } else {
        buf.append(" ").append(Utils.buildImageTag(context, WebResources.IMAGE_SORTNONE, 10, 7, null));
    }
    buf.append("</a></nobr>");
    out.write(buf.toString());
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) IDataContainer(org.alfresco.web.data.IDataContainer)

Example 77 with ResponseWriter

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

the class UIDynamicDescription method encodeBegin.

/**
 * @see javax.faces.component.UIComponent#encodeBegin(javax.faces.context.FacesContext)
 */
public void encodeBegin(FacesContext context) throws IOException {
    if (this.isRendered() == false) {
        return;
    }
    // output the required JavaScript
    ResponseWriter out = context.getResponseWriter();
    out.write("<script language='JavaScript'>\n");
    out.write("var m_");
    out.write(getFunctionName());
    out.write(" = '");
    if (getSelected() != null) {
        out.write("desc-");
        out.write(getSelected());
    }
    out.write("';\n");
    out.write("function ");
    out.write(getFunctionName());
    out.write("(inputControl) {\n");
    out.write("if (m_");
    out.write(getFunctionName());
    out.write(" != '') {\n");
    out.write("   document.getElementById(m_");
    out.write(getFunctionName());
    out.write(").style.display = 'none';\n");
    out.write("}\nm_");
    out.write(getFunctionName());
    out.write(" = 'desc-' + inputControl.value;\n");
    out.write("document.getElementById(m_");
    out.write(getFunctionName());
    out.write(").style.display = 'inline';\n");
    out.write("} </script>\n");
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter)

Example 78 with ResponseWriter

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

the class UIDynamicDescription method renderDescription.

/**
 * Renders a description item
 *
 * @param context The faces context
 * @param controlId The id of the control the description is for
 * @param text The description text
 */
private void renderDescription(FacesContext context, String controlId, String text) throws IOException {
    ResponseWriter out = context.getResponseWriter();
    out.write("<span");
    String spanId = "desc-" + controlId;
    outputAttribute(out, spanId, "id");
    if (controlId.equals(this.selected)) {
        outputAttribute(out, "display: inline", "style");
    } else {
        outputAttribute(out, "display: none", "style");
    }
    out.write(">");
    out.write(Utils.encode(text));
    out.write("</span>\n");
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter)

Example 79 with ResponseWriter

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

the class BaseMultiValueRenderer method encodeBegin.

/**
 * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
 */
@SuppressWarnings("static-access")
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
    if (component.isRendered() == false) {
        return;
    }
    // reset the highlighted row flag
    this.highlightedRow = false;
    if (component instanceof UIMultiValueEditor) {
        ResponseWriter out = context.getResponseWriter();
        Map attrs = component.getAttributes();
        UIMultiValueEditor editor = (UIMultiValueEditor) component;
        // start outer table
        out.write("<table border='0' cellspacing='3' cellpadding='3'");
        this.outputAttribute(out, attrs.get("style"), "style");
        this.outputAttribute(out, attrs.get("styleClass"), "class");
        out.write(">");
        // render the area before the wrapped component
        renderPreWrappedComponent(context, out, editor);
    }
}
Also used : UIMultiValueEditor(org.alfresco.web.ui.repo.component.UIMultiValueEditor) ResponseWriter(javax.faces.context.ResponseWriter) Map(java.util.Map)

Example 80 with ResponseWriter

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

the class MultilingualTextAreaRenderer method encodeEnd.

@Override
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
    super.encodeEnd(facesContext, component);
    String tooltip = Application.getMessage(facesContext, "marker_tooltip");
    ResponseWriter out = facesContext.getResponseWriter();
    out.write("<img src='");
    out.write(facesContext.getExternalContext().getRequestContextPath());
    out.write("/images/icons/multilingual_marker.gif' title='");
    out.write(tooltip);
    out.write("' style='margin-left:6px; vertical-align:-2px;'>");
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter)

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