本文整理汇总了Java中com.opensymphony.xwork2.util.LocalizedTextUtil类的典型用法代码示例。如果您正苦于以下问题:Java LocalizedTextUtil类的具体用法?Java LocalizedTextUtil怎么用?Java LocalizedTextUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocalizedTextUtil类属于com.opensymphony.xwork2.util包,在下文中一共展示了LocalizedTextUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getErrorMessage
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
@Override
protected String getErrorMessage() {
if ((namespace != null) && (namespace.trim().length() > 0)) {
String contextPath = ServletActionContext.getRequest().getContextPath();
return LocalizedTextUtil.findDefaultText(
"struts.exception.missing-package-action.with-context",
Locale.getDefault(),
new String[]{namespace, actionName, contextPath}
);
} else {
return super.getErrorMessage();
}
}
开发者ID:txazo,项目名称:struts2,代码行数:14,代码来源:StrutsActionProxy.java
示例2: loadCustomResourceBundles
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
private void loadCustomResourceBundles(LocatableProperties props) {
String bundles = props.getProperty(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES);
if (bundles != null && bundles.length() > 0) {
StringTokenizer customBundles = new StringTokenizer(bundles, ", ");
while (customBundles.hasMoreTokens()) {
String name = customBundles.nextToken();
try {
LOG.trace("Loading global messages from [{}]", name);
LocalizedTextUtil.addDefaultResourceBundle(name);
} catch (Exception e) {
LOG.error("Could not find messages file {}.properties. Skipping", name);
}
}
}
}
开发者ID:txazo,项目名称:struts2,代码行数:17,代码来源:DefaultBeanSelectionProvider.java
示例3: getLocaleFromParam
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
/**
* Creates a Locale object from the request param, which might
* be already a Local or a String
*
* @param requestedLocale the parameter from the request
* @return the Locale
*/
protected Locale getLocaleFromParam(Object requestedLocale) {
Locale locale = null;
if (requestedLocale != null) {
locale = (requestedLocale instanceof Locale) ?
(Locale) requestedLocale :
LocalizedTextUtil.localeFromString(requestedLocale.toString(), null);
if (locale != null) {
LOG.debug("Applied request locale: {}", locale);
}
}
if (locale != null && !Arrays.asList(Locale.getAvailableLocales()).contains(locale)) {
locale = Locale.getDefault();
}
return locale;
}
开发者ID:txazo,项目名称:struts2,代码行数:24,代码来源:I18nInterceptor.java
示例4: cleanUp
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
public void cleanUp() {
Set<String> names = files.keySet();
for (String name : names) {
List<FileItem> items = files.get(name);
for (FileItem item : items) {
if (LOG.isDebugEnabled()) {
String msg = LocalizedTextUtil.findText(this.getClass(), "struts.messages.removing.file",
Locale.ENGLISH, "no.message.found", new Object[]{name, item});
LOG.debug(msg);
}
if (!item.isInMemory()) {
item.delete();
}
}
}
}
开发者ID:txazo,项目名称:struts2,代码行数:17,代码来源:JakartaMultiPartRequest.java
示例5: getText
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
/**
* Gets a message based on a key using the supplied args, as defined in
* {@link java.text.MessageFormat}, or, if the message is not found, a supplied
* default value is returned. Instead of using the value stack in the ActionContext
* this version of the getText() method uses the provided value stack.
*
* @param key the resource bundle key that is to be searched for
* @param defaultValue the default value which will be returned if no message is found
* @param args a list args to be used in a {@link java.text.MessageFormat} message
* @param stack the value stack to use for finding the text
* @return the message as found in the resource bundle, or defaultValue if none is found
*/
public String getText(String key, String defaultValue, List<?> args, ValueStack stack) {
Object[] argsArray = ((args != null) ? args.toArray() : null);
Locale locale;
if (stack == null){
locale = getLocale();
}else{
locale = (Locale) stack.getContext().get(ActionContext.LOCALE);
}
if (locale == null) {
locale = getLocale();
}
if (clazz != null) {
return LocalizedTextUtil.findText(clazz, key, locale, defaultValue, argsArray, stack);
} else {
return LocalizedTextUtil.findText(bundle, key, locale, defaultValue, argsArray, stack);
}
}
开发者ID:txazo,项目名称:struts2,代码行数:30,代码来源:TextProviderSupport.java
示例6: onSetUpInTransaction
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void onSetUpInTransaction() {
LocalizedTextUtil.addDefaultResourceBundle(Constants.BUNDLE_KEY);
// ActionContext.getContext().setSession(new HashMap<Object, Object>());
// change the port on the mailSender so it doesn't conflict with an
// existing SMTP server on localhost
// JavaMailSenderImpl mailSender = (JavaMailSenderImpl)
// applicationContext.getBean("mailSender");
mailSender.setPort(2525);
mailSender.setHost("localhost");
// populate the request so getRequest().getSession() doesn't fail in
// BaseAction.java
setUpActionContext();
}
开发者ID:gisgraphy,项目名称:gisgraphy,代码行数:19,代码来源:BaseActionTestCase.java
示例7: init_PreloadConfiguration
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
private Container init_PreloadConfiguration() {
// 源码解析: 获取容器
Container container = getContainer();
// 源码解析: 是否reload资源文件
boolean reloadi18n = Boolean.valueOf(container.getInstance(String.class, StrutsConstants.STRUTS_I18N_RELOAD));
LocalizedTextUtil.setReloadBundles(reloadi18n);
// 源码解析: 是否开发模式
boolean devMode = Boolean.valueOf(container.getInstance(String.class, StrutsConstants.STRUTS_DEVMODE));
LocalizedTextUtil.setDevMode(devMode);
return container;
}
开发者ID:txazo,项目名称:struts2,代码行数:15,代码来源:Dispatcher.java
示例8: createContextMap
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
/**
* Merge all application and servlet attributes into a single <tt>HashMap</tt> to represent the entire
* <tt>Action</tt> context.
*
* @param requestMap a Map of all request attributes.
* @param parameterMap a Map of all request parameters.
* @param sessionMap a Map of all session attributes.
* @param applicationMap a Map of all servlet context attributes.
* @param request the HttpServletRequest object.
* @param response the HttpServletResponse object.
* @return a HashMap representing the <tt>Action</tt> context.
*
* @since 2.3.17
*/
public HashMap<String,Object> createContextMap(Map requestMap,
Map parameterMap,
Map sessionMap,
Map applicationMap,
HttpServletRequest request,
HttpServletResponse response) {
HashMap<String, Object> extraContext = new HashMap<>();
extraContext.put(ActionContext.PARAMETERS, new HashMap(parameterMap));
extraContext.put(ActionContext.SESSION, sessionMap);
extraContext.put(ActionContext.APPLICATION, applicationMap);
Locale locale;
if (defaultLocale != null) {
locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale());
} else {
locale = request.getLocale();
}
extraContext.put(ActionContext.LOCALE, locale);
extraContext.put(StrutsStatics.HTTP_REQUEST, request);
extraContext.put(StrutsStatics.HTTP_RESPONSE, response);
extraContext.put(StrutsStatics.SERVLET_CONTEXT, servletContext);
// helpers to get access to request/session/application scope
extraContext.put("request", requestMap);
extraContext.put("session", sessionMap);
extraContext.put("application", applicationMap);
extraContext.put("parameters", parameterMap);
AttributeMap attrMap = new AttributeMap(extraContext);
extraContext.put("attr", attrMap);
return extraContext;
}
开发者ID:txazo,项目名称:struts2,代码行数:50,代码来源:Dispatcher.java
示例9: prepare
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
/**
* Prepare a request, including setting the encoding and locale.
*
* @param request The request
* @param response The response
*/
public void prepare(HttpServletRequest request, HttpServletResponse response) {
String encoding = null;
if (defaultEncoding != null) {
encoding = defaultEncoding;
}
// check for Ajax request to use UTF-8 encoding strictly http://www.w3.org/TR/XMLHttpRequest/#the-send-method
if ("XMLHttpRequest".equals(request.getHeader("X-Requested-With"))) {
encoding = "UTF-8";
}
Locale locale = null;
if (defaultLocale != null) {
locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale());
}
if (encoding != null) {
applyEncoding(request, encoding);
}
if (locale != null) {
response.setLocale(locale);
}
if (paramsWorkaroundEnabled) {
request.getParameter("foo"); // simply read any parameter (existing or not) to "prime" the request
}
}
开发者ID:txazo,项目名称:struts2,代码行数:34,代码来源:Dispatcher.java
示例10: validToken
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
/**
* Checks for a valid transaction token in the current request params. If a valid token is found, it is
* removed so the it is not valid again.
*
* @return false if there was no token set into the params (check by looking for {@link #TOKEN_NAME_FIELD}), true if a valid token is found
*/
public static boolean validToken() {
String tokenName = getTokenName();
if (tokenName == null) {
LOG.debug("No token name found -> Invalid token ");
return false;
}
String token = getToken(tokenName);
if (token == null) {
LOG.debug("No token found for token name {} -> Invalid token ", tokenName);
return false;
}
Map session = ActionContext.getContext().getSession();
String tokenSessionName = buildTokenSessionAttributeName(tokenName);
String sessionToken = (String) session.get(tokenSessionName);
if (!token.equals(sessionToken)) {
if (LOG.isWarnEnabled()) {
LOG.warn(LocalizedTextUtil.findText(TokenHelper.class, "struts.internal.invalid.token", ActionContext.getContext().getLocale(), "Form token {0} does not match the session token {1}.", new Object[]{
token, sessionToken
}));
}
return false;
}
// remove the token so it won't be used again
session.remove(tokenSessionName);
return true;
}
开发者ID:txazo,项目名称:struts2,代码行数:41,代码来源:TokenHelper.java
示例11: start
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
public boolean start(Writer writer) {
boolean result = super.start(writer);
try {
String name = this.findString(this.name, "name", "Resource bundle name is required. Example: foo or foo_en");
ResourceBundle bundle = (ResourceBundle) findValue("getTexts('" + name + "')");
if (bundle == null) {
bundle = LocalizedTextUtil.findResourceBundle(name, (Locale) getStack().getContext().get(ActionContext.LOCALE));
}
if (bundle != null) {
final Locale locale = (Locale) getStack().getContext().get(ActionContext.LOCALE);
TextProviderFactory tpf = new TextProviderFactory();
container.inject(tpf);
textProvider = tpf.createInstance(bundle, new LocaleProvider() {
public Locale getLocale() {
return locale;
}
});
getStack().push(textProvider);
pushed = true;
}
} catch (Exception e) {
throw new StrutsException("Could not find the bundle " + name, e);
}
return result;
}
开发者ID:txazo,项目名称:struts2,代码行数:30,代码来源:I18n.java
示例12: getText
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
public String getText(String key, List<?> args) {
Object[] params;
if (args != null) {
params = args.toArray();
} else {
params = EMPTY_ARGS;
}
return LocalizedTextUtil.findDefaultText(key, ActionContext.getContext().getLocale(), params);
}
开发者ID:txazo,项目名称:struts2,代码行数:11,代码来源:DefaultTextProvider.java
示例13: getErrorMessage
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
protected String getErrorMessage() {
if ((namespace != null) && (namespace.trim().length() > 0)) {
return LocalizedTextUtil.findDefaultText(
XWorkMessages.MISSING_PACKAGE_ACTION_EXCEPTION,
Locale.getDefault(),
new String[]{namespace, actionName});
} else {
return LocalizedTextUtil.findDefaultText(
XWorkMessages.MISSING_ACTION_EXCEPTION,
Locale.getDefault(),
new String[]{actionName});
}
}
开发者ID:txazo,项目名称:struts2,代码行数:14,代码来源:DefaultActionProxy.java
示例14: hasKey
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
/**
* Checks if a key is available in the resource bundles associated with this action.
* The resource bundles are searched, starting with the one associated
* with this particular action, and testing all its superclasses' bundles.
* It will stop once a bundle is found that contains the given text. This gives
* a cascading style that allow global texts to be defined for an application base
* class.
*/
public boolean hasKey(String key) {
String message;
if (clazz != null) {
message = LocalizedTextUtil.findText(clazz, key, getLocale(), null, new Object[0] );
} else {
message = LocalizedTextUtil.findText(bundle, key, getLocale(), null, new Object[0]);
}
return message != null;
}
开发者ID:txazo,项目名称:struts2,代码行数:18,代码来源:TextProviderSupport.java
示例15: configMessages
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
private void configMessages() {
if (messagesConfigured)
return;
LocalizedTextUtil.addDefaultResourceBundle("hibernateplugin-messages");
for (String messageFile:getMessageFiles()) {
LocalizedTextUtil.addDefaultResourceBundle(messageFile);
}
messagesConfigured = true;
}
开发者ID:javalover123,项目名称:full-hibernate-plugin-for-struts2,代码行数:10,代码来源:InternalHibernatePluginInterceptor.java
示例16: buildErrorMessage
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
protected String buildErrorMessage(Throwable e, Object[] args) {
String errorKey = "struts.messages.upload.error." + e.getClass().getSimpleName();
LOG.debug("Preparing error message for key: [{}]", errorKey);
return LocalizedTextUtil.findText(this.getClass(), errorKey, defaultLocale, e.getMessage(), args);
}
开发者ID:txazo,项目名称:struts2,代码行数:6,代码来源:MultiPartRequestWrapper.java
示例17: register
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
public void register(ContainerBuilder builder, LocatableProperties props) {
// 源码解析: 给容器中的bean添加"default"别名
alias(ObjectFactory.class, StrutsConstants.STRUTS_OBJECTFACTORY, builder, props);
alias(ActionFactory.class, StrutsConstants.STRUTS_OBJECTFACTORY_ACTIONFACTORY, builder, props);
alias(ResultFactory.class, StrutsConstants.STRUTS_OBJECTFACTORY_RESULTFACTORY, builder, props);
alias(ConverterFactory.class, StrutsConstants.STRUTS_OBJECTFACTORY_CONVERTERFACTORY, builder, props);
alias(InterceptorFactory.class, StrutsConstants.STRUTS_OBJECTFACTORY_INTERCEPTORFACTORY, builder, props);
alias(ValidatorFactory.class, StrutsConstants.STRUTS_OBJECTFACTORY_VALIDATORFACTORY, builder, props);
alias(UnknownHandlerFactory.class, StrutsConstants.STRUTS_OBJECTFACTORY_UNKNOWNHANDLERFACTORY, builder, props);
alias(FileManagerFactory.class, StrutsConstants.STRUTS_FILE_MANAGER_FACTORY, builder, props, Scope.SINGLETON);
alias(XWorkConverter.class, StrutsConstants.STRUTS_XWORKCONVERTER, builder, props);
alias(CollectionConverter.class, StrutsConstants.STRUTS_CONVERTER_COLLECTION, builder, props);
alias(ArrayConverter.class, StrutsConstants.STRUTS_CONVERTER_ARRAY, builder, props);
alias(DateConverter.class, StrutsConstants.STRUTS_CONVERTER_DATE, builder, props);
alias(NumberConverter.class, StrutsConstants.STRUTS_CONVERTER_NUMBER, builder, props);
alias(StringConverter.class, StrutsConstants.STRUTS_CONVERTER_STRING, builder, props);
alias(ConversionPropertiesProcessor.class, StrutsConstants.STRUTS_CONVERTER_PROPERTIES_PROCESSOR, builder, props);
alias(ConversionFileProcessor.class, StrutsConstants.STRUTS_CONVERTER_FILE_PROCESSOR, builder, props);
alias(ConversionAnnotationProcessor.class, StrutsConstants.STRUTS_CONVERTER_ANNOTATION_PROCESSOR, builder, props);
alias(TypeConverterCreator.class, StrutsConstants.STRUTS_CONVERTER_CREATOR, builder, props);
alias(TypeConverterHolder.class, StrutsConstants.STRUTS_CONVERTER_HOLDER, builder, props);
alias(TextProvider.class, StrutsConstants.STRUTS_XWORKTEXTPROVIDER, builder, props, Scope.PROTOTYPE);
alias(LocaleProvider.class, StrutsConstants.STRUTS_LOCALE_PROVIDER, builder, props);
alias(ActionProxyFactory.class, StrutsConstants.STRUTS_ACTIONPROXYFACTORY, builder, props);
alias(ObjectTypeDeterminer.class, StrutsConstants.STRUTS_OBJECTTYPEDETERMINER, builder, props);
alias(ActionMapper.class, StrutsConstants.STRUTS_MAPPER_CLASS, builder, props);
alias(MultiPartRequest.class, StrutsConstants.STRUTS_MULTIPART_PARSER, builder, props, Scope.PROTOTYPE);
alias(FreemarkerManager.class, StrutsConstants.STRUTS_FREEMARKER_MANAGER_CLASSNAME, builder, props);
alias(VelocityManager.class, StrutsConstants.STRUTS_VELOCITY_MANAGER_CLASSNAME, builder, props);
alias(UrlRenderer.class, StrutsConstants.STRUTS_URL_RENDERER, builder, props);
alias(ActionValidatorManager.class, StrutsConstants.STRUTS_ACTIONVALIDATORMANAGER, builder, props);
alias(ValueStackFactory.class, StrutsConstants.STRUTS_VALUESTACKFACTORY, builder, props);
alias(ReflectionProvider.class, StrutsConstants.STRUTS_REFLECTIONPROVIDER, builder, props);
alias(ReflectionContextFactory.class, StrutsConstants.STRUTS_REFLECTIONCONTEXTFACTORY, builder, props);
alias(PatternMatcher.class, StrutsConstants.STRUTS_PATTERNMATCHER, builder, props);
alias(ContentTypeMatcher.class, StrutsConstants.STRUTS_CONTENT_TYPE_MATCHER, builder, props);
alias(StaticContentLoader.class, StrutsConstants.STRUTS_STATIC_CONTENT_LOADER, builder, props);
alias(UnknownHandlerManager.class, StrutsConstants.STRUTS_UNKNOWN_HANDLER_MANAGER, builder, props);
alias(UrlHelper.class, StrutsConstants.STRUTS_URL_HELPER, builder, props);
alias(TextParser.class, StrutsConstants.STRUTS_EXPRESSION_PARSER, builder, props);
alias(DispatcherErrorHandler.class, StrutsConstants.STRUTS_DISPATCHER_ERROR_HANDLER, builder, props);
/** Checker is used mostly in interceptors, so there be one instance of checker per interceptor with Scope.PROTOTYPE **/
alias(ExcludedPatternsChecker.class, StrutsConstants.STRUTS_EXCLUDED_PATTERNS_CHECKER, builder, props, Scope.PROTOTYPE);
alias(AcceptedPatternsChecker.class, StrutsConstants.STRUTS_ACCEPTED_PATTERNS_CHECKER, builder, props, Scope.PROTOTYPE);
// 源码解析: 开发模式的特殊处理
switchDevMode(props);
// Convert Struts properties into XWork properties
// 源码解析: 复制Struts的部分配置到XWork配置
convertIfExist(props, StrutsConstants.STRUTS_LOG_MISSING_PROPERTIES, XWorkConstants.LOG_MISSING_PROPERTIES);
convertIfExist(props, StrutsConstants.STRUTS_ENABLE_OGNL_EXPRESSION_CACHE, XWorkConstants.ENABLE_OGNL_EXPRESSION_CACHE);
convertIfExist(props, StrutsConstants.STRUTS_ENABLE_OGNL_EVAL_EXPRESSION, XWorkConstants.ENABLE_OGNL_EVAL_EXPRESSION);
convertIfExist(props, StrutsConstants.STRUTS_ALLOW_STATIC_METHOD_ACCESS, XWorkConstants.ALLOW_STATIC_METHOD_ACCESS);
convertIfExist(props, StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, XWorkConstants.RELOAD_XML_CONFIGURATION);
convertIfExist(props, StrutsConstants.STRUTS_EXCLUDED_CLASSES, XWorkConstants.OGNL_EXCLUDED_CLASSES);
convertIfExist(props, StrutsConstants.STRUTS_EXCLUDED_PACKAGE_NAME_PATTERNS, XWorkConstants.OGNL_EXCLUDED_PACKAGE_NAME_PATTERNS);
convertIfExist(props, StrutsConstants.STRUTS_EXCLUDED_PACKAGE_NAMES, XWorkConstants.OGNL_EXCLUDED_PACKAGE_NAMES);
convertIfExist(props, StrutsConstants.STRUTS_ADDITIONAL_EXCLUDED_PATTERNS, XWorkConstants.ADDITIONAL_EXCLUDED_PATTERNS);
convertIfExist(props, StrutsConstants.STRUTS_ADDITIONAL_ACCEPTED_PATTERNS, XWorkConstants.ADDITIONAL_ACCEPTED_PATTERNS);
convertIfExist(props, StrutsConstants.STRUTS_OVERRIDE_EXCLUDED_PATTERNS, XWorkConstants.OVERRIDE_EXCLUDED_PATTERNS);
convertIfExist(props, StrutsConstants.STRUTS_OVERRIDE_ACCEPTED_PATTERNS, XWorkConstants.OVERRIDE_ACCEPTED_PATTERNS);
// 源码解析: 添加默认的资源文件com/opensymphony/xwork2/xwork-messages和org/apache/struts2/struts-messages
LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/struts-messages");
// 源码解析: 添加自定义的资源文件, 由struts.custom.i18n.resources指定
loadCustomResourceBundles(props);
}
开发者ID:txazo,项目名称:struts2,代码行数:81,代码来源:DefaultBeanSelectionProvider.java
示例18: getTexts
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
public ResourceBundle getTexts(String bundleName) {
return LocalizedTextUtil.findResourceBundle(bundleName, ActionContext.getContext().getLocale());
}
开发者ID:txazo,项目名称:struts2,代码行数:4,代码来源:DefaultTextProvider.java
示例19: intercept
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
@Override public String intercept(ActionInvocation invocation) throws Exception {
ActionConfig config = invocation.getProxy().getConfig();
ActionContext ac = invocation.getInvocationContext();
Object action = invocation.getAction();
// get the action's parameters
final Map<String, String> parameters = config.getParams();
if (parameters.containsKey(aliasesKey)) {
String aliasExpression = parameters.get(aliasesKey);
ValueStack stack = ac.getValueStack();
Object obj = stack.findValue(aliasExpression);
if (obj != null && obj instanceof Map) {
//get secure stack
ValueStack newStack = valueStackFactory.createValueStack(stack);
boolean clearableStack = newStack instanceof ClearableValueStack;
if (clearableStack) {
//if the stack's context can be cleared, do that to prevent OGNL
//from having access to objects in the stack, see XW-641
((ClearableValueStack)newStack).clearContextValues();
Map<String, Object> context = newStack.getContext();
ReflectionContextState.setCreatingNullObjects(context, true);
ReflectionContextState.setDenyMethodExecution(context, true);
ReflectionContextState.setReportingConversionErrors(context, true);
//keep locale from original context
context.put(ActionContext.LOCALE, stack.getContext().get(ActionContext.LOCALE));
}
// override
Map aliases = (Map) obj;
for (Object o : aliases.entrySet()) {
Map.Entry entry = (Map.Entry) o;
String name = entry.getKey().toString();
String alias = (String) entry.getValue();
Object value = stack.findValue(name);
if (null == value) {
// workaround
Map<String, Object> contextParameters = ActionContext.getContext().getParameters();
if (null != contextParameters) {
value = contextParameters.get(name);
}
}
if (null != value) {
try {
newStack.setValue(alias, value);
} catch (RuntimeException e) {
if (devMode) {
String developerNotification = LocalizedTextUtil.findText(ParametersInterceptor.class, "devmode.notification", ActionContext.getContext().getLocale(), "Developer Notification:\n{0}", new Object[]{
"Unexpected Exception caught setting '" + entry.getKey() + "' on '" + action.getClass() + ": " + e.getMessage()
});
LOG.error(developerNotification);
if (action instanceof ValidationAware) {
((ValidationAware) action).addActionMessage(developerNotification);
}
}
}
}
}
if (clearableStack && (stack.getContext() != null) && (newStack.getContext() != null))
stack.getContext().put(ActionContext.CONVERSION_ERRORS, newStack.getContext().get(ActionContext.CONVERSION_ERRORS));
} else {
LOG.debug("invalid alias expression: {}", aliasesKey);
}
}
return invocation.invoke();
}
开发者ID:txazo,项目名称:struts2,代码行数:74,代码来源:AliasInterceptor.java
示例20: getText
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入依赖的package包/类
@Override
public String getText(String key, String defaultValue, List<?> args, ValueStack stack) {
Object[] argsArray = args != null ? args.toArray() : null;
Locale locale = (Locale) stack.getContext().get(ActionContext.LOCALE);
return LocalizedTextUtil.findText(resourceBundle, key, locale, defaultValue, argsArray, stack);
}
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:7,代码来源:ResourceBundleTextProviderAdapter.java
注:本文中的com.opensymphony.xwork2.util.LocalizedTextUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论