@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(); }
protected OgnlValueStack(ValueStack vs, XWorkConverter xworkConverter, CompoundRootAccessor accessor, boolean allowStaticAccess) { setRoot(xworkConverter, accessor, new CompoundRoot(vs.getRoot()), allowStaticAccess); }
/** * @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; }
for (Object o : stack.getRoot()) { if (o instanceof TextResourceProvider) { tp = ((TextResourceProvider) o).getTextResource(null);
/** * @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; }
@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(); }
@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; }
@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; }
@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(); }
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); } } } }
@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); } }
@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, ""); }
@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, ""); }
/** * 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(); }
/** * 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; }
/** * 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; }
boolean pop = false; if (!stack.getRoot().contains(object)) { stack.push(object); pop = true;
@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(); } } }
@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(); } } }
CompoundRoot root = stack.getRoot(); Action currentAction = (Action) invocation.getAction(); if (root.size() > 1 && isValidationAware(currentAction)) {