当前位置: 首页>>代码示例>>Java>>正文


Java TagUtils类代码示例

本文整理汇总了Java中org.apache.struts.taglib.TagUtils的典型用法代码示例。如果您正苦于以下问题:Java TagUtils类的具体用法?Java TagUtils怎么用?Java TagUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TagUtils类属于org.apache.struts.taglib包,在下文中一共展示了TagUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doRedirect

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 * Redirect to the given path converting exceptions to JspException.
 * @param path The path to redirect to.
 * @throws JspException
 * @since Struts 1.2
 */
protected void doRedirect(String path) throws JspException {
    HttpServletRequest request =
        (HttpServletRequest) pageContext.getRequest();
        
    HttpServletResponse response =
        (HttpServletResponse) pageContext.getResponse();
        
    try {
        if (path.startsWith("/")) {
            path = request.getContextPath() + path;
        }
        
        response.sendRedirect(response.encodeRedirectURL(path));
        
    } catch (Exception e) {
        TagUtils.getInstance().saveException(pageContext, e);
        throw new JspException(
            messages.getMessage("forward.redirect", name, e.toString()));
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:ForwardTag.java

示例2: condition

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 * Evaluate the condition that is being tested by this particular tag,
 * and return <code>true</code> if there is at least one message in the
 * class or for the property specified.
 * This method must be implemented by concrete subclasses.
 *
 * @param desired Desired outcome for a true result
 *
 * @exception JspException if a JSP exception occurs
 */
protected boolean condition(boolean desired) throws JspException {
    ActionMessages am = null;

    String key = name;
    if (message != null && "true".equalsIgnoreCase(message)){
       key = Globals.MESSAGE_KEY;
    }

    try {
        am = TagUtils.getInstance().getActionMessages(pageContext, key);
        
    } catch (JspException e) {
        TagUtils.getInstance().saveException(pageContext, e);
        throw e;
    }

    Iterator iterator = (property == null) ? am.get() : am.get(property);

    return (iterator.hasNext() == desired);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:MessagesPresentTag.java

示例3: doStartTag

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 * Overriding method of the heart of the tag. Gets the relative property
 * and tells the JSP engine to evaluate its body content.
 *
 * @return int JSP continuation directive.
 */
public int doStartTag() throws JspException {
  // set the original property
  originalProperty = property;

  HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
  String nesting = NestedPropertyHelper.getAdjustedProperty(request, property);

  if (id != null) {
    // use it as a scripting variable instead
    pageContext.setAttribute(id, nesting);

  } else {
    /* write output, filtering if required */
    if (this.filter) {
      TagUtils.getInstance().write(pageContext, TagUtils.getInstance().filter(nesting));
    } else {
      TagUtils.getInstance().write(pageContext, nesting);
    }
  }

  /* continue with page processing */
  return (SKIP_BODY);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:NestedWriteNestingTag.java

示例4: handleMultipleHeaders

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 * Expose an array of header values.
 * @throws JspException
 * @since Struts 1.2
 */
protected void handleMultipleHeaders() throws JspException {
    ArrayList values = new ArrayList();
    Enumeration items =
        ((HttpServletRequest) pageContext.getRequest()).getHeaders(name);
        
    while (items.hasMoreElements()){
        values.add(items.nextElement());
    }
        
    if (values.isEmpty() && (this.value != null)){
        values.add(this.value);
    }
        
    String headers[] = new String[values.size()];
    if (headers.length == 0) {
        JspException e =
            new JspException(messages.getMessage("header.get", name));
        TagUtils.getInstance().saveException(pageContext, e);
        throw e;
    }
    
    pageContext.setAttribute(id, values.toArray(headers));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:HeaderTag.java

示例5: handleSingleHeader

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 * Expose a single header value.
 * @throws JspException
 * @since Struts 1.2
 */
protected void handleSingleHeader() throws JspException {
    String value =
        ((HttpServletRequest) pageContext.getRequest()).getHeader(name);

    if ((value == null) && (this.value != null)) {
        value = this.value;
    }

    if (value == null) {
        JspException e =
            new JspException(messages.getMessage("header.get", name));
        TagUtils.getInstance().saveException(pageContext, e);
        throw e;
    }
    
    pageContext.setAttribute(id, value);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:HeaderTag.java

示例6: retrieveFormatString

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 * Retrieve format string from message bundle and return null if
 * message not found or message string.
 *
 * @param formatKey value to use as key to search message in bundle
 * @exception JspException if a JSP exception has occurred
 */
protected String retrieveFormatString(String formatKey) throws JspException {
    String result =
        TagUtils.getInstance().message(
            pageContext,
            this.bundle,
            this.localeKey,
            formatKey);

    if ((result != null)
        && !(result.startsWith("???") && result.endsWith("???"))) {

        return result;

    } else {
        return null;
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:WriteTag.java

示例7: doStartTag

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 * 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);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:FrameTag.java

示例8: doEndTag

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 * Render the end of this form.
 *
 * @exception JspException if a JSP exception has occurred
 */
public int doEndTag() throws JspException {

    // Remove the page scope attributes we created
    pageContext.removeAttribute(Constants.SELECT_KEY);

    // Render a tag representing the end of our current form
    StringBuffer results = new StringBuffer();
    if (saveBody != null) {
        results.append(saveBody);
        saveBody = null;
    }
    results.append("</select>");

    TagUtils.getInstance().write(pageContext, results.toString());

    return (EVAL_PAGE);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:SelectTag.java

示例9: doEndTag

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 * 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);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:SubmitTag.java

示例10: renderRadioElement

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 * Renders an HTML &lt;input type="radio"&gt; 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();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:RadioTag.java

示例11: doEndTag

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:MultiboxTag.java

示例12: renderBaseElement

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 * Render a fully formed HTML &lt;base&gt; element and return it as a String.
 * @param scheme The scheme used in the url (ie. http or https).
 * @param serverName
 * @param port
 * @param uri  The portion of the url from the protocol name up to the query 
 * string.
 * @return String An HTML &lt;base&gt; element.
 * @since Struts 1.1
 */
protected String renderBaseElement(
    String scheme,
    String serverName,
    int port,
    String uri) {
        
    StringBuffer tag = new StringBuffer("<base href=\"");
    tag.append(RequestUtils.createServerUriStringBuffer(scheme,serverName,port,uri).toString());

    tag.append("\"");
    
    if (this.target != null) {
        tag.append(" target=\"");
        tag.append(this.target);
        tag.append("\"");
    }
    
    if (TagUtils.getInstance().isXhtml(this.pageContext)) {
        tag.append(" />");
    } else {
        tag.append(">");
    }
    
    return tag.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:BaseTag.java

示例13: text

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 * Return the text to be displayed to the user for this option (if any).
 *
 * @exception JspException if an error occurs
 */
protected String text() throws JspException {
    String optionText = this.text;

    if ((optionText == null) && (this.key != null)) {
        optionText =
            TagUtils.getInstance().message(pageContext, bundle, locale, key);
    }

    // no body text and no key to lookup so display the value
    if (optionText == null) {
        optionText = this.value;    
    }

    return optionText;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:OptionTag.java

示例14: message

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 * Return the text specified by the literal value or the message resources
 * key, if any; otherwise return <code>null</code>.
 *
 * @param literal Literal text value or <code>null</code>
 * @param key Message resources key or <code>null</code>
 *
 * @exception JspException if both arguments are non-null
 */
protected String message(String literal, String key) throws JspException {

    if (literal != null) {
        if (key != null) {
            JspException e =
                new JspException(messages.getMessage("common.both"));
            TagUtils.getInstance().saveException(pageContext, e);
            throw e;
        } else {
            return (literal);
        }
    } else {
        if (key != null) {
            return TagUtils.getInstance().message(
                pageContext,
                getBundle(),
                getLocale(),
                key);
        } else {
            return null;
        }
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:BaseHandlerTag.java

示例15: getIndexValue

import org.apache.struts.taglib.TagUtils; //导入依赖的package包/类
/**
 *  Returns the index value for tags with 'true' value in 'indexed' attribute.
 *  @return the index value.
 *  @exception JspException if 'indexed' tag used outside of iterate tag.
 */
protected int getIndexValue() throws JspException {

    // look for outer iterate tag
    IterateTag iterateTag =
        (IterateTag) findAncestorWithClass(this, IterateTag.class);
    if (iterateTag != null) {
        return iterateTag.getIndex();
    }

    // Look for JSTL loops
    Integer i = getJstlLoopIndex();
    if (i != null) {
        return i.intValue();
    }

    // this tag should be nested in an IterateTag or JSTL loop tag, if it's not, throw exception
    JspException e =
         new JspException(messages.getMessage("indexed.noEnclosingIterate"));
    TagUtils.getInstance().saveException(pageContext, e);
    throw e;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:BaseHandlerTag.java


注:本文中的org.apache.struts.taglib.TagUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。