本文整理汇总了Java中com.opensymphony.xwork2.util.LocalizedTextUtil.findText方法的典型用法代码示例。如果您正苦于以下问题:Java LocalizedTextUtil.findText方法的具体用法?Java LocalizedTextUtil.findText怎么用?Java LocalizedTextUtil.findText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.opensymphony.xwork2.util.LocalizedTextUtil
的用法示例。
在下文中一共展示了LocalizedTextUtil.findText方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
}
}
示例2: 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);
}
}
示例3: 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;
}
示例4: 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);
}
示例5: 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();
}
示例6: 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);
}
示例7: 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(getTexts(), key, locale, defaultValue, argsArray, stack);
}
示例8: buildErrorMessage
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入方法依赖的package包/类
/**
* Build error message.
*
* @param e the Throwable/Exception
* @param args arguments
* @return error message
*/
private String buildErrorMessage(Throwable e, Object[] args) {
String errorKey = "struts.message.upload.error." + e.getClass().getSimpleName();
LOG.debug("Preparing error message for key: [{}]", errorKey);
return LocalizedTextUtil.findText(this.getClass(), errorKey, defaultLocale, e.getMessage(), args);
}
示例9: buildMessage
import com.opensymphony.xwork2.util.LocalizedTextUtil; //导入方法依赖的package包/类
/**
* Build action message.
*
* @param e the Throwable/Exception
* @param args arguments
* @return action message
*/
private String buildMessage(Throwable e, Object[] args) {
String messageKey = "struts.message.upload.message." + e.getClass().getSimpleName();
LOG.debug("Preparing message for key: [{}]", messageKey);
return LocalizedTextUtil.findText(this.getClass(), messageKey, defaultLocale, e.getMessage(), args);
}