本文整理了Java中com.opensymphony.xwork2.util.ValueStack.push()
方法的一些代码示例,展示了ValueStack.push()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ValueStack.push()
方法的具体详情如下:
包路径:com.opensymphony.xwork2.util.ValueStack
类名称:ValueStack
方法名:push
[英]Put this object onto the top of the stack
[中]将此对象放在堆栈顶部
代码示例来源:origin: org.apache.struts.xwork/xwork-core
/**
* Default implementation to handle ExceptionHolder publishing. Pushes given ExceptionHolder on the stack.
* Subclasses may override this to customize publishing.
*
* @param invocation The invocation to publish Exception for.
* @param exceptionHolder The exceptionHolder wrapping the Exception to publish.
*/
protected void publishException(ActionInvocation invocation, ExceptionHolder exceptionHolder) {
invocation.getStack().push(exceptionHolder);
}
代码示例来源:origin: org.beangle.struts2/beangle-struts2-view
protected Object getValue(Object obj, String property) {
stack.push(obj);
try {
Object value = stack.findValue(property);
if (value instanceof Number) { return MessageFormat.format(NumberFormat, value); }
return value;
} finally {
stack.pop();
}
}
代码示例来源:origin: org.onebusaway/onebusaway-presentation
@Override
public boolean end(Writer writer, String body) {
ValueStack stack = getStack();
if (_iterator != null) {
Object value = stack.pop();
if (_lastKey == null || !_lastKey.equals(body)) {
_currentGroup = new ArrayList<Object>();
_groups.add(_currentGroup);
}
_currentGroup.add(value);
_lastKey = body;
}
if (_iterator != null && _iterator.hasNext()) {
Object currentValue = _iterator.next();
stack.push(currentValue);
return true;
} else {
putInContext(_groups);
return super.end(writer, "");
}
}
}
代码示例来源:origin: org.onebusaway/onebusaway-presentation
@Override
public boolean start(Writer writer) {
ValueStack stack = getStack();
if (_value == null)
_value = "top";
_iterator = MakeIterator.convert(findValue(_value));
// get the first
if ((_iterator != null) && _iterator.hasNext()) {
Object currentValue = _iterator.next();
stack.push(currentValue);
return true;
} else {
super.end(writer, "");
return false;
}
}
代码示例来源:origin: org.onebusaway/onebusaway-phone
@Override
protected AgiActionName executeTemplate(ActionContext context,
AgiTemplate template) throws Exception {
if (_message != null) {
ValueStack stack = context.getValueStack();
MessageSource source = new MessageSource(_message,_nextAction);
stack.push(source);
}
return super.executeTemplate(context, template);
}
代码示例来源:origin: OneBusAway/onebusaway-application-modules
@Override
public boolean start(Writer writer) {
ValueStack stack = getStack();
if (_value == null)
_value = "top";
_iterator = MakeIterator.convert(findValue(_value));
// get the first
if ((_iterator != null) && _iterator.hasNext()) {
Object currentValue = _iterator.next();
stack.push(currentValue);
return true;
} else {
super.end(writer, "");
return false;
}
}
代码示例来源:origin: org.apache.struts.xwork/xwork-core
public void testCreateNullObjectsIsFalseByDefault() {
ValueStack vs = ActionContext.getContext().getValueStack();
vs.push(new MapHolder(Collections.emptyMap()));
assertNull(vs.findValue("map[key]"));
}
代码示例来源:origin: org.apache.struts.xwork/xwork-core
public void testMapContentsAreReturned() {
ValueStack vs = ActionContext.getContext().getValueStack();
vs.push(new MapHolder(Collections.singletonMap("key", "value")));
assertEquals("value", vs.findValue("map['key']"));
}
代码示例来源: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.apache.struts.xwork/xwork-core
public void testNullIsNotReturnedWhenCreateNullObjectsIsSpecified() {
ValueStack vs = ActionContext.getContext().getValueStack();
vs.push(new MapHolder(Collections.emptyMap()));
ReflectionContextState.setCreatingNullObjects(vs.getContext(), true);
Object value = vs.findValue("map['key']");
assertNotNull(value);
assertSame(Object.class, value.getClass());
}
代码示例来源:origin: org.apache.struts.xwork/xwork-core
public void testNullIsReturnedWhenCreateNullObjectsIsSpecifiedAsFalse() {
ValueStack vs = ActionContext.getContext().getValueStack();
vs.push(new MapHolder(Collections.emptyMap()));
ReflectionContextState.setCreatingNullObjects(vs.getContext(), false);
assertNull(vs.findValue("map['key']"));
}
代码示例来源: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.xwork/xwork-core
@Override
public String intercept(ActionInvocation invocation) throws Exception {
Object action = invocation.getAction();
if (action instanceof ModelDriven) {
ModelDriven modelDriven = (ModelDriven) action;
ValueStack stack = invocation.getStack();
Object model = modelDriven.getModel();
if (model != null) {
stack.push(model);
}
if (refreshModelBeforeResult) {
invocation.addPreResultListener(new RefreshModelBeforeResult(modelDriven, model));
}
}
return invocation.invoke();
}
代码示例来源:origin: org.apache.struts.xwork/xwork-core
public void init(ActionProxy proxy) {
this.proxy = proxy;
Map<String, Object> contextMap = createContextMap();
// Setting this so that other classes, like object factories, can use the ActionProxy and other
// contextual information to operate
ActionContext actionContext = ActionContext.getContext();
if (actionContext != null) {
actionContext.setActionInvocation(this);
}
createAction(contextMap);
if (pushAction) {
stack.push(action);
contextMap.put("action", action);
}
invocationContext = new ActionContext(contextMap);
invocationContext.setName(proxy.getActionName());
createInterceptors(proxy);
}
代码示例来源:origin: com.googlecode.struts2-conversation/struts2-conversation-scope-plugin
/**
* {@inheritDoc}
*/
public void prepare() {
ActionContext actionContext = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest) actionContext.get(StrutsStatics.HTTP_REQUEST);
ConversationContextManager contextManager = scopeContainer.getComponent(HttpConversationContextManagerProvider.class).getManager(request);
try {
scopeContainer.getComponent(ConversationProcessor.class).processConversations(new StrutsConversationAdapter(actionContext.getActionInvocation(), contextManager));
Map<String, Map<String, String>> stackItem = new HashMap<String, Map<String, String>>();
stackItem.put(StrutsScopeConstants.CONVERSATION_ID_MAP_STACK_KEY, ConversationAdapter.getAdapter().getViewContext());
actionContext.getValueStack().push(stackItem);
} catch (ConversationException e) {
LOG.error("Programmatic Conversation error in Prepare method", e);
}
}
代码示例来源:origin: org.apache.struts.xwork/xwork-core
public void validate(Object object) throws ValidationException {
String fieldName = getFieldName();
Object value = this.getFieldValue(fieldName, object);
if (value == null) {
log.warn("The visited object is null, VisitorValidator will not be able to handle validation properly. Please make sure the visited object is not null for VisitorValidator to function properly");
return;
}
ValueStack stack = ActionContext.getContext().getValueStack();
stack.push(object);
String visitorContext = (context == null) ? ActionContext.getContext().getName() : context;
if (value instanceof Collection) {
Collection coll = (Collection) value;
Object[] array = coll.toArray();
validateArrayElements(array, fieldName, visitorContext);
} else if (value instanceof Object[]) {
Object[] array = (Object[]) value;
validateArrayElements(array, fieldName, visitorContext);
} else {
validateObject(fieldName, value, visitorContext);
}
stack.pop();
}
代码示例来源:origin: org.apache.struts.xwork/xwork-core
private void validateObject(String fieldName, Object o, String visitorContext) throws ValidationException {
ValueStack stack = ActionContext.getContext().getValueStack();
stack.push(o);
ValidatorContext validatorContext;
if (appendPrefix) {
validatorContext = new AppendingValidatorContext(getValidatorContext(), o, fieldName, getMessage(o));
} else {
ValidatorContext parent = getValidatorContext();
validatorContext = new DelegatingValidatorContext(parent, DelegatingValidatorContext.makeTextProvider(o, parent), parent);
}
actionValidatorManager.validate(o, visitorContext, validatorContext);
stack.pop();
}
代码示例来源: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();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!