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());
}
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");
}
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");
}
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);
}
}
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;'>");
}
Aggregations