本文整理汇总了Java中org.apache.struts.config.ModuleConfig.getPrefix方法的典型用法代码示例。如果您正苦于以下问题:Java ModuleConfig.getPrefix方法的具体用法?Java ModuleConfig.getPrefix怎么用?Java ModuleConfig.getPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.struts.config.ModuleConfig
的用法示例。
在下文中一共展示了ModuleConfig.getPrefix方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRequestProcessor
import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
* <p>Look up and return the {@link RequestProcessor} responsible for the
* specified module, creating a new one if necessary.</p>
*
* @param config The module configuration for which to acquire and return
* a RequestProcessor.
* @return The {@link RequestProcessor} responsible for the specified
* module,
* @throws ServletException If we cannot instantiate a RequestProcessor
* instance a {@link UnavailableException} is
* thrown, meaning your application is not loaded
* and will not be available.
* @since Struts 1.1
*/
protected synchronized RequestProcessor getRequestProcessor(
ModuleConfig config) throws ServletException {
RequestProcessor processor = this.getProcessorForModule(config);
if (processor == null) {
try {
processor =
(RequestProcessor) RequestUtils.applicationInstance(config.getControllerConfig()
.getProcessorClass());
} catch (Exception e) {
throw new UnavailableException(
"Cannot initialize RequestProcessor of class "
+ config.getControllerConfig().getProcessorClass() + ": "
+ e);
}
processor.init(this, config);
String key = Globals.REQUEST_PROCESSOR_KEY + config.getPrefix();
getServletContext().setAttribute(key, processor);
}
return (processor);
}
示例2: getRequestProcessor
import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
* <p>Look up and return the {@link RequestProcessor} responsible for the
* specified module, creating a new one if necessary.</p>
*
* @param config The module configuration for which to
* acquire and return a RequestProcessor.
*
* @exception ServletException if we cannot instantiate a RequestProcessor
* instance
* @since Struts 1.1
*/
protected synchronized RequestProcessor getRequestProcessor(ModuleConfig config)
throws ServletException {
// :FIXME: Document UnavailableException?
RequestProcessor processor = this.getProcessorForModule(config);
if (processor == null) {
try {
processor =
(RequestProcessor) RequestUtils.applicationInstance(
config.getControllerConfig().getProcessorClass());
} catch (Exception e) {
throw new UnavailableException(
"Cannot initialize RequestProcessor of class "
+ config.getControllerConfig().getProcessorClass()
+ ": "
+ e);
}
processor.init(this, config);
String key = Globals.REQUEST_PROCESSOR_KEY + config.getPrefix();
getServletContext().setAttribute(key, processor);
}
return (processor);
}
示例3: doEndTag
import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
* Look up the ActionForward associated with the specified name, and
* perform a forward or redirect to that path as indicated.
*
* @throws JspException if a JSP exception has occurred
*/
public int doEndTag() throws JspException {
// Look up the desired ActionForward entry
ActionForward forward = null;
ModuleConfig config =
TagUtils.getInstance().getModuleConfig(pageContext);
if (config != null) {
forward = (ActionForward) config.findForwardConfig(name);
}
if (forward == null) {
JspException e =
new JspException(messages.getMessage("forward.lookup", name));
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
// Forward or redirect to the corresponding actual path
String path = forward.getPath();
path = config.getPrefix() + path;
if (forward.getRedirect()) {
this.doRedirect(path);
} else {
this.doForward(path);
}
// Skip the remainder of this page
return (SKIP_PAGE);
}
示例4: findOrCreateActionForm
import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
* <p> In the context of the given <code>ModuleConfig</code> and this
* <code>ActionContext</code>, look for an existing
* <code>ActionForm</code> in the specified scope. If one is found, return
* it; otherwise, create a new instance, add it to that scope, and then
* return it. </p>
*
* @param formName The name attribute of our ActionForm
* @param scopeName The scope identier (request, session)
* @return The ActionForm for this request
* @throws IllegalAccessException If object cannot be created
* @throws InstantiationException If object cannot be created
* @throws IllegalArgumentException If form config is missing from module
* or scopeName is invalid
*/
public ActionForm findOrCreateActionForm(String formName, String scopeName,
ModuleConfig moduleConfig)
throws IllegalAccessException, InstantiationException {
Map scope = this.getScope(scopeName);
ActionForm instance;
FormBeanConfig formBeanConfig =
moduleConfig.findFormBeanConfig(formName);
if (formBeanConfig == null) {
throw new IllegalArgumentException("No form config found under "
+ formName + " in module " + moduleConfig.getPrefix());
}
instance = (ActionForm) scope.get(formName);
// ISSUE: Can we recycle the existing instance (if any)?
if (instance != null) {
getLogger().trace("Found an instance in scope " + scopeName
+ "; test for reusability");
if (formBeanConfig.canReuse(instance)) {
return instance;
}
}
ActionForm form = formBeanConfig.createActionForm(this);
// ISSUE: Should we check this call to put?
scope.put(formName, form);
return form;
}
示例5: renderJavascript
import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
* Returns fully rendered JavaScript.
* @since Struts 1.2
*/
protected String renderJavascript() throws JspException {
StringBuffer results = new StringBuffer();
ModuleConfig config = TagUtils.getInstance().getModuleConfig(pageContext);
ValidatorResources resources =
(ValidatorResources) pageContext.getAttribute(
ValidatorPlugIn.VALIDATOR_KEY + config.getPrefix(),
PageContext.APPLICATION_SCOPE);
if (resources == null) {
throw new JspException(
"ValidatorResources not found in application scope under key \""
+ ValidatorPlugIn.VALIDATOR_KEY + config.getPrefix() + "\"");
}
Locale locale = TagUtils.getInstance().getUserLocale(this.pageContext, null);
Form form = resources.getForm(locale, formName);
if ("true".equalsIgnoreCase(dynamicJavascript) && form == null)
{
throw new JspException("No form found under '"
+ formName
+ "' in locale '"
+ locale
+ "'");
}
if (form != null) {
if ("true".equalsIgnoreCase(dynamicJavascript)) {
results.append(
this.createDynamicJavascript(config, resources, locale, form));
} else if ("true".equalsIgnoreCase(staticJavascript)) {
results.append(this.renderStartElement());
if ("true".equalsIgnoreCase(htmlComment)) {
results.append(HTML_BEGIN_COMMENT);
}
}
}
if ("true".equalsIgnoreCase(staticJavascript)) {
results.append(getJavascriptStaticMethods(resources));
}
if (form != null
&& ("true".equalsIgnoreCase(dynamicJavascript)
|| "true".equalsIgnoreCase(staticJavascript))) {
results.append(getJavascriptEnd());
}
return results.toString();
}
示例6: renderJavascript
import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
* Returns fully rendered JavaScript.
*
* @since Struts 1.2
*/
protected String renderJavascript()
throws JspException {
StringBuffer results = new StringBuffer();
ModuleConfig config =
TagUtils.getInstance().getModuleConfig(pageContext);
ValidatorResources resources =
(ValidatorResources) pageContext.getAttribute(
ValidatorPlugIn.VALIDATOR_KEY
+ config.getPrefix(), PageContext.APPLICATION_SCOPE);
if (resources == null) {
throw new JspException(
"ValidatorResources not found in application scope under key \""
+ ValidatorPlugIn.VALIDATOR_KEY + config.getPrefix() + "\"");
}
Locale locale =
TagUtils.getInstance().getUserLocale(this.pageContext, null);
Form form = null;
if ("true".equalsIgnoreCase(dynamicJavascript)) {
form = resources.getForm(locale, formName);
if (form == null) {
throw new JspException("No form found under '" + formName
+ "' in locale '" + locale
+ "'. A form must be defined in the "
+ "Commons Validator configuration when "
+ "dynamicJavascript=\"true\" is set.");
}
}
if (form != null) {
if ("true".equalsIgnoreCase(dynamicJavascript)) {
results.append(this.createDynamicJavascript(config, resources,
locale, form));
} else if ("true".equalsIgnoreCase(staticJavascript)) {
results.append(this.renderStartElement());
if ("true".equalsIgnoreCase(htmlComment)) {
results.append(HTML_BEGIN_COMMENT);
}
}
}
if ("true".equalsIgnoreCase(staticJavascript)) {
results.append(getJavascriptStaticMethods(resources));
}
if ((form != null)
&& ("true".equalsIgnoreCase(dynamicJavascript)
|| "true".equalsIgnoreCase(staticJavascript))) {
results.append(getJavascriptEnd());
}
return results.toString();
}
示例7: getPath
import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
protected String getPath(ActionContext context) {
ServletActionContext saContext = (ServletActionContext) context;
HttpServletRequest request = saContext.getRequest();
String path = null;
boolean extension = false;
// For prefix matching, match on the path info
path = (String) request.getAttribute(Constants.INCLUDE_PATH_INFO);
if ((path == null) || (path.length() == 0)) {
path = request.getPathInfo();
}
// For extension matching, match on the servlet path
if ((path == null) || (path.length() == 0)) {
path =
(String) request.getAttribute(Constants.INCLUDE_SERVLET_PATH);
if ((path == null) || (path.length() == 0)) {
path = request.getServletPath();
}
if ((path == null) || (path.length() == 0)) {
throw new IllegalArgumentException(
"No path information in request");
}
extension = true;
}
// Strip the module prefix and extension (if any)
ModuleConfig moduleConfig = saContext.getModuleConfig();
String prefix = moduleConfig.getPrefix();
if (!path.startsWith(prefix)) {
throw new IllegalArgumentException("Path does not start with '"
+ prefix + "'");
}
path = path.substring(prefix.length());
if (extension) {
int slash = path.lastIndexOf("/");
int period = path.lastIndexOf(".");
if ((period >= 0) && (period > slash)) {
path = path.substring(0, period);
}
}
return (path);
}
示例8: getProcessorForModule
import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
* <p>Returns the RequestProcessor for the given module or null if one does not
* exist. This method will not create a RequestProcessor.</p>
*
* @param config The ModuleConfig.
*/
private RequestProcessor getProcessorForModule(ModuleConfig config) {
String key = Globals.REQUEST_PROCESSOR_KEY + config.getPrefix();
return (RequestProcessor) getServletContext().getAttribute(key);
}
示例9: forward
import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
* <p>Create and return a <code>ForwardConfig</code> representing the
* specified module-relative destination.</p>
*
* @param context The context for this request
* @param moduleConfig The <code>ModuleConfig</code> for this request
* @param uri The module-relative URI to be the destination
*/
protected ForwardConfig forward(ActionContext context,
ModuleConfig moduleConfig, String uri) {
return (new ActionForward(null, uri, false, moduleConfig.getPrefix()));
}
示例10: includePath
import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
* <p>Returns the path to perform the include. Override this method to provide
* a different path.</p>
*
* @param actionContext The context for this request
* @param include The forward to be performed
* @since Struts 1.3.6
*/
protected String includePath(ActionContext actionContext, String include) {
ModuleConfig moduleConfig = actionContext.getModuleConfig();
return moduleConfig.getPrefix() + include;
}
示例11: getProcessorForModule
import org.apache.struts.config.ModuleConfig; //导入方法依赖的package包/类
/**
* <p>Returns the RequestProcessor for the given module or null if one
* does not exist. This method will not create a RequestProcessor.</p>
*
* @param config The ModuleConfig.
* @return The <code>RequestProcessor</code> for the given module, or
* <code>null</code> if one does not exist.
*/
private RequestProcessor getProcessorForModule(ModuleConfig config) {
String key = Globals.REQUEST_PROCESSOR_KEY + config.getPrefix();
return (RequestProcessor) getServletContext().getAttribute(key);
}