⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 paramcontextdatareplacelookupvalue.java

📁 这是一个mvc模式
💻 JAVA
字号:
package jsp.tags.dapact.lookup;

import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;
import jsp.tags.dapact.BaseDataBodyTagSupport;
import jsp.tags.dapact.BaseDataTagSupport;
import jsp.tags.dapact.conf.UserClassFactory;
/**
 * Title:        Data Aware Processing And Control Tags
 * Description:  Tag library for the processing and controlling the input and output of data.
 * Copyright:    LGPL (http://www.gnu.org/copyleft/lesser.html)
 * Compile Date: @compile_date@
 * @author Allen M Servedio
 * @amp_sign@version @VERSION@
 */

/**
 * This class implements lookuping of values such that it replaces delimited
 * parameters with parameter values from the HTTP request object, if not found
 * it will look in the contexts (page, request, session, and then servlet),
 * and finally it will look in the data objects.
 *
 * @todo rewrite to make one parameter driven class that uses properties as default.
 */
public class ParamContextDataReplaceLookupValue extends ParamContextReplaceLookupValue
{
  /**
   * Default constructor.
   */
  public ParamContextDataReplaceLookupValue()
  {
  }

  /**
   * Replace the parameter named with a value from the tag or page context. In this
   * function, it is replaced by looking for a similarily named parameter, then
   * looks in the contexts (page, request, session, and then servlet), and finally
   * looks in the tag heirarchy for data tags and queries them.
   *
   * <p>Make sure that value is a string.</p>
   *
   * @param key the key of the value to be saved.
   * @param name the name of the parameter to replace.
   * @param tag the tag that will be used to save the value.
   * @param pc the page context associated with the tag that is also a parameter. This
   *   will be used to search parameters and contexts (page, session, request, and servlet).
   *
   * @return a new value or null if not found.
   */
  protected String replaceParam(String key, String name, TagSupport tag, PageContext pc)
  {
    String result = super.replaceParam(key, name, tag, pc);
    if ((result == null) && (name != null) && (tag != null))
    {
      try
      {
        String dataTagName = null;
        if (tag instanceof BaseDataTagSupport)
        {
          dataTagName = ((BaseDataTagSupport)tag).getDataTagName();
        }
        else if (tag instanceof BaseDataBodyTagSupport)
        {
          dataTagName = ((BaseDataBodyTagSupport)tag).getDataTagName();
        }
        result = (String)LookupUtil.findValueInDataTag(name, dataTagName, tag);
      }
      catch (ClassCastException e)
      {
        // Catch this exception and log it and return null.
        UserClassFactory.getLogger().log("The attribute for the following name is not a String: " + name, e);
      }
    }
    return result;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -