本文整理了Java中com.opensymphony.xwork2.util.ValueStack.getRoot()
方法的一些代码示例,展示了ValueStack.getRoot()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ValueStack.getRoot()
方法的具体详情如下:
包路径:com.opensymphony.xwork2.util.ValueStack
类名称:ValueStack
方法名:getRoot
[英]Get the CompoundRoot which holds the objects pushed onto the stack
[中]获取CompoundRoot,它保存推送到堆栈上的对象
代码示例来源:origin: stackoverflow.com
@Override
public String intercept(ActionInvocation ai) throws Exception {
ValueStack stack=ai.getStack();
Iterator it = stack.getRoot().iterator();
while( it.hasNext() )
{
Object objecto = it.next();
//LoginUsuario is my action class
if( objecto instanceof LoginUsuario )
{
LoginUsuario usuario = (LoginUsuario)objecto;
usuario.setUsername( usuario.getUsername().toUpperCase() );
usuario.setPassword( usuario.getPassword().toUpperCase() );
}
}
return ai.invoke();
}
代码示例来源:origin: org.apache.struts.xwork/xwork-core
protected OgnlValueStack(ValueStack vs, XWorkConverter xworkConverter, CompoundRootAccessor accessor, boolean allowStaticAccess) {
setRoot(xworkConverter, accessor, new CompoundRoot(vs.getRoot()), allowStaticAccess);
}
代码示例来源:origin: com.github.hazendaz/displaytag
/**
* @see LocaleResolver#resolveLocale(PageContext)
*/
@Override
public Locale resolveLocale(PageContext pageContext)
{
Locale result = null;
ValueStack stack = ActionContext.getContext().getValueStack();
Iterator<Object> iterator = stack.getRoot().iterator();
while (iterator.hasNext())
{
Object o = iterator.next();
if (o instanceof LocaleProvider)
{
LocaleProvider lp = (LocaleProvider) o;
result = lp.getLocale();
break;
}
}
if (result == null)
{
log.debug("Missing LocalProvider actions, init locale to default");
result = Locale.getDefault();
}
return result;
}
代码示例来源:origin: org.beangle.struts2/beangle-struts2-view
for (Object o : stack.getRoot()) {
if (o instanceof TextResourceProvider) {
tp = ((TextResourceProvider) o).getTextResource(null);
代码示例来源:origin: com.github.hazendaz/displaytag
/**
* @see I18nResourceProvider#getResource(String, String, Tag, javax.servlet.jsp.PageContext)
*/
@Override
public String getResource(String resourceKey, String defaultValue, Tag tag, PageContext pageContext)
{
// if resourceKey isn't defined either, use defaultValue
String key = (resourceKey != null) ? resourceKey : defaultValue;
String message = null;
ValueStack stack = TagUtils.getStack(pageContext);
Iterator<Object> iterator = stack.getRoot().iterator();
while (iterator.hasNext())
{
Object o = iterator.next();
if (o instanceof TextProvider)
{
TextProvider tp = (TextProvider) o;
message = tp.getText(key, null, (String) null);
break;
}
}
// if user explicitly added a titleKey we guess this is an error
if (message == null && resourceKey != null)
{
log.debug(Messages.getString("Localization.missingkey", resourceKey)); //$NON-NLS-1$
message = UNDEFINED_KEY + resourceKey + UNDEFINED_KEY;
}
return message;
}
代码示例来源:origin: org.apache.struts.xwork/xwork-core
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ValueStack stack = invocation.getStack();
CompoundRoot root = stack.getRoot();
if (shouldCopyStack(invocation, root)) {
copyStack(invocation, root);
}
return invocation.invoke();
}
代码示例来源:origin: org.nuiton/nuiton-validator
@Override
public String getMessage(Object object) {
boolean pop = false;
if (useSensitiveContext && !stack.getRoot().contains(c)) {
stack.push(c);
pop = true;
}
String message = super.getMessage(object);
if (pop) {
stack.pop();
}
return message;
}
代码示例来源:origin: org.nuiton.jaxx/jaxx-runtime-api
@Override
public String getMessage(Object object) {
boolean pop = false;
if (useSensitiveContext && !stack.getRoot().contains(c)) {
stack.push(c);
pop = true;
}
String message = super.getMessage(object);
if (pop) {
stack.pop();
}
return message;
}
代码示例来源:origin: org.entando.entando/entando-core-engine
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ValueStack stack = invocation.getStack();
CompoundRoot root = stack.getRoot();
if (root.size() >= this.compoundRootMinSize && isChainResult(invocation)) {
List<CompoundRoot> list = new ArrayList<CompoundRoot>(root);
list.remove(0);
Collections.reverse(list);
Map<String, Object> ctxMap = invocation.getInvocationContext().getContextMap();
Iterator<CompoundRoot> iterator = list.iterator();
int index = 1; // starts with 1, 0 has been removed
while (iterator.hasNext()) {
index = index + 1;
Object o = iterator.next();
if (o != null) {
if (!(o instanceof Unchainable)) {
reflectionProvider.copy(o, invocation.getAction(), ctxMap, excludes, includes);
}
} else {
LOG.warn("compound root element at index " + index + " is null");
}
}
}
return invocation.invoke();
}
代码示例来源:origin: org.apache.struts.xwork/xwork-core
public void beforeResult(ActionInvocation invocation, String resultCode) {
ValueStack stack = invocation.getStack();
CompoundRoot root = stack.getRoot();
boolean needsRefresh = true;
Object newModel = action.getModel();
// Check to see if the new model instance is already on the stack
for (Object item : root) {
if (item.equals(newModel)) {
needsRefresh = false;
break;
}
}
// Add the new model on the stack
if (needsRefresh) {
// Clear off the old model instance
if (originalModel != null) {
root.remove(originalModel);
}
if (newModel != null) {
stack.push(newModel);
}
}
}
}
代码示例来源:origin: org.apache.struts/struts2-tiles-plugin
@Override
public Object evaluate(String expression, Request request) {
try {
HttpServletRequest httpRequest = ServletUtil.getServletRequest(request).getRequest();
ActionContext ctx = ServletActionContext.getActionContext(httpRequest);
if (ctx == null) {
LOG.error("Cannot obtain HttpServletRequest from [{}]", request.getClass().getName());
throw new ConfigurationException("There is no ActionContext for current request!");
}
OgnlUtil ognlUtil = ctx.getContainer().getInstance(OgnlUtil.class);
LOG.debug("Trying evaluate expression [{}] using OgnlUtil's getValue", expression);
Object result = ognlUtil.getValue(expression, ctx.getContextMap(), ctx.getValueStack().getRoot());
LOG.debug("Final result of evaluating expression [{}] is: {}", expression, result);
return result;
} catch (OgnlException e) {
throw new EvaluationException(e);
}
}
代码示例来源:origin: org.onebusaway/onebusaway-presentation
@Override
public boolean end(Writer writer, String body) {
if (_key != null) {
ValueStack stack = getStack();
CompoundRoot root = stack.getRoot();
TextProvider textProvider = null;
for (Object obj : root) {
if (obj instanceof TextProvider) {
textProvider = (TextProvider) obj;
break;
}
}
if (textProvider != null) {
String message = textProvider.getText(_key, _arguments);
if (message != null) {
try {
writer.write(message);
} catch (IOException e) {
LOG.error("Could not write out tag", e);
}
}
}
}
return super.end(writer, "");
}
代码示例来源:origin: OneBusAway/onebusaway-application-modules
@Override
public boolean end(Writer writer, String body) {
if (_key != null) {
ValueStack stack = getStack();
CompoundRoot root = stack.getRoot();
TextProvider textProvider = null;
for (Object obj : root) {
if (obj instanceof TextProvider) {
textProvider = (TextProvider) obj;
break;
}
}
if (textProvider != null) {
String message = textProvider.getText(_key, _arguments);
if (message != null) {
try {
writer.write(message);
} catch (IOException e) {
LOG.error("Could not write out tag", e);
}
}
}
}
return super.end(writer, "");
}
代码示例来源:origin: org.seasar.xwork/s2xwork2
/**
* S2ComponentMapをValueStackに追加します。
*
*/
public String intercept(ActionInvocation invocation) throws Exception {
if (container == null && SingletonS2ContainerFactory.hasContainer()) {
container = SingletonS2ContainerFactory.getContainer();
}
Map map = new S2ComponentMap(container.getRoot());
ActionContext.getContext().getValueStack().getRoot().add(map);
return invocation.invoke();
}
代码示例来源:origin: org.apache.struts.xwork/xwork-core
/**
* Return the field value named <code>name</code> from <code>object</code>,
* <code>object</code> should have the appropriate getter/setter.
*
* @param name name of the field
* @param object to search field name on
* @return Object as field value
* @throws ValidationException
*/
protected Object getFieldValue(String name, Object object) throws ValidationException {
boolean pop = false;
if (!stack.getRoot().contains(object)) {
stack.push(object);
pop = true;
}
Object retVal = stack.findValue(name);
if (pop) {
stack.pop();
}
return retVal;
}
代码示例来源:origin: org.apache.struts/struts2-gxp-plugin
/**
* Iterates over GXP parameters, pulls value from value stack for each
* parameter, and appends the values to an argument list which will
* be passed to a method on a GXP.
*
* @param overrides parameter map pushed onto the value stack
*
* @return list of arguments
*/
List getArgListFromValueStack(Map overrides) {
ValueStack valueStack = valueStackFactory.createValueStack(ActionContext.getContext().getValueStack());
// add default values to the bottom of the stack. if no action provides
// a getter for a param, the default value will be used.
valueStack.getRoot().add(this.defaultValues);
// push override parameters onto the stack.
if (overrides != null && !overrides.isEmpty()) {
valueStack.push(overrides);
}
List args = new ArrayList(params.size());
for (Param param : getParams()) {
try {
args.add(valueStack.findValue(param.getName(), param.getType()));
} catch (Exception e) {
throw new RuntimeException("Exception while finding '" + param.getName() + "'.", e);
}
}
return args;
}
代码示例来源:origin: org.apache.struts.xwork/xwork-core
boolean pop = false;
if (!stack.getRoot().contains(object)) {
stack.push(object);
pop = true;
代码示例来源:origin: org.nuiton/nuiton-validator
@Override
public void validateWhenNotSkip(Object object) throws ValidationException {
booleans = initParams(Boolean.class, booleanParams, EXTRA_BOOLEAN_PARAM_ENTRY_PATTERN);
shorts = initParams(Short.class, shortParams, EXTRA_SHORT_PARAM_ENTRY_PATTERN);
ints = initParams(Integer.class, intParams, EXTRA_INT_PARAM_ENTRY_PATTERN);
longs = initParams(Long.class, longParams, EXTRA_LONG_PARAM_ENTRY_PATTERN);
doubles = initParams(Double.class, doubleParams, EXTRA_DOUBLE_PARAM_ENTRY_PATTERN);
strings = initParams(String.class, stringParams, EXTRA_STRING_PARAM_ENTRY_PATTERN);
boolean pop = false;
if (!stack.getRoot().contains(this)) {
stack.push(this);
pop = true;
}
try {
super.validateWhenNotSkip(object);
} finally {
if (pop) {
stack.pop();
}
}
}
代码示例来源:origin: org.nuiton.jaxx/jaxx-runtime-api
@Override
public void validate(Object object) throws ValidationException {
booleans = initParams(Boolean.class, booleanParams, EXTRA_BOOLEAN_PARAM_ENTRY_PATTERN);
shorts = initParams(Short.class, shortParams, EXTRA_SHORT_PARAM_ENTRY_PATTERN);
ints = initParams(Integer.class, intParams, EXTRA_INT_PARAM_ENTRY_PATTERN);
longs = initParams(Long.class, longParams, EXTRA_LONG_PARAM_ENTRY_PATTERN);
doubles = initParams(Double.class, doubleParams, EXTRA_DOUBLE_PARAM_ENTRY_PATTERN);
strings = initParams(String.class, stringParams, EXTRA_STRING_PARAM_ENTRY_PATTERN);
boolean pop = false;
if (!stack.getRoot().contains(this)) {
stack.push(this);
pop = true;
}
try {
super.validate(object);
} finally {
if (pop) {
stack.pop();
}
}
}
代码示例来源:origin: stackoverflow.com
CompoundRoot root = stack.getRoot();
Action currentAction = (Action) invocation.getAction();
if (root.size() > 1 && isValidationAware(currentAction)) {
内容来源于网络,如有侵权,请联系作者删除!