Java Code Examples for javax.faces.context.ResponseWriter#writeText()

The following examples show how to use javax.faces.context.ResponseWriter#writeText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OneUIv302PagerSizesRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void writerStartText(FacesContext context, ResponseWriter w, UIPagerSizes pager, FacesDataIterator dataIterator, String text, int pos) throws IOException {
     if(-1 != pos) {
         text = text.substring(0,pos);
     }// else, output entire text at start when {0} absent
     if(StringUtil.isNotEmpty(text)) {
         String tag = (String)getProperty(PROP_ITEMTAG);
         if(StringUtil.isNotEmpty(tag)) {
             w.startElement(tag, null);
             String style = (String)getProperty(PROP_FIRSTSTYLE);
             if(StringUtil.isNotEmpty(style)) {
                 w.writeAttribute("style", style,null); // $NON-NLS-1$
             }
             String styleClass = (String)getProperty(PROP_FIRSTCLASS);
             if(StringUtil.isNotEmpty(styleClass)) {
                 w.writeAttribute("class", styleClass,null); // $NON-NLS-1$
             }
             w.writeAttribute("role", "presentation", null); // $NON-NLS-1$ $NON-NLS-2$
         }
         w.writeText(text,null);
         if(StringUtil.isNotEmpty(tag)) {
             w.endElement(tag);
         }
     }
 }
 
Example 2
Source File: SelectMultiMenuRenderer.java    From BootsFaces-OSP with Apache License 2.0 6 votes vote down vote up
/**
 * Renders the optional label. This method is protected in order to allow
 * third-party frameworks to derive from it.
 *
 * @param rw
 *            the response writer
 * @param clientId
 *            the id used by the label to refernce the input field
 * @throws IOException
 *             may be thrown by the response writer
 */
protected void addLabel(ResponseWriter rw, String clientId, SelectMultiMenu menu) throws IOException {
	String label = menu.getLabel();
	if (!menu.isRenderLabel()) {
           label = null;
       }
	if (label != null) {
		rw.startElement("label", menu);
		rw.writeAttribute("for", clientId, "for");
                       
                       generateErrorAndRequiredClass(menu, rw, clientId, menu.getLabelStyleClass(), Responsive.getResponsiveLabelClass(menu), "control-label");
                       
		//generateErrorAndRequiredClassForLabels(menu, rw, clientId, "control-label " + menu.getLabelStyleClass());
		writeAttribute(rw, "style", menu.getLabelStyle());
		rw.writeText(label, null);
		rw.endElement("label");
	}
}
 
Example 3
Source File: NavigationMapRenderer.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Write one link
 * @param writer the writer for output
 * @param component the component
 * @param text the text of the link
 * @param link the context relative url, or script
 * @param path the context path
 * @throws IOException
 */
private void writeLink(ResponseWriter writer, UIComponent component,
  String text, String link, String path, String styleClass) throws IOException
{
  writer.write(" ");
  writer.startElement("a", component);
  // if javascript create onclick handler, else regular link
  if (link.toLowerCase().startsWith("javascript"))
  {
    writer.writeAttribute("href", "#", null);
    writer.writeAttribute("onclick", link, null);
  }
  else
  {
    writer.writeAttribute("href", path  + "/" + link, null);
  }

  if (styleClass != null)
  {
    writer.writeAttribute("class", styleClass, "styleClass");
  }
  writer.writeText(text, null);
  writer.endElement("a");
  writer.write(" ");
}
 
Example 4
Source File: OneUIv302BreadCrumbsRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void preRenderList(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException {
    writer.startElement("nav", null); // $NON-NLS-1$
    writer.writeAttribute("role", "navigation", null); // $NON-NLS-1$ $NON-NLS-2$
    writer.writeAttribute("aria-label", "Breadcrumbs", null);//$NON-NLS-1$ // $NLS-OneUIv302BreadCrumbsRenderer_Breadcrumbs_IndicationOfCurrentNavigationLocation-2$
    
    String style = getContainerStyle(tree);
    if(StringUtil.isNotEmpty(style)) {
        writer.writeAttribute("style",style,null); // $NON-NLS-1$
    }
    String styleClass = ExtLibUtil.concatStyleClasses((String)getProperty(PROP_BREADCRUMBS_CONTAINER),getContainerStyleClass(tree));
    if(StringUtil.isNotEmpty(styleClass)) {
        writer.writeAttribute("class",styleClass,null); // $NON-NLS-1$
    }
    
    UIComponent c = tree.getComponent();
    if(c instanceof UIOutlineBreadCrumbs) {
        String text = ((UIOutlineBreadCrumbs)c).getLabel(); 
        if(StringUtil.isNotEmpty(text)) {
            writer.writeText(text, null);
        }
    }
}
 
Example 5
Source File: PagerSizesRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
protected void writerEndText(FacesContext context, ResponseWriter w, UIPagerSizes pager, FacesDataIterator dataIterator, String text, int pos) throws IOException {
    if(-1 != pos) {
        text = text.substring(pos+3);
    } else {
        // do not output end text when {0} absent
        return;
    }
    if(StringUtil.isNotEmpty(text)) {
        String tag = (String)getProperty(PROP_ITEMTAG);
        if(StringUtil.isNotEmpty(tag)) {
            w.startElement(tag, null);
            String style = (String)getProperty(PROP_LASTSTYLE);
            if(StringUtil.isNotEmpty(style)) {
                w.writeAttribute("style", style,null); // $NON-NLS-1$
            }
            String styleClass = (String)getProperty(PROP_LASTCLASS);
            if(StringUtil.isNotEmpty(styleClass)) {
                w.writeAttribute("class", styleClass,null); // $NON-NLS-1$
            }
        }
        w.writeText(text,null);
        if(StringUtil.isNotEmpty(tag)) {
            w.endElement(tag);
        }
    }
}
 
Example 6
Source File: HtmlComboBoxRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void renderNode(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException {
    // Generate a regular node
    boolean leaf = tree.getNode().getType()==ITreeNode.NODE_LEAF;
    if(leaf) {
        String label = tree.getNode().getLabel();
        String value = tree.getNode().getSubmitValue();
        writer.startElement("option", null); // $NON-NLS-1$
        if(StringUtil.isNotEmpty(value)) {
            writer.writeAttribute("value",value,null); // $NON-NLS-1$
        }
        boolean enabled = tree.getNode().isEnabled();
        if(!enabled) {
            writer.writeAttribute("disabled", "disabled", "disabled"); // $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
        }
        boolean selected = tree.getNode().isSelected();
        if(selected) {
            writer.writeAttribute("selected", "selected", "selected"); // $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
        }
        writer.writeText(label,"label"); // $NON-NLS-1$
        writer.endElement("option"); // $NON-NLS-1$
        JSUtil.writeln(writer);
    }
}
 
Example 7
Source File: PagerRenderer.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/** Output an HTML drop-down select */
private static void writeSelect(ResponseWriter out, boolean render, String selectId, String[] optionTexts, String[] optionValues, String selectedValue, String onchangeHandler)
	throws IOException
{
	if (!render) return;
	
	out.startElement("select", null);
	out.writeAttribute("name", selectId, null);
	out.writeAttribute("id", selectId, null);
	out.writeAttribute("onchange", onchangeHandler, null);
	out.write("\n");
	for (int i=0; i<optionValues.length; i++)
	{
		String optionText = optionTexts[i];
		String optionValue = optionValues[i];
		out.startElement("option", null);
		if (optionValue.equals(selectedValue)) out.writeAttribute("selected", "selected", null);
		out.writeAttribute("value", optionValue, null);
		out.writeText(optionText, null);
		out.endElement("option");
		out.write("\n");
	}
	out.endElement("select");
	out.write("\n");
}
 
Example 8
Source File: FormTableRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void writeWarnMessage(FacesContext context, ResponseWriter w, FormLayout c, String msg) throws IOException {
    w.startElement("div", c); // $NON-NLS-1$
    String style = (String)getProperty(PROP_WARNIMGSTYLE);
    if(StringUtil.isNotEmpty(style)) {
        w.writeAttribute("style", style, null); // $NON-NLS-1$
    }
    String cls = (String)getProperty(PROP_WARNIMGCLASS);
    if(StringUtil.isNotEmpty(cls)) {
        w.writeAttribute("class", cls, null); // $NON-NLS-1$
    }
    String alt = (String)getProperty(PROP_WARNIMGALT);
    if(StringUtil.isNotEmpty(alt)) {
        w.writeAttribute("aria-label", alt, null); // $NON-NLS-1$
    }
    w.endElement("div"); // $NON-NLS-1$
    
    if( StringUtil.isNotEmpty(msg) ){
        w.writeText(msg, null);
    }
}
 
Example 9
Source File: PagerRenderer.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/** Output an HTML button */
private static void writeButton(ResponseWriter out, boolean render, String name, String label, boolean disabled, String title, String accesskey) throws IOException {
    if (!render) return;

    //SAK-22812 wrap each button with a fieldset and legend, for accessibility
    out.startElement("fieldset", null);
    out.startElement("legend", null);
    out.writeText(title, null);
    out.endElement("legend");

    out.startElement("input", null);
    out.writeAttribute("type", "submit", null);
    out.writeAttribute("name", name, null);
    out.writeAttribute("value", label, null);
    // TODO: i18n
    if (!disabled) {
        out.writeAttribute("title", title, null);
        if (accesskey != null) out.writeAttribute("accesskey", accesskey, null);
        //out.writeAttribute("onclick", "javascript:this.form.submit(); return false;", null);
    } else {
        out.writeAttribute("disabled", "disabled", null);
    }
    out.endElement("input");
    out.endElement("fieldset");
    out.write("\n");
}
 
Example 10
Source File: PagerSizesRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
protected void writerStartText(FacesContext context, ResponseWriter w, UIPagerSizes pager, FacesDataIterator dataIterator, String text, int pos) throws IOException {
    if(-1 != pos) {
        text = text.substring(0,pos);
    }// else, output entire text at start when {0} absent
    if(StringUtil.isNotEmpty(text)) {
        String tag = (String)getProperty(PROP_ITEMTAG);
        if(StringUtil.isNotEmpty(tag)) {
            w.startElement(tag, null);
            String style = (String)getProperty(PROP_FIRSTSTYLE);
            if(StringUtil.isNotEmpty(style)) {
                w.writeAttribute("style", style,null); // $NON-NLS-1$
            }
            String styleClass = (String)getProperty(PROP_FIRSTCLASS);
            if(StringUtil.isNotEmpty(styleClass)) {
                w.writeAttribute("class", styleClass,null); // $NON-NLS-1$
            }
        }
        w.writeText(text,null);
        if(StringUtil.isNotEmpty(tag)) {
            w.endElement(tag);
        }
    }
}
 
Example 11
Source File: OneUIv302WidgetDropDownRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
protected void renderPopupButton(FacesContext context, ResponseWriter writer, TreeContextImpl tree, boolean enabled, boolean selected) throws IOException {
    writer.startElement("a",null);
    // A popup button requires an id
    String clientId = tree.getClientId(context,"ab",1); // $NON-NLS-1$
    if(StringUtil.isNotEmpty(clientId)) {
        writer.writeAttribute("id", clientId, null); // $NON-NLS-1$
    }
    writer.writeAttribute("class","lotusIcon lotusActionIcon",null); // $NON-NLS-1$ $NON-NLS-2$
    writer.writeAttribute("href", "javascript:;", null); // $NON-NLS-1$ $NON-NLS-2$
    // "Click for actions"
    String buttonTitle = com.ibm.xsp.extlib.controls.ResourceHandler.getString("DropDownButtonRenderer.Clickforactions"); // $NON-NLS-1$
    writer.writeAttribute("title", buttonTitle, null); // $NON-NLS-1$
    writer.writeAttribute("aria-haspopup","true",null); // $NON-NLS-1$ $NON-NLS-2$
    writer.startElement("img",null); // $NON-NLS-1$
    writer.writeAttribute("src", HtmlRendererUtil.getImageURL(context,OneUIResources.get().BLANK_GIF), null); // $NON-NLS-1$
    writer.writeAttribute("alt","",null); // $NON-NLS-1$
    writer.writeAttribute("aria-owns",clientId,null); // $NON-NLS-1$ $NON-NLS-2$
    writer.endElement("img"); // $NON-NLS-1$
    writer.startElement("span",null); // $NON-NLS-1$
    writer.writeAttribute("class","lotusAltText",null); // $NON-NLS-1$ $NON-NLS-2$
    // "Actions"
    String buttonText = com.ibm.xsp.extlib.controls.ResourceHandler.getString("DropDownButtonRenderer.Actions"); // $NON-NLS-1$
    writer.writeText(buttonText, null);
    writer.endElement("span"); // $NON-NLS-1$
    writer.endElement("a");
    JSUtil.writeln(writer);
}
 
Example 12
Source File: WidgetContainerRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void writeBodyScrollUpAltText(FacesContext context, ResponseWriter w, UIWidgetContainer c) throws IOException {
    String alt = (String)getProperty(PROP_CSSSCROLLUPALTTEXT);
    if(StringUtil.isNotEmpty(alt)) {
        w.startElement("span", c); // $NON-NLS-1$
        w.writeAttribute("class", "lotusAltText", null); //$NON-NLS-1$ //$NON-NLS-2$
        w.writeText(alt, "\u25B2"); //$NON-NLS-1$
        w.endElement("span"); // $NON-NLS-1$
    }
}
 
Example 13
Source File: FormLayoutRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void writeWarnMessage(FacesContext context, ResponseWriter w, FormLayout c, String msg) throws IOException {
    w.startElement("img", c); // $NON-NLS-1$
    String style = (String)getProperty(PROP_WARNIMGSTYLE);
    if(StringUtil.isNotEmpty(style)) {
        w.writeAttribute("style", style, null); // $NON-NLS-1$
    }
    String cls = (String)getProperty(PROP_WARNIMGCLASS);
    if(StringUtil.isNotEmpty(cls)) {
        w.writeAttribute("class", cls, null); // $NON-NLS-1$
    }
    String bgif = (String)getProperty(PROP_WARNIMGSRC);
    if(StringUtil.isNotEmpty(bgif)) {
        w.writeAttribute("src",HtmlRendererUtil.getImageURL(context,bgif),null); // $NON-NLS-1$
    }
    String alt = (String)getProperty(PROP_WARNIMGALT);
    if(StringUtil.isNotEmpty(alt)) {
        w.writeAttribute("alt", alt, null); // $NON-NLS-1$
    }
    w.endElement("img"); // $NON-NLS-1$

    String altText = (String)getProperty(PROP_WARNMSGALTTEXT);
    if(StringUtil.isNotEmpty(altText)) {
        w.startElement("span", c); // $NON-NLS-1$
        String altClass = (String)getProperty(PROP_WARNMSGALTTEXTCLASS);
        if(StringUtil.isNotEmpty(altClass)) {
            w.writeAttribute("class", altClass, null); // $NON-NLS-1$
        }
        w.writeText(altText, null);
        w.endElement("span"); // $NON-NLS-1$
    }
    
    JSUtil.writeTextBlank(w); // &nbsp;
    if( StringUtil.isNotEmpty(msg) ){
        w.writeText(msg, null);
    }
}
 
Example 14
Source File: LinksListRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void writePopupImage(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException {
    // Render the popup image (down arrow) if the link has children
    if(tree.getNode().getType()!=ITreeNode.NODE_LEAF) {
        // a space and Unicode Character 'BLACK DOWN-POINTING TRIANGLE' 
        writer.writeText(" \u25BC", null); //$NON-NLS-1$
        //writer.writeText(" \u02C5", null);
    }
}
 
Example 15
Source File: GoogleSearch.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
private void renderLink(ResponseWriter writer, UIComponent component, String value) throws IOException {
    writer.startElement("a", component);
    String lk = "http://www.google.com/search?q="+value; // $NON-NLS-1$
    writer.writeURIAttribute("href", lk, null); // $NON-NLS-1$
    writer.writeAttribute("target", "_blank", null); // $NON-NLS-1$ $NON-NLS-2$
    writer.writeAttribute("title", "Google search link", null); // $NON-NLS-1$ $NLS-GoogleSearch.Googlesearchlink-2$
    if(null != value && StringUtil.isNotEmpty(value)) {
        writer.writeText(value, null);
    }else{
        writer.writeAttribute("style", "display:none", null); // $NON-NLS-1$ $NON-NLS-2$
    }
    writer.endElement("a");
}
 
Example 16
Source File: CarouselRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public void writeSlideButton(FacesContext context, ResponseWriter w, UICarousel c, SlideNode slide, String buttonText) throws IOException {
    if(StringUtil.isNotEmpty(buttonText)) {
        String buttonHref  = slide.getButtonHref();
        String buttonStyle  = slide.getButtonStyle();
        String buttonClass  = slide.getButtonStyleClass();

        // write button container
        String contTag = (String)getProperty(PROP_SLIDE_BTN_CONTAINER_TAG);
        w.startElement(contTag, c);
        w.writeAttribute("class", (String)getProperty(PROP_SLIDE_BTN_CONTAINER_CLASS), null); // $NON-NLS-1$
        
        String tag = (String)getProperty(PROP_SLIDE_BTN_TAG);
        w.startElement(tag, c);

        String role = (String)getProperty(PROP_SLIDE_BTN_ROLE);
        w.writeAttribute("role", role, null); // $NON-NLS-1$
        
        String classMixin = ExtLibUtil.concatStyleClasses((String)getProperty(PROP_SLIDE_BTN_CLASS), buttonClass);
        if(StringUtil.isNotEmpty(classMixin)) {
            w.writeAttribute("class", classMixin, null); // $NON-NLS-1$
        }
        String styleMixin = ExtLibUtil.concatStyleClasses((String)getProperty(PROP_SLIDE_BTN_STYLE), buttonStyle);
        if(StringUtil.isNotEmpty(styleMixin)) {
            w.writeAttribute("style", styleMixin, null); // $NON-NLS-1$
        }
        if(StringUtil.isNotEmpty(buttonHref)) {
            RenderUtil.writeLinkAttribute(context,w,buttonHref);
        }
        
        // write button text
        w.writeText(buttonText, null);
        
        // end button tag
        w.endElement(tag);
        // end button container
        w.endElement(contTag);
    }
}
 
Example 17
Source File: DateTimePickerRenderer.java    From BootsFaces-OSP with Apache License 2.0 4 votes vote down vote up
/**
 * Encode the javascript code
 * @throws IOException
 */
private void encodeJS(FacesContext fc, ResponseWriter rw, DateTimePicker dtp, String datePickerId)
throws IOException {
	String clientId = dtp.getClientId();
	String fieldId = dtp.getFieldId();
	if (null == fieldId) {
		fieldId = clientId + "_Input";
	} else if (fieldId.equals(dtp.getId())) {
		throw new FacesException("The field id must differ from the regular id.");
	}
	String mode = dtp.getMode();

	Object v = dtp.getSubmittedValue();
	if (v == null) {
		v = dtp.getValue();
	}

	// show all buttons
	if(dtp.isShowButtonPanel()) {
		dtp.setShowClearButton(true);
		dtp.setShowCloseButton(true);
		dtp.setShowTodayButton(true);
	}

	Locale sloc = BsfUtils.selectLocale(fc.getViewRoot().getLocale(), dtp.getLocale(), dtp);
	String format = BsfUtils.selectMomentJSDateTimeFormat(sloc, dtp.getFormat(), dtp.isShowDate(), dtp.isShowTime());
	String displayFormat = "'" + format + "'";
	
	PolicyFactory policy = new HtmlPolicyBuilder().toFactory();
	String sanitizedDate = policy.sanitize(getValueAsString(v, fc, dtp));
	String inlineDisplayDate = "'" +sanitizedDate + "'";

	String fullSelector =  "#" + BsfUtils.escapeJQuerySpecialCharsInSelector(datePickerId);

	String defaultDate = BsfUtils.isStringValued(dtp.getInitialDate()) ?
		dtp.getInitialDate().contains("moment") ? dtp.getInitialDate() : "'" + dtp.getInitialDate() + "'" : "";
	String minDate = BsfUtils.isStringValued(dtp.getMinDate()) ?
						dtp.getMinDate().contains("moment") ? dtp.getMinDate() : "'" + dtp.getMinDate() + "'" :
						"";
	String maxDate = BsfUtils.isStringValued(dtp.getMaxDate()) ?
						dtp.getMaxDate().contains("moment") ? dtp.getMaxDate() : "'" + dtp.getMaxDate() + "'" :
						"";

	rw.startElement("script", dtp);
	rw.writeText("$(function () { " +
				      "$('" + fullSelector + "').datetimepicker({  " +
				        "ignoreReadonly: false, " +
				        (dtp.isAllowInputToggle()                  ?         		"allowInputToggle: true, ": "") +
				      	(dtp.isCollapse() ? 										"collapse: " + dtp.isCollapse() + ", ": "") +
				      	(BsfUtils.isStringValued(dtp.getDayViewHeaderFormat()) ? 	"dayViewHeaderFormat: '" + dtp.getDayViewHeaderFormat() + "', " : "") +
				      	(BsfUtils.isStringValued(dtp.getDisabledDates()) ?			"disabledDates: " + asArray(dtp.getDisabledDates()) + ", " : "") +
				      	(BsfUtils.isStringValued(dtp.getDisableTimeInterval()) ?	"disabledTimeIntervals: [" + dtp.getDisableTimeInterval() + "], " : "") +
				      	(BsfUtils.isStringValued(dtp.getEnabledDates()) ?			"enabledDates: [" + dtp.getDisableTimeInterval() + "], " : "") +
				      	(dtp.isFocusOnShow() ? 										"focusOnShow: " + dtp.isFocusOnShow() + ", ": "") +
				      	(BsfUtils.isStringValued(dtp.getInitialDate()) ?			"defaultDate: " + defaultDate + ", " : "") +
				      	(dtp.isKeepInvalid() ? 										"keepInvalid: " + dtp.isKeepInvalid() + ", ": "") +
				      	(dtp.isKeepOpen() ? 										"keepOpen: " + dtp.isKeepOpen() + ", ": "") +
				      	(BsfUtils.isStringValued(minDate) ?							"minDate: " + minDate + ", " : "") +
				      	(BsfUtils.isStringValued(maxDate) ?							"maxDate: " + maxDate + ", " : "") +
				      	(dtp.isShowWeek() ? 										"calendarWeeks: " + dtp.isShowWeek() + ", ": "") +
				      	(dtp.isShowClearButton() ? 									"showClear: " + dtp.isShowClearButton() + ", ": "") +
				      	(dtp.isShowCloseButton() ? 									"showClose: " + dtp.isShowCloseButton() + ", ": "") +
				      	(dtp.isShowTodayButton() ? 									"showTodayButton: " + dtp.isShowTodayButton() + ", ": "") +
				      	(dtp.isSideBySide() || "inline".equals(mode) ? 				"sideBySide: true, ": "") +
				      	(dtp.getTimeStepping() > 0 ?								"stepping: " + dtp.getTimeStepping() + ", ": "") +
				      	(BsfUtils.isStringValued(dtp.getToolbarPlacement()) ?		"toolbarPlacement: '" + dtp.getToolbarPlacement() + "', " : "") +
				      	(BsfUtils.isStringValued(dtp.getViewMode()) ?				"viewMode: '" + dtp.getViewMode() + "', " : "") +
				      	(dtp.isUseCurrent() ? 										"": "useCurrent:false,") +
				      	(dtp.getWeekDaysDisabled() == null ? 					    "": "daysOfWeekDisabled:" + asArray(dtp.getWeekDaysDisabled()) + ", ") +
				      	(dtp.isUseStrict() ? 										"useStrict: " + dtp.isUseStrict() + ", ": "") +
				      	(BsfUtils.isStringValued(dtp.getWidgetParent()) ?           "widgetParent: '" + BsfUtils.resolveSearchExpressions(dtp.getWidgetParent()) + "', " : "" ) +
				      	("inline".equals(mode) ? 									"inline: true," : "" ) +
				      	"date: moment(" + inlineDisplayDate + ", " + displayFormat + "), " +
				      	"locale: '" + sloc.getLanguage() + "', " +
				      	"format: " + displayFormat +
					  "});" +
				      // ("inline".equals(type) ? "$('" + fullSelector + "').date(" + inlineDisplayDate + ")" : "") +
				  "});", null);

	if("inline".equals(mode)) {
		rw.writeText("$('" + fullSelector + "').on('dp.change', function(e) { " +
					 "   $('#" + BsfUtils.escapeJQuerySpecialCharsInSelector(fieldId) + "').val( e.date.format(" + displayFormat + ") ); " +
					 "});", null);
	}
	rw.endElement("script");
	new AJAXRenderer().generateBootsFacesAJAXAndJavaScriptForJQuery(fc, dtp, rw, fullSelector, null, true);
}
 
Example 18
Source File: DashboardRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
public void writeDashboard(FacesContext context, ResponseWriter w, UIDashboard c) throws IOException{
    String containerStyle      = "";
    String containerStyleClass = "";
    String headingText         = "";
    String headingStyle        = "";
    String headingStyleClass   = "";
    String boardTitle          = "";
    
    if(c != null) {
        containerStyle      = c.getStyle();
        containerStyleClass = c.getStyleClass();
        headingText         = c.getHeading();
        headingStyle        = c.getHeadingStyle();
        headingStyleClass   = c.getHeadingStyleClass();
        boardTitle          = c.getTitle();
    }
    //Get the list of dash nodes
    List<DashNode> nodes = c.getDashNodes();
    
    //write container div
    w.startElement("div", c); // $NON-NLS-1$
    
    if(HtmlUtil.isUserId(c.getId())) {
        String clientId = c.getClientId(context);
        w.writeAttribute("id", clientId, null); // $NON-NLS-1$ $NON-NLS-2$
    }
    
    String containerClazz = ExtLibUtil.concatStyleClasses((String)getProperty(PROP_CONTAINER_CLASS), containerStyleClass);
    if(StringUtil.isNotEmpty(containerClazz)) {
        w.writeAttribute("class", containerClazz, null); // $NON-NLS-1$
    }
    String containerMixinStyle = ExtLibUtil.concatStyleClasses((String)getProperty(PROP_CONTAINER_STYLE), containerStyle);
    if(StringUtil.isNotEmpty(containerMixinStyle)) {
        w.writeAttribute("style", containerMixinStyle, null); // $NON-NLS-1$
    }
    if(StringUtil.isNotEmpty(boardTitle)) {
        w.writeText(boardTitle, null);
    }else{
        w.writeAttribute("title", "Dashboard", null); // $NON-NLS-1$ $NLS-DashboardRenderer.dashboard-2$
    }
    String role = "presentation"; // $NON-NLS-1$
    w.writeAttribute("role", role, null); // $NON-NLS-1$

    //write title div
    if(StringUtil.isNotEmpty(headingText)) {
        w.startElement((String)getProperty(PROP_HEADING_TAG), c);
        String titleClazz = ExtLibUtil.concatStyleClasses((String)getProperty(PROP_HEADING_CLASS), headingStyleClass);
        if(StringUtil.isNotEmpty(titleClazz)) {
            w.writeAttribute("class", titleClazz, null); // $NON-NLS-1$
        }
        String titleMixinStyle = ExtLibUtil.concatStyleClasses((String)getProperty(PROP_HEADING_STYLE), headingStyle);
        if(StringUtil.isNotEmpty(titleMixinStyle)) {
            w.writeAttribute("style", titleMixinStyle, null); // $NON-NLS-1$
        }
        w.writeText(headingText, null);
        w.endElement((String)getProperty(PROP_HEADING_TAG));
    }
    
    if(nodes != null && nodes.size() > 0) {
        //write inner div
        w.startElement("div", c); // $NON-NLS-1$
        String innerClazz = (String)getProperty(PROP_INNER_CLASS);
        if(StringUtil.isNotEmpty(innerClazz)) {
            w.writeAttribute("class", innerClazz, null); // $NON-NLS-1$
        }
        
        //write dash nodes
        writeDashNodes(context, w, c);
        
        //end inner div
        w.endElement("div"); // $NON-NLS-1$
    }
        
    //end container div
    w.endElement("div"); // $NON-NLS-1$
}
 
Example 19
Source File: SketchPadRenderer.java    From ctsms with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void encodeMarkup(FacesContext context, SketchPad sketchPad)
		throws IOException {
	ResponseWriter writer = context.getResponseWriter();
	String clientId = sketchPad.getClientId(context);
	String styleClass = sketchPad.getStyleClass();
	styleClass = styleClass == null ? SketchPad.CONTAINER_CLASS
			: SketchPad.CONTAINER_CLASS + " " + styleClass;
	writer.startElement("span", null);
	writer.writeAttribute("id", clientId, null);
	writer.writeAttribute("class", styleClass, null);
	encodeInput(context, sketchPad);
	if (!sketchPad.isDisabled()) {
		writer.startElement("table", null);
		writer.writeAttribute("class", "sketch-toolbar-table", null);
		writer.startElement("tr", null);
		String strokesId = sketchPad.getStrokesId();
		boolean regionMode = true;
		if (!(strokesId != null && strokesId.length() > 0)) {
			encodeButton(context, sketchPad, "regionToggler",
					Settings.getBoolean(SettingCodes.SKETCH_REGIONS_VISIBLE, Bundle.SETTINGS, DefaultSettings.SKETCH_REGIONS_VISIBLE) ? "sketch-region-toggler-off"
							: "sketch-region-toggler-on",
					Messages.getString(MessageCodes.SKETCH_TOGGLE_REGION_TOOLTIP));
			regionMode = false;
		}
		encodeButton(context, sketchPad, "drawEraseMode", "sketch-draw-mode", Messages.getString(MessageCodes.SKETCH_DRAW_MODE_TOOLTIP));
		encodeButton(context, sketchPad, "undo", "sketch-undo-disabled", Messages.getString(MessageCodes.SKETCH_UNDO_TOOLTIP));
		encodeButton(context, sketchPad, "redo", "sketch-redo-disabled", Messages.getString(MessageCodes.SKETCH_REDO_TOOLTIP));
		encodeButton(context, sketchPad, "clear", "sketch-clear-disabled", Messages.getString(MessageCodes.SKETCH_CLEAR_TOOLTIP));
		writer.startElement("td", null);
		writer.writeText(" ", null);
		writer.endElement("td");
		encodeColorPicker(context, sketchPad);
		if (!regionMode) {
			encodeButton(context, sketchPad, "penWidth0", "sketch-pen-width-0-disabled", Messages.getString(MessageCodes.SKETCH_PEN_WIDTH_0_TOOLTIP));
			encodeButton(context, sketchPad, "penWidth1", "sketch-pen-width-1-disabled", Messages.getString(MessageCodes.SKETCH_PEN_WIDTH_1_TOOLTIP));
			encodeButton(context, sketchPad, "penWidth2", "sketch-pen-width-2", Messages.getString(MessageCodes.SKETCH_PEN_WIDTH_2_TOOLTIP));
			encodeButton(context, sketchPad, "penWidth3", "sketch-pen-width-3-disabled", Messages.getString(MessageCodes.SKETCH_PEN_WIDTH_3_TOOLTIP));
			encodeButton(context, sketchPad, "penOpacity0", "sketch-pen-opacity-0", Messages.getString(MessageCodes.SKETCH_PEN_OPACITY_0_TOOLTIP));
			encodeButton(context, sketchPad, "penOpacity1", "sketch-pen-opacity-1-disabled", Messages.getString(MessageCodes.SKETCH_PEN_OPACITY_1_TOOLTIP));
			encodeButton(context, sketchPad, "penOpacity2", "sketch-pen-opacity-2-disabled", Messages.getString(MessageCodes.SKETCH_PEN_OPACITY_2_TOOLTIP));
		}
		writer.endElement("tr");
		writer.endElement("table");
	}
	encodeDiv(context, sketchPad);
	writer.endElement("span");
}
 
Example 20
Source File: CoreRenderer.java    From BootsFaces-OSP with Apache License 2.0 3 votes vote down vote up
/**
 * @param rw
 *            ResponseWriter to be used
 * @param text
 *            Text to be written
 * @param property
 *            Name of the property or attribute (if any) of the
 *            {@link UIComponent} associated with the containing element, to
 *            which this generated text corresponds
 * @throws IOException
 *             if an input/output error occurs
 * @throws NullPointerException
 *             if <code>text</code> is <code>null</code>
 */
public void writeText(ResponseWriter rw, Object text, String property) throws IOException {
	if (text == null || text.equals("")) {
		return;
	}
	rw.writeText(text, property);
}