public static void addToScriptHash(Map<String, Object> hash, FacesContext facesContext, UIComponent component, Attributes attributes, ScriptHashVariableWrapper wrapper) { boolean disabled = isDisabled(component); for (ComponentAttribute knownAttribute : attributes) { if (!disabled || knownAttribute.getEventNames().length == 0) { String attributeName = knownAttribute.getComponentAttributeName(); addToScriptHash(hash, attributeName, getAttributeAndBehaviorsValue(facesContext, component, knownAttribute), knownAttribute.getDefaultValue(), wrapper); } } }
public static void renderAttributeAndBehaviors(FacesContext facesContext, UIComponent component, ComponentAttribute componentAttribute) throws IOException { Object attributeValue = getAttributeAndBehaviorsValue(facesContext, component, componentAttribute); renderAttribute(facesContext, componentAttribute.getHtmlAttributeName(), attributeValue); }
public void render(FacesContext context, UIComponent component) throws IOException { renderPassThroughAttributes(context, component, this); }
public String getButtonIcon(FacesContext facesContext, UIComponent component) { boolean disable = (Boolean) component.getAttributes().get(OPTION_DISABLED); String buttonIcon = (String) component.getAttributes().get("buttonIcon"); if (disable) { buttonIcon = (String) component.getAttributes().get("buttonDisabledIcon"); } if (buttonIcon != null && buttonIcon.trim().length() != 0) { buttonIcon = RenderKitUtils.getResourceURL(buttonIcon, facesContext); } else { buttonIcon = disable ? CALENDAR_DISABLE_ICON_RESOURCE_NAME : CALENDAR_ICON_RESOURCE_NAME; buttonIcon = RenderKitUtils.getResourcePath(facesContext, "org.richfaces.images", buttonIcon); } return buttonIcon; }
shouldRenderAttribute(value) ) { responseWriter.writeAttribute("class",value,null); renderPassThroughAttributes(facesContext, component, PASS_THROUGH_ATTRIBUTES3); addToScriptHash(options, facesContext, component, ATTRIBUTES_FOR_SCRIPT_HASH2, null); addToScriptHash(options, facesContext, component, ATTRIBUTES_FOR_SCRIPT_HASH3, null); Object text = "new RichFaces.HtmlLog(" + convertToString(toScriptArgs(options)) + ");"; if (text != null) { responseWriter.writeText(text, null);
renderPassThroughAttributes(facesContext, component, PASS_THROUGH_ATTRIBUTES36); renderPassThroughAttributes(facesContext, component, PASS_THROUGH_ATTRIBUTES37); renderPassThroughAttributes(facesContext, component, PASS_THROUGH_ATTRIBUTES38); String onchange = (String)convertToString(RenderKitUtils.getAttributeAndBehaviorsValue(facesContext,component,RenderKitUtils.attributes().generic("onchange","onchange","change","valueChange").first())); responseWriter.startElement("script", component); responseWriter.writeAttribute("type","text/javascript",null); Object text = "new RichFaces.ui.InputNumberSlider('" + convertToString(clientId) + "', {\n delay: " + convertToString(component.getAttributes().get("delay")) + ",\n disabled: " + convertToString(component.getAttributes().get("disabled")) + ",\n handleType: '" + convertToString(component.getAttributes().get("handleType")) + "',\n maxValue: " + convertToString(component.getAttributes().get("maxValue")) + ",\n minValue:\n " + convertToString(component.getAttributes().get("minValue")) + ",\n onchange: " + convertToString(((onchange.length() > 0) ? (("function (event) {" + onchange) + "}") : "null")) + ",\n step: " + convertToString(component.getAttributes().get("step")) + ",\n tabIndex:\n " + convertToString((convertToBoolean(RenderKitUtils.shouldRenderAttribute(component.getAttributes().get("tabindex"))) ? component.getAttributes().get("tabindex") : "null")) + "\n }, {\n decreaseSelectedClass: '" + convertToString(component.getAttributes().get("decreaseSelectedClass")) + "',\n handleSelectedClass:\n '" + convertToString(component.getAttributes().get("handleSelectedClass")) + "',\n increaseSelectedClass:\n '" + convertToString(component.getAttributes().get("increaseSelectedClass")) + "'\n });"; if (text != null) { responseWriter.writeText(text, null);
addToScriptHash(options, facesContext, component, ATTRIBUTES_FOR_SCRIPT_HASH31, null); addToScriptHash(options, "selectionType", this.getSelectionType(facesContext,component), SwitchType.client, null); addToScriptHash(options, "ajaxSubmitFunction", this.getAjaxSubmitFunction(facesContext,component), null, null); addToScriptHash(options, facesContext, component, ATTRIBUTES_FOR_SCRIPT_HASH32, null); addToScriptHash(options, "clientEventHandlers", clientEventHandlers, null, null); Object text = "new RichFaces.ui.Tree(" + convertToString(toScriptArgs(clientId,options)) + ");"; if (text != null) { responseWriter.writeText(text, null);
renderPassThroughAttributes(facesContext, component, PASS_THROUGH_ATTRIBUTES42); renderPassThroughAttributes(facesContext, component, PASS_THROUGH_ATTRIBUTES43); renderPassThroughAttributes(facesContext, component, PASS_THROUGH_ATTRIBUTES44); renderPassThroughAttributes(facesContext, component, PASS_THROUGH_ATTRIBUTES45); String onchange = (String)convertToString(RenderKitUtils.getAttributeAndBehaviorsValue(facesContext,component,RenderKitUtils.attributes().generic("onchange","onchange","change","valueChange").first())); responseWriter.startElement("script", component); responseWriter.writeAttribute("type","text/javascript",null);
public static void addToScriptHash(Map<String, Object> hash, String name, Object value) { addToScriptHash(hash, name, value, null, null); }
shouldRenderAttribute(value) ) { responseWriter.writeAttribute("class",value,null); renderPassThroughAttributes(facesContext, component, PASS_THROUGH_ATTRIBUTES39);
/** * @param context * @param component * @param property * @param attributeName * * @throws IOException */ public void encodeAttribute(FacesContext context, UIComponent component, Object property, String attributeName) throws IOException { ResponseWriter writer = context.getResponseWriter(); Object value = component.getAttributes().get(property); if (RenderKitUtils.shouldRenderAttribute(value)) { writer.writeAttribute(attributeName, value, property.toString()); } }
int monthMin = calendar.getActualMinimum(Calendar.MONTH); String[] weekDayLabelsShort = RenderKitUtils.asArray(calendarComponent.getWeekDayLabelsShort()); if (isEmptyArray(weekDayLabelsShort)) { weekDayLabelsShort = dateFormat.getShortWeekdays(); weekDayLabelsShort = shiftDates(minimum, maximum, weekDayLabelsShort); RenderKitUtils.addToScriptHash(map, WEEK_DAY_LABELS_SHORT, weekDayLabelsShort); String[] monthLabels = RenderKitUtils.asArray(calendarComponent.getMonthLabels()); if (isEmptyArray(monthLabels)) { monthLabels = dateFormat.getMonths(); monthLabels = shiftDates(monthMin, monthMax, monthLabels); RenderKitUtils.addToScriptHash(map, MONTH_LABELS, monthLabels); String[] monthLabelsShort = RenderKitUtils.asArray(calendarComponent.getMonthLabelsShort()); if (isEmptyArray(monthLabelsShort)) { monthLabelsShort = dateFormat.getShortMonths(); monthLabelsShort = shiftDates(monthMin, monthMax, monthLabelsShort); RenderKitUtils.addToScriptHash(map, MONTH_LABELS_SHORT, monthLabelsShort); RenderKitUtils.addToScriptHash(map, MIN_DAYS_IN_FIRST_WEEK, minDaysInFirstWeek); RenderKitUtils.addToScriptHash(map, FIRST_DAY_WEEK, day); } else { throw new IllegalArgumentException(day + " value of firstWeekDay attribute is not a legal one for component: "
addToScriptHash(options, "selectionMode", attributes.get("selectionMode"), SelectionMode.multiple); addToScriptHash(options, "onbeforeselectionchange", RenderKitUtils.getAttributeAndBehaviorsValue(context, component, EVENT_ATTRIBUTES.get("onbeforeselectionchange")), null, ScriptHashVariableWrapper.eventHandler); addToScriptHash(options, "onselectionchange", RenderKitUtils.getAttributeAndBehaviorsValue(context, component, EVENT_ATTRIBUTES.get("onselectionchange")), null, ScriptHashVariableWrapper.eventHandler); addToScriptHash(options, "onready", RenderKitUtils.getAttributeAndBehaviorsValue(context, component, EVENT_ATTRIBUTES.get("onready")), null, ScriptHashVariableWrapper.eventHandler); StringBuilder builder = new StringBuilder("new RichFaces.ui.ExtendedDataTable('");
renderPassThroughAttributes(facesContext, component, PASS_THROUGH_ATTRIBUTES4); addToScriptHash(options, facesContext, component, ATTRIBUTES_FOR_SCRIPT_HASH4, null); addToScriptHash(options, facesContext, component, ATTRIBUTES_FOR_SCRIPT_HASH5, ScriptHashVariableWrapper.eventHandler);
protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException { String savedTableState = (String) component.getAttributes().get("tableState"); if (savedTableState != null && ! savedTableState.isEmpty()) { // retrieve table state ExtendedDataTableState tableState = new ExtendedDataTableState(savedTableState); consumeTableState(context, (UIDataTableBase) component, tableState); } Map<String, Object> attributes = component.getAttributes(); writer.startElement(HtmlConstants.DIV_ELEM, component); writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, component.getClientId(context), null); writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, HtmlUtil.concatClasses("rf-edt", (String) attributes.get("styleClass")), null); renderAttribute(context, HtmlConstants.STYLE_ATTRIBUTE, attributes.get("style")); }
public static void renderAttribute(FacesContext facesContext, String attributeName, Object attributeValue) throws IOException { if (!shouldRenderAttribute(attributeValue)) { return; } ResponseWriter writer = facesContext.getResponseWriter(); String prefixedAttributeName = prefixAttributeName(attributeName, writer); if (Arrays.binarySearch(URI_ATTRIBUTE_NAMES, attributeName) >= 0) { writer.writeURIAttribute(prefixedAttributeName, attributeValue, null); } else if (Arrays.binarySearch(BOOLEAN_ATTRIBUTE_NAMES, attributeName) >= 0) { boolean booleanAttributeValue = Boolean.valueOf(String.valueOf(attributeValue)); if (booleanAttributeValue) { // TODO - is passing in Boolean.TRUE value documented somewhere? writer.writeAttribute(prefixedAttributeName, Boolean.TRUE, null); } } else { writer.writeAttribute(prefixedAttributeName, attributeValue, null); } }
public String writePreloadBody(FacesContext context, UIComponent component) throws IOException { AbstractCalendar calendar = (AbstractCalendar) component; Object preload = calendar.getPreload(); if (preload != null) { return RenderKitUtils.toScriptArgs(preload); } else { return null; } }
RenderKitUtils.Attributes seriesEvents = attributes().generic( "onplothover", "onplothover", "plothover").generic( "onplotclick", "onplotclick", "plotclick"); addToScriptHash(optMap, context.getFacesContext(), target, seriesEvents, RenderKitUtils.ScriptHashVariableWrapper.eventHandler);
public String getResourcePath(FacesContext context, String library, String resourceName) { return RenderKitUtils.getResourcePath(context, library, resourceName); } }
@Override Object wrap(Object o) { return asArray(o); } },