/** * Prepares the keyboard event handlers, appending them to the the given * StringBuffer. * @param handlers The StringBuffer that output will be appended to. */ protected void prepareKeyEvents(StringBuffer handlers) { prepareAttribute(handlers, "onkeydown", getOnkeydown()); prepareAttribute(handlers, "onkeyup", getOnkeyup()); prepareAttribute(handlers, "onkeypress", getOnkeypress()); }
/** * Prepares the text event handlers, appending them to the the given * StringBuffer. * @param handlers The StringBuffer that output will be appended to. */ protected void prepareTextEvents(StringBuffer handlers) { prepareAttribute(handlers, "onselect", getOnselect()); prepareAttribute(handlers, "onchange", getOnchange()); }
/** * Render the value element * @param results The StringBuffer that output will be appended to. */ protected void prepareValue(StringBuffer results) { // Acquire the label value we will be generating String label = value; if ((label == null) && (text != null)) label = text; if ((label == null) || (label.length() < 1)) label = getDefaultValue(); prepareAttribute(results, "value", label); }
/** * Prepares the mouse event handlers, appending them to the the given * StringBuffer. * @param handlers The StringBuffer that output will be appended to. */ protected void prepareMouseEvents(StringBuffer handlers) { prepareAttribute(handlers, "onclick", getOnclick()); prepareAttribute(handlers, "ondblclick", getOndblclick()); prepareAttribute(handlers, "onmouseover", getOnmouseover()); prepareAttribute(handlers, "onmouseout", getOnmouseout()); prepareAttribute(handlers, "onmousemove", getOnmousemove()); prepareAttribute(handlers, "onmousedown", getOnmousedown()); prepareAttribute(handlers, "onmouseup", getOnmouseup()); }
/** * Render the button attributes * @param results The StringBuffer that output will be appended to. */ protected void prepareButtonAttributes(StringBuffer results) throws JspException { String tmp = src(); if (tmp != null) { HttpServletResponse response = (HttpServletResponse) pageContext.getResponse(); prepareAttribute(results, "src", response.encodeURL(tmp)); } prepareAttribute(results, "align", getAlign()); prepareAttribute(results, "border", getBorder()); prepareAttribute(results, "value", getValue()); prepareAttribute(results, "accesskey", getAccesskey()); prepareAttribute(results, "tabindex", getTabindex()); }
/** * Render the button attributes * @param results The StringBuffer that output will be appended to. */ protected void prepareButtonAttributes(StringBuffer results) throws JspException { prepareAttribute(results, "accesskey", getAccesskey()); prepareAttribute(results, "tabindex", getTabindex()); prepareValue(results); }
/** * Create an appropriate select start element based on our parameters. * @throws JspException * @since Struts 1.1 */ protected String renderSelectStartElement() throws JspException { StringBuffer results = new StringBuffer("<select"); prepareAttribute(results, "name", prepareName()); prepareAttribute(results, "accesskey", getAccesskey()); if (multiple != null) { results.append(" multiple=\"multiple\""); } prepareAttribute(results, "size", getSize()); prepareAttribute(results, "tabindex", getTabindex()); results.append(prepareEventHandlers()); results.append(prepareStyles()); prepareOtherAttributes(results); results.append(">"); return results.toString(); }
/** * Generate an HTML <textarea> tag. * @throws JspException * @since Struts 1.1 */ protected String renderTextareaElement() throws JspException { StringBuffer results = new StringBuffer("<textarea"); prepareAttribute(results, "name", prepareName()); prepareAttribute(results, "accesskey", getAccesskey()); prepareAttribute(results, "tabindex", getTabindex()); prepareAttribute(results, "cols", getCols()); prepareAttribute(results, "rows", getRows()); results.append(prepareEventHandlers()); results.append(prepareStyles()); prepareOtherAttributes(results); results.append(">"); results.append(this.renderData()); results.append("</textarea>"); return results.toString(); }
/** * Renders a fully formed <input> element. * @throws JspException * @since Struts 1.2 */ protected String renderInputElement() throws JspException { StringBuffer results = new StringBuffer("<input"); prepareAttribute(results, "type", this.type); prepareAttribute(results, "name", prepareName()); prepareAttribute(results, "accesskey", getAccesskey()); prepareAttribute(results, "accept", getAccept()); prepareAttribute(results, "maxlength", getMaxlength()); prepareAttribute(results, "size", getCols()); prepareAttribute(results, "tabindex", getTabindex()); prepareValue(results); results.append(this.prepareEventHandlers()); results.append(this.prepareStyles()); prepareOtherAttributes(results); results.append(this.getElementClose()); return results.toString(); }
/** * Render the value element * @param results The StringBuffer that output will be appended to. */ protected String prepareValue(StringBuffer results) throws JspException { String value = (this.value == null) ? this.constant : this.value; if (value == null) { JspException e = new JspException(messages.getMessage("multiboxTag.value")); pageContext.setAttribute(Globals.EXCEPTION_KEY, e, PageContext.REQUEST_SCOPE); throw e; } prepareAttribute(results, "value", TagUtils.getInstance().filter(value)); return value; }
/** * Render the appropriately encoded URI. * * @exception JspException if a JSP exception has occurred */ public int doStartTag() throws JspException { // Print this element to our output writer StringBuffer results = new StringBuffer("<frame"); prepareAttribute(results, "src", calculateURL()); prepareAttribute(results, "name", getFrameName()); if (noresize) { results.append(" noresize=\"noresize\""); } prepareAttribute(results, "scrolling", getScrolling()); prepareAttribute(results, "marginheight", getMarginheight()); prepareAttribute(results, "marginwidth", getMarginwidth()); prepareAttribute(results, "frameborder", getFrameborder()); prepareAttribute(results, "longdesc", getLongdesc()); results.append(prepareStyles()); prepareOtherAttributes(results); results.append(getElementClose()); TagUtils.getInstance().write(pageContext,results.toString()); return (SKIP_BODY); }
/** * Renders an HTML <input type="radio"> element. * @param serverValue The data to be used in the tag's <code>value</code> * attribute and sent to the server when the form is submitted. * @param checkedValue If the serverValue equals this value the radio button * will be checked. * @return A radio input element. * @throws JspException * @since Struts 1.1 */ protected String renderRadioElement(String serverValue, String checkedValue) throws JspException { StringBuffer results = new StringBuffer("<input type=\"radio\""); prepareAttribute(results, "name", prepareName()); prepareAttribute(results, "accesskey", getAccesskey()); prepareAttribute(results, "tabindex", getTabindex()); prepareAttribute(results, "value", TagUtils.getInstance().filter(serverValue)); if (serverValue.equals(checkedValue)) { results.append(" checked=\"checked\""); } results.append(prepareEventHandlers()); results.append(prepareStyles()); prepareOtherAttributes(results); results.append(getElementClose()); return results.toString(); }
String srcurl = url(tmp); if (srcurl != null) { prepareAttribute(results, "src", response.encodeURL(srcurl)); prepareAttribute(results, "lowsrcurl", response.encodeURL(lowsrcurl)); prepareAttribute(results, "name", getImageName()); prepareAttribute(results, "height", getHeight()); prepareAttribute(results, "width", getWidth()); prepareAttribute(results, "align", getAlign()); prepareAttribute(results, "border", getBorder()); prepareAttribute(results, "hspace", getHspace()); prepareAttribute(results, "vspace", getVspace()); prepareAttribute(results, "ismap", getIsmap()); prepareAttribute(results, "usemap", getUsemap()); results.append(prepareStyles()); results.append(prepareEventHandlers());
/** * Prepares the style attributes for inclusion in the component's HTML tag. * @return The prepared String for inclusion in the HTML tag. * @exception JspException if invalid attributes are specified */ protected String prepareStyles() throws JspException { StringBuffer styles = new StringBuffer(); boolean errorsExist = doErrorsExist(); if (errorsExist && getErrorStyleId() != null) { prepareAttribute(styles , "id", getErrorStyleId()); } else { prepareAttribute(styles , "id", getStyleId()); } if (errorsExist && getErrorStyle() != null) { prepareAttribute(styles , "style", getErrorStyle()); } else { prepareAttribute(styles , "style", getStyle()); } if (errorsExist && getErrorStyleClass() != null) { prepareAttribute(styles , "class", getErrorStyleClass()); } else { prepareAttribute(styles , "class", getStyleClass()); } prepareAttribute(styles , "title", message(getTitle(), getTitleKey())); prepareAttribute(styles , "alt", message(getAlt(), getAltKey())); return styles.toString(); }
/** * Generate the required input tag. * <p> * Support for indexed property since Struts 1.1 * * @exception JspException if a JSP exception has occurred */ public int doStartTag() throws JspException { // Create an appropriate "input" element based on our parameters StringBuffer results = new StringBuffer("<input type=\"checkbox\""); prepareAttribute(results, "name", prepareName()); prepareAttribute(results, "accesskey", getAccesskey()); prepareAttribute(results, "tabindex", getTabindex()); prepareAttribute(results, "value", getValue()); if (isChecked()) { results.append(" checked=\"checked\""); } results.append(prepareEventHandlers()); results.append(prepareStyles()); prepareOtherAttributes(results); results.append(getElementClose()); // Print this field to our output writer TagUtils.getInstance().write(pageContext, results.toString()); // Continue processing this page this.text = null; return (EVAL_BODY_TAG); }
/** * Render an input element for this tag. * * @exception JspException if a JSP exception has occurred */ public int doEndTag() throws JspException { // Create an appropriate "input" element based on our parameters StringBuffer results = new StringBuffer("<input type=\"checkbox\""); prepareAttribute(results, "name", prepareName()); prepareAttribute(results, "accesskey", getAccesskey()); prepareAttribute(results, "tabindex", getTabindex()); String value = prepareValue(results); prepareChecked(results, value); results.append(prepareEventHandlers()); results.append(prepareStyles()); prepareOtherAttributes(results); results.append(getElementClose()); TagUtils.getInstance().write(pageContext, results.toString()); return EVAL_PAGE; }
/** * Render the beginning of the hyperlink. * <p> * Support for indexed property since Struts 1.1 * * @exception JspException if a JSP exception has occurred */ public int doStartTag() throws JspException { // Generate the opening anchor element StringBuffer results = new StringBuffer("<a"); // Special case for name anchors prepareAttribute(results, "name", getLinkName()); // * @since Struts 1.1 if (getLinkName() == null || getForward() != null || getHref() != null || getPage() != null || getAction() != null) { prepareAttribute(results, "href", calculateURL()); } prepareAttribute(results, "target", getTarget()); prepareAttribute(results, "accesskey", getAccesskey()); prepareAttribute(results, "tabindex", getTabindex()); results.append(prepareStyles()); results.append(prepareEventHandlers()); prepareOtherAttributes(results); results.append(">"); TagUtils.getInstance().write(pageContext, results.toString()); // Evaluate the body of this tag this.text = null; return (EVAL_BODY_TAG); }
/** * Process the end of this tag. * <p> * Support for Indexed property since Struts 1.1 * * @exception JspException if a JSP exception has occurred */ public int doEndTag() throws JspException { // Generate an HTML element StringBuffer results = new StringBuffer(); results.append(getElementOpen()); prepareAttribute(results, "name", prepareName()); prepareButtonAttributes(results); results.append(prepareEventHandlers()); results.append(prepareStyles()); prepareOtherAttributes(results); results.append(getElementClose()); TagUtils.getInstance().write(pageContext, results.toString()); return (EVAL_PAGE); }
/** * Prepares the focus event handlers, appending them to the the given * StringBuffer. * @param handlers The StringBuffer that output will be appended to. */ protected void prepareFocusEvents(StringBuffer handlers) { prepareAttribute(handlers, "onblur", getOnblur()); prepareAttribute(handlers, "onfocus", getOnfocus()); // Get the parent FormTag (if necessary) FormTag formTag = null; if ((doDisabled && !getDisabled()) || (doReadonly && !getReadonly())) { formTag = (FormTag)pageContext.getAttribute(Constants.FORM_KEY, PageContext.REQUEST_SCOPE); } // Format Disabled if (doDisabled) { boolean formDisabled = formTag == null ? false : formTag.isDisabled(); if (formDisabled || getDisabled()) { handlers.append(" disabled=\"disabled\""); } } // Format Read Only if (doReadonly) { boolean formReadOnly = formTag == null ? false : formTag.isReadonly(); if (formReadOnly || getReadonly()) { handlers.append(" readonly=\"readonly\""); } } }