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

The following examples show how to use javax.faces.context.ResponseWriter#startElement() . 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: PagerExpandRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void writePagerContent(FacesContext context, ResponseWriter w, AbstractPager _pager, FacesDataIterator dataIterator) throws IOException {
    UIPagerExpand pager = (UIPagerExpand) _pager;
    w.startElement("div", null); // $NON-NLS-1$

    w.startElement("ul", null); // $NON-NLS-1$
    String styleClass = pager.getStyleClass();
    String pgClass = ExtLibUtil.concatStyleClasses("pagination", styleClass); // $NON-NLS-1$
    if (StringUtil.isNotEmpty(pgClass)) {
        w.writeAttribute("class", pgClass, null); // $NON-NLS-1$
    }

    writeCollapseAll(context, w, pager, dataIterator);
    writeSeparator(context, w, pager, dataIterator);
    writeExpandAll(context, w, pager, dataIterator);
    w.endElement("ul"); // $NON-NLS-1$

    w.endElement("div"); // $NON-NLS-1$
}
 
Example 2
Source File: DojoDropDownButtonRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
protected void writePopupImage(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException {
	if (tree.getNode().getType() != ITreeNode.NODE_LEAF) {
		writer.startElement("img", null); // $NON-NLS-1$
		// writer.writeAttribute("class","yourProductSprite yourProductSprite-btnDropDown2",null); // $NON-NLS-1$ $NON-NLS-2$
		writer.writeAttribute("src", HtmlRendererUtil.getImageURL(context, (String)getProperty(PROP_DROPDOWN_IMAGEURL_CLASS)), null); // $NON-NLS-1$
		String dropDownImageAriaLabel = (String)getProperty(PROP_DROPDOWN_IMAGE_ARIA_LABEL);
		if( ExtLibRenderUtil.isAltPresent(dropDownImageAriaLabel) ){
		    writer.writeAttribute("aria-label", dropDownImageAriaLabel, null); //$NON-NLS-1$
		}
		String dropDownImageAlt = (String)getProperty(PROP_DROPDOWN_IMAGE_ALT);
		if( ExtLibRenderUtil.isAltPresent(dropDownImageAlt) ){
		    writer.writeAttribute("alt", dropDownImageAlt, null); //$NON-NLS-1$
		}
		writer.endElement("img"); // $NON-NLS-1$
		writer.startElement("span", null); // $NON-NLS-1$
		writer.writeAttribute("class", (String)getProperty(PROP_DROPDOWN_ALTTEXT_CLASS), null); // $NON-NLS-1$
		writer.writeText("\u25BC", null); // $NLS-OneUIDropDownButtonRenderer.u25BC-1$
		writer.endElement("span"); // $NON-NLS-1$
	}
}
 
Example 3
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 4
Source File: FormTableRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void writeHeaderFacet(FacesContext context, ResponseWriter w, FormLayout c, UIComponent header) throws IOException {
    w.startElement("tr", c); // $NON-NLS-1$
    w.startElement("td", c); // $NON-NLS-1$
    String style = (String)getProperty(PROP_STYLEHEADER);
    if(StringUtil.isNotEmpty(style)) {
        w.writeAttribute("style", style, null); // $NON-NLS-1$
    }
    String cls = (String)getProperty(PROP_STYLECLASSHEADER);
    if(StringUtil.isNotEmpty(cls)) {
        w.writeAttribute("class", cls, null); // $NON-NLS-1$
    }
    w.writeAttribute("colspan", "3", null); // $NON-NLS-1$
    
    writeHeaderFacetContext(context, w, c, header);
    
    w.endElement("td"); // $NON-NLS-1$
    w.endElement("tr"); // $NON-NLS-1$
}
 
Example 5
Source File: PagerSizesRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void writePagerContent(FacesContext context, ResponseWriter w, AbstractPager _pager, FacesDataIterator dataIterator) throws IOException {
    UIPagerSizes pager = (UIPagerSizes) _pager;
    w.startElement("div", null); // $NON-NLS-1$

    w.startElement("ul", null); // $NON-NLS-1$
    String styleClass = pager.getStyleClass();
    String pgClass = ExtLibUtil.concatStyleClasses("pagination", styleClass); // $NON-NLS-1$
    if (StringUtil.isNotEmpty(pgClass)) {
        w.writeAttribute("class", pgClass, null); // $NON-NLS-1$
    }

    String text = pager.getText();
    if (StringUtil.isEmpty(text)) {
        // "Show {0} items per page";
        text = com.ibm.xsp.extlib.controls.ResourceHandler.getString("PagerSizesRenderer.Show0itemsperpage"); //$NON-NLS-1$
    }
    int pos = text.indexOf("{0}"); //$NON-NLS-1$
    writerStartText(context, w, pager, dataIterator, text, pos);
    writerPages(context, w, pager, dataIterator, text, pos);
    writerEndText(context, w, pager, dataIterator, text, pos);
    w.endElement("ul"); // $NON-NLS-1$

    w.endElement("div"); // $NON-NLS-1$
}
 
Example 6
Source File: ViewTitleRenderer.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public void encodeBegin(FacesContext context, UIComponent component) throws IOException
	{
		if (!component.isRendered()) return;

		ResponseWriter writer = context.getResponseWriter();
		writer.startElement("h1", null);

		// TODO: Should we really write out the ID?  Is there any need for this in this tag?
//		String id = (String) RendererUtil.getAttribute(context, component, "id");
//		if (id != null)
//		{
//			writer.writeAttribute("id", id, null);
//		}

		String cssClass = "insColor insBak insBorder";
		Integer indent = (Integer) RendererUtil.getAttribute(context, component, "indent");
		if (indent != null)
		{
			cssClass = cssClass + " indnt"+indent;
		}
		writer.writeAttribute("class", cssClass, null);
		writer.writeText((String) RendererUtil.getAttribute(context, component, "value"), null);
	}
 
Example 7
Source File: DojoFormWidgetRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void startTag(FacesContext context, ResponseWriter writer, UIInput component) throws IOException {
    String tagName = getTagName();
    writer.startElement(tagName, component); //$NON-NLS-1$
    String type = getInputType();
    if(StringUtil.isNotEmpty(type)) {
        writer.writeAttribute("type", type, null); //$NON-NLS-1$ //$NON-NLS-2$
    }
}
 
Example 8
Source File: WidgetContainerRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void writeHeader(FacesContext context, ResponseWriter w, UIWidgetContainer c) throws IOException {
    UIComponent header = c.getFacet(UIWidgetContainer.FACET_HEADER);
    if(header!=null) {
        String tag = (String)getProperty(PROP_TAGHEADER);
        w.startElement(tag, c);
        String cls = (String)getProperty(PROP_CSSHEADER);
        if(StringUtil.isNotEmpty(cls)) {
            w.writeAttribute("class", cls, null); // $NON-NLS-1$
        }
        FacesUtil.renderChildren(context, header);
        
        w.endElement(tag);
    }
}
 
Example 9
Source File: RendererUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Given a List of SelectItems render the select options
 * 
 * @param out
 * @param items
 *            List of SelectItems
 * @param selected
 *            seelcted choice
 * @param clientId
 *            the id
 * @param styleClass
 *            the optional style class
 * @param component
 *            the component being rendered
 * @throws IOException
 */

public static void renderMenu(ResponseWriter out, List items, int selected, String clientId,
        String styleClass, UIComponent component) throws IOException
{
    // // debug lines
    // out.writeText("startElement select", null);
    // if (true) return;
    out.startElement("select", component);
    out.writeAttribute("name", clientId, "id");
    out.writeAttribute("id", clientId, "id");
    if (styleClass != null)
    {
        out.writeAttribute("class", styleClass, "styleClass");
    }

    Iterator iter = items.iterator();
    while (iter.hasNext())
    {
        SelectItem si = (SelectItem) iter.next();
        Integer value = (Integer) si.getValue();
        String label = si.getLabel();
        out.startElement("option", component);
        out.writeAttribute("value", value, null);
        if (value.intValue() == selected)
        {
            out.writeAttribute("selected", "selected", null);
        }
        out.writeText(label, null);
    }
    out.endElement("select");
}
 
Example 10
Source File: CarouselControlRenderer.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
public void myEncodeBegin(FacesContext context, UIComponent component) throws IOException {
	if (!component.isRendered()) {
		return;
	}
	CarouselControl carouselControl = (CarouselControl) component;
	ResponseWriter rw = context.getResponseWriter();
	// String clientId = carouselControl.getClientId();

	/**
	 * <a class=
	 * "left carousel-control" href="#myCarousel" role="button" data-slide=
	 * "prev"> <span class=
	 * "glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
	 * <span class="sr-only">Previous</span> </a>
	 */

	// put custom code here
	// Simple demo widget that simply renders every attribute value
	rw.startElement("carouselControl", carouselControl);
	Tooltip.generateTooltip(context, carouselControl, rw);

	rw.writeAttribute("id", carouselControl.getId(), "id");
	Tooltip.activateTooltips(context, carouselControl);
	AJAXRenderer.generateBootsFacesAJAXAndJavaScript(context, carouselControl, rw, false);

	UIComponent parent = carouselControl.getParent();
	rw.writeAttribute("href", "#" + parent.getClientId(), "href");
	rw.writeAttribute("role", "button", "role");

	String direction = carouselControl.getDirection();
	rw.writeAttribute("data-slide", direction, "data-slide");
	String styleClass = direction + " carousel-control";
	if (null != carouselControl.getStyleClass())
		styleClass += " " + carouselControl.getStyleClass();
	rw.writeAttribute("styleClass", styleClass, "styleClass");

	rw.writeAttribute("style", carouselControl.getStyle(), "style");
}
 
Example 11
Source File: UIAutoComplete.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void encodeAutoCompleteInitializationScript(ResponseWriter writer, String inputTextClientId, String divClientId,
        String contextPath, String serviceName, String serviceArgs, String labelField, String valueField,
        String autoCompleteItemsStyleClass, String className, String inputTextArgName) throws IOException {
    String finalUri =
            MessageFormat.format(contextPath + "/" + DEFAULT_AUTO_COMPLETE_SERVLET_URI
                    + "?args={0}&labelField={1}&valueField={2}&styleClass={3}&class={4}&inputTextArgName={5}", new Object[] {
                    "serviceName=" + serviceName + ",serviceArgs=" + URLEncoder.encode(serviceArgs, DEFAULT_ENCODING),
                    labelField, valueField, autoCompleteItemsStyleClass, className, inputTextArgName });

    String escapeId = escapeId(inputTextClientId);
    String scriptText =
            "$(\"input#"
                    + escapeId
                    + "\").autocomplete(\""
                    + finalUri
                    + "\", { minChars: 3"
                    + ", validSelection: false"
                    + ", cleanSelection: clearAutoComplete, select: selectElement, after: updateCustomValue, error:showError}); +\n"
                    + "$(\"input[name='" + escapeId + "']\").val($(\"input#" + escapeId + "\").val());";

    writer.startElement("script", null);
    writer.writeAttribute("language", "JavaScript", null);
    writer.write(scriptText);

    writer.endElement("script");

}
 
Example 12
Source File: UIHtmlEditor.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void encodeHiddenField(ResponseWriter writer, String clientId, String value) throws IOException {
    writer.startElement("input", this);
    writer.writeAttribute("type", "hidden", null);
    writer.writeAttribute("id", clientId, null);
    writer.writeAttribute("name", clientId, null);
    writer.writeAttribute("value", (value != null) ? value : "", null);
    writer.endElement("input");
}
 
Example 13
Source File: DataGridRenderer.java    From ctsms with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void encodeMarkup(FacesContext context, DataGrid grid) throws IOException {
	if (grid.isLazyLoading()) {
		grid.loadLazyData();
	}
	ResponseWriter writer = context.getResponseWriter();
	String clientId = grid.getClientId();
	boolean hasPaginator = grid.isPaginator();
	boolean empty = grid.getRowCount() == 0;
	String paginatorPosition = grid.getPaginatorPosition();
	String styleClass = grid.getStyleClass() == null ? DataGrid.DATAGRID_CLASS : DataGrid.DATAGRID_CLASS + " " + grid.getStyleClass();
	String contentClass = empty ? DataGrid.EMPTY_CONTENT_CLASS : DataGrid.CONTENT_CLASS;
	if (hasPaginator) {
		grid.calculatePage();
	}
	writer.startElement("div", grid);
	writer.writeAttribute("id", clientId, "id");
	writer.writeAttribute("class", styleClass, "styleClass");
	encodeFacet(context, grid, "header", DataGrid.HEADER_CLASS);
	if (hasPaginator && !paginatorPosition.equalsIgnoreCase("bottom")) {
		encodePaginatorMarkup(context, grid, "top");
	}
	writer.startElement("div", grid);
	writer.writeAttribute("id", clientId + "_content", null);
	writer.writeAttribute("class", contentClass, null);
	if (empty) {
		writer.write(grid.getEmptyMessage());
	} else {
		encodeTable(context, grid);
	}
	writer.endElement("div");
	if (hasPaginator && !paginatorPosition.equalsIgnoreCase("top")) {
		encodePaginatorMarkup(context, grid, "bottom");
	}
	encodeFacet(context, grid, "footer", DataGrid.FOOTER_CLASS);
	writer.endElement("div");
}
 
Example 14
Source File: AbstractApplicationLayoutRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void writeBanner(FacesContext context, ResponseWriter w, UIApplicationLayout c, BasicApplicationConfigurationImpl configuration) throws IOException {
        String tag = (String)getProperty(PROP_BANNERTAG);
        w.startElement(tag,c);
        String style = (String)getProperty(PROP_BANNERSTYLE);
        if(StringUtil.isNotEmpty(style)) {
            w.writeAttribute("style",style,null); // $NON-NLS-1$
        }
        String styleClass = (String)getProperty(PROP_BANNERCLASS);
        if(StringUtil.isNotEmpty(styleClass)) {
            w.writeAttribute("class",styleClass,null); // $NON-NLS-1$
        }
        String role = (String)getProperty(PROP_BANNERROLE);
        if(StringUtil.isNotEmpty(role)) {
            w.writeAttribute("role",role,null); // $NON-NLS-1$
        }
        newLine(w);
        
        w.startElement("div",c); // $NON-NLS-1$
        String styleClass1 = (String)getProperty(PROP_BANNERINNER1CLASS);
        if(StringUtil.isNotEmpty(styleClass1)) {
            w.writeAttribute("class",styleClass1,null); // $NON-NLS-1$
        }
        newLine(w);
        
        w.startElement("div",c); // $NON-NLS-1$
        String styleClass2 = (String)getProperty(PROP_BANNERINNER2CLASS);
        if(StringUtil.isNotEmpty(styleClass2)) {
            w.writeAttribute("class",styleClass2,null); // $NON-NLS-1$
        }
        newLine(w);
        
        writeBannerContent(context, w, c, configuration);
        
        // Close the banner
        w.endElement("div"); newLine(w,"lotusInner"); // $NON-NLS-1$ $NON-NLS-2$
        w.endElement("div"); newLine(w,"lotusRightCorner"); // $NON-NLS-1$ $NON-NLS-2$
        w.endElement(tag); newLine(w,"lotusBanner"); // $NON-NLS-1$
}
 
Example 15
Source File: FormTableRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
@Override
protected void writeFormLayout(FacesContext context, ResponseWriter w, FormLayout c) throws IOException {
    ComputedFormData formData = createFormData(context, c);
    String style = c.getStyle();
    String styleClass = c.getStyleClass();
    boolean nested = formData.isNested();
    if(!nested) {
        w.startElement("fieldset", c); // $NON-NLS-1$
    } else {
        w.startElement("div", c); // $NON-NLS-1$
        style = ExtLibUtil.concatStyles("margin-left: -25px; margin-right: 0px;", style); // $NON-NLS-1$
    }
    String clientId = c.getClientId(context);
    w.writeAttribute("id", clientId, "clientId"); // $NON-NLS-1$ $NON-NLS-2$
    if(!StringUtil.isEmpty(style)) {
        w.writeAttribute("style", style, null); // $NON-NLS-1$
    }
    if(!StringUtil.isEmpty(styleClass)) {
        w.writeAttribute("class", styleClass, null); // $NON-NLS-1$
    }
    
    if(!nested){
        String legend = c.getLegend();
        if(StringUtil.isNotEmpty(legend)) {
            w.startElement("legend", c); // $NON-NLS-1$
            w.writeText(legend, "legend"); // $NON-NLS-1$
            w.endElement("legend"); // $NON-NLS-1$
        }
    }

    newLine(w);
    // TODO the xe:formTable is using a HTML TABLE element, but the latest OneUI uses DIVs instead
    // as they're better for accessibility. This implementation should be changed to use DIVs
    // before the control is published. See http://rtpgsa.ibm.com/projects/o/oneui/development/OneUI_3.0.0_rc1/docPublic/components/forms.htm
    // TODO the OneUI spec now has recommendations for subsections in the form control
    // where as for the initial TeamRoom implementation
    // we recommended using an inner xe:formTable control within an xe:formRow
    // Should use the new recommended form table format, with support for sections,
    // collapsible sections, and tabs.
    // See http://rtpgsa.ibm.com/projects/o/oneui/development/OneUI_3.0.0_rc1/docPublic/components/forms.htm
    // TODO the table summary, and other table accessibility attributes
    w.startElement("table", c); // $NON-NLS-1$
    writeMainTableTag(context, w, c);
    w.startElement("tbody", c); // $NON-NLS-1$
    newLine(w);
    
    writeErrorSummary(context, w, c, formData);
    writeHeader(context, w, c);
    writeForm(context, w, c, formData);
    writeFooter(context, w, c);
    
    w.endElement("tbody"); // $NON-NLS-1$
    newLine(w);
    w.endElement("table"); // $NON-NLS-1$
    newLine(w);
    if(!nested) {
        w.endElement("fieldset"); // $NON-NLS-1$
    } else {
        w.endElement("div"); // $NON-NLS-1$
    }
    newLine(w);
}
 
Example 16
Source File: SketchPadRenderer.java    From ctsms with GNU Lesser General Public License v2.1 4 votes vote down vote up
private static void startScript(ResponseWriter writer, String id) throws IOException {
	writer.startElement("script", null);
	writer.writeAttribute("id", id, null);
	writer.writeAttribute("type", "text/javascript", null);
}
 
Example 17
Source File: SeparatedListRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * We put all our processing in the encodeChildren method
 * @param context
 * @param component
 * @throws IOException
 */
public void encodeChildren(FacesContext context, UIComponent component)
  throws IOException
{
  if (!component.isRendered())
  {
    return;
  }

  String clientId = null;

  if (component.getId() != null &&
    !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
  {
    clientId = component.getClientId(context);
  }

  ResponseWriter writer = context.getResponseWriter();

  if (clientId != null)
  {
     String styleClass = (String) RendererUtil.getAttribute(context, component, "styleClass");
    writer.startElement("div", component);
    writer.writeAttribute("id", clientId, "id");
    writer.writeAttribute("class", styleClass, "class");
  }

  List children = component.getChildren();

  // this is a special separator attribute, not supported by UIData
  String separator = (String) RendererUtil.getAttribute(context, component, "separator");
  if (separator==null) separator=" | ";

  boolean first = true;
  for (Iterator iter = children.iterator(); iter.hasNext();)
  {
    UIComponent child = (UIComponent)iter.next();
     
    if (child.isRendered()) {
       if (!first) writer.write(separator);
 
       RendererUtil.encodeRecursive(context, child);
       first = false;
    }
  } 
    if (clientId != null)
      {
      writer.endElement("div");
    }

  }
 
Example 18
Source File: FullCalendarRenderer.java    From BootsFaces-OSP with Apache License 2.0 4 votes vote down vote up
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
	if (!component.isRendered()) {
		return;
	}
	FullCalendar fullCalendar = (FullCalendar) component;
	ResponseWriter rw = context.getResponseWriter();
	String clientId = fullCalendar.getClientId();
	String lang = fullCalendar.getLang();
	if (lang == null) {
		lang = "en"; // ensure to have a value for lang; on loaded language files, lang must be specified
	}

	// activate the jquery plugin on that div
	rw.startElement("script", null);

	rw.writeText("$(document).ready(function() {", null);
	rw.writeText("  $(\"[id='" + clientId + "']\").fullCalendar({", null);
	rw.writeText("    lang: '" + lang + "',", null);
	if (fullCalendar.getScrollTime() != null) {
		rw.writeText("    scrollTime: '" + fullCalendar.getScrollTime() + "',", null);
	}
	rw.writeText("    allDaySlot: " + fullCalendar.isAllDaySlot() + ",", null);
	if (fullCalendar.getSlotDuration() != null) {
		rw.writeText("    slotDuration: '" +  fullCalendar.getSlotDuration() + "',", null);
	}
	if (fullCalendar.getDefaultView() != null) {
		rw.writeText("    defaultView: '" + fullCalendar.getDefaultView() + "',", null);
	}
	if (fullCalendar.getCalendarHeader() != null) {
		rw.writeText("    header: " + fullCalendar.getCalendarHeader() + ",", null);
	}
	if (fullCalendar.getBusinessHours() != null) {
		rw.writeText("    businessHours: " + fullCalendar.getBusinessHours() + ",", null);
	}
	rw.writeText("    height: " + fullCalendar.getHeight() + ",", null);
	rw.writeText("    weekNumbers: " + fullCalendar.isWeekNumbers() + ",", null);
	rw.writeText("    weekends: " + fullCalendar.isWeekends() + ",", null);
	rw.writeText("    editable: " + fullCalendar.isEditable() + ",", null);
	if (fullCalendar.getDefaultDate() != null) {
		rw.writeText("    defaultDate: '" + fullCalendar.getDefaultDate() + "',", null);
	}
	rw.writeText("    weekMode: '" + fullCalendar.getWeekMode() + "',", null);
	if (fullCalendar.getEventClick() != null) {
		rw.writeText("    eventClick: " + fullCalendar.getEventClick() + ",", null);
	}
	if (fullCalendar.getDayClick() != null) {
		rw.writeText("    dayClick: " + fullCalendar.getDayClick() + ",", null);
	}
	rw.writeText("    events: " + fullCalendar.getEvents(), null);
	// TODO: add onchange listener that updates a hidden input field with $([\"id='" + clientId + "'\"]).fullCalendar('getEventSources') that contains the events
	rw.writeText("  });", null);
	rw.writeText("});", null);
	rw.endElement("script");
}
 
Example 19
Source File: ToolBarRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * We put all our processing in the encodeChildren method
 * @param context
 * @param component
 * @throws IOException
 */
public void encodeChildren(FacesContext context, UIComponent component) throws IOException
{
    if (!component.isRendered())
    {
        return;
    }

    String clientId = null;

    if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
    {
        clientId = component.getClientId(context);
    }

    ResponseWriter writer = context.getResponseWriter();

    if (clientId != null)
    {
        writer.startElement("ul", component);
        //writer.append(" class=\"jsfToolbar\" "); // we don't seem to get here
    }

    @SuppressWarnings("unchecked")
    List<UIComponent> children = component.getChildren();

    // this is a special separator attribute, not supported by UIData
    String separator = (String) RendererUtil.getAttribute(context, component, "separator");
    if (separator == null)
    {
        separator = "";
    }

    boolean first = true;
    boolean foundCurrent = false;
    for( UIComponent child : children )
    {
        // should instead leave the span open, and the item should then add class and aria attributes
        // depending on the item is (disabled or not) and then close
        if (child.isRendered()) {
            if (!first)
            {
                writer.write("<li>");
            }
            else
            {
                writer.write("<li class=\"firstToolBarItem\">");
            }
            // SAK-23062 improve JSF options menu
            boolean current = false;
            if (!foundCurrent) {
                // check for the "current" attribute on the custom tag, mark that item as current if it set to true
                boolean hasCurrentIndicated = (child.getAttributes().get("current") != null); // NOTE: child.getAttributes().containsKey("current") will NOT work here
                current = (hasCurrentIndicated && ((Boolean)child.getAttributes().get("current")));
                /* this breaks too many other things
                 * if (!hasCurrentIndicated && !"javax.faces.Link".equals(child.getRendererType())) {
                 * // basically - if it is not a link, it is probably the current item
                 * current = true;
                 * }
                 */
            }
            if (current) {
                foundCurrent = true;
                writer.write("<span class=\"current\">");
            } else {
                writer.write("<span>");
            }
            RendererUtil.encodeRecursive(context, child);
            writer.write("</span></li> ");
            first = false;
        }
    }
    if (clientId != null)
    {
         writer.endElement("ul");
    }
}
 
Example 20
Source File: SelectOneMenuRenderer.java    From BootsFaces-OSP with Apache License 2.0 3 votes vote down vote up
/**
 * Starts the input field group (if needed to display a component seamlessly in
 * front of or behind the input field). This method is protected in order to
 * allow third-party frameworks to derive from it.
 *
 * @param hasAppendingAddOn
 *
 * @param rw
 *            the response writer
 * @param hasPrependingAddOn
 * @return true if there is an add-on in front of or behind the input field
 * @throws IOException
 *             may be thrown by the response writer
 */
protected boolean startInputGroupForAddOn(ResponseWriter rw, boolean hasPrependingAddOn, boolean hasAppendingAddOn,
		SelectOneMenu menu) throws IOException {
	final boolean hasAddon = hasAppendingAddOn || hasPrependingAddOn;
	if (hasAddon) {
		rw.startElement("div", menu);
		rw.writeAttribute("class", "input-group", "class");
	}
	return hasAddon;
}