📄 lookupvaluebyparamcontextdata.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@
*/
/**
* Looks up the value by looking in the parameter list in the request, then the contexts,
* and finally the data objects.
* @todo rewrite to make one parameter driven class that uses properties as default.
*/
public class LookupValueByParamContextData extends LookupValueByParamContext
{
/**
* Default constructor...
*/
public LookupValueByParamContextData()
{
}
/**
* This function will be called by the tags when they want to lookup a general
* non-String object - in this case, it returns the value of a HTTP request parameter,
* if that is null it looks in the contexts (page, request, session, and then application [servlet]),
* or if that is also null look in the tag data objects for the value.
*
* @param key the key of the value to be saved.
* @param value the value to be added - this will be overridden by what is returned by
* this function.
* @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 the lookedup value or null if not found.
*/
public Object lookupValue(String key, Object value, TagSupport tag, PageContext pc)
{
Object result = super.lookupValue(key, value, tag, pc);
if ((result == null) && (key != null) && (tag != null))
{
String dataTagName = null;
if (tag instanceof BaseDataTagSupport)
{
dataTagName = ((BaseDataTagSupport)tag).getDataTagName();
}
else if (tag instanceof BaseDataBodyTagSupport)
{
dataTagName = ((BaseDataBodyTagSupport)tag).getDataTagName();
}
result = LookupUtil.findValueInDataTag(key, dataTagName, tag);
}
return result;
}
/**
* This function will be called by the tags when they want to lookup a string object
* (most common case: storing attributes) - in this case, it returns the value of a HTTP request parameter,
* if that is null it looks in the contexts (page, request, session, and then application [servlet]),
* or if that is also null look in the tag data objects for the value.
*
* @param key the key of the value to be saved.
* @param value the value to be added - this will be overridden by what is returned by
* this function.
* @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 the lookedup value.
*/
public String lookupValue(String key, String value, TagSupport tag, PageContext pc)
{
String result = super.lookupValue(key, value, tag, pc);
if ((result == null) && (key != 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(key, dataTagName, tag);
}
catch (ClassCastException e)
{
// Catch this exception and log it and return null.
UserClassFactory.getLogger().log("The lookup value for the following name is not a String: " + key, e);
}
}
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -