Search in sources :

Example 41 with ActionContext

use of com.opensymphony.xwork2.ActionContext in project onebusaway-application-modules by camsys.

the class ResourceUrlFunction method getExternalUrlForResource.

public String getExternalUrlForResource(String resourcePath) {
    Locale locale = Locale.getDefault();
    ActionContext ctx = ActionContext.getContext();
    if (ctx != null)
        locale = ctx.getLocale();
    return _resourceService.getExternalUrlForResource(resourcePath, locale);
}
Also used : Locale(java.util.Locale) ActionContext(com.opensymphony.xwork2.ActionContext)

Example 42 with ActionContext

use of com.opensymphony.xwork2.ActionContext in project qi4j-sdk by Qi4j.

the class ConstraintViolationInterceptor method intercept.

@Override
public String intercept(ActionInvocation invocation) throws Exception {
    ActionContext invocationContext = invocation.getInvocationContext();
    ValueStack stack = invocationContext.getValueStack();
    Object action = invocation.getAction();
    if (action instanceof ValidationAware) {
        ValidationAware va = (ValidationAware) action;
        HashMap<Object, Object> propertyOverrides = new HashMap<Object, Object>();
        for (Map.Entry<String, FieldConstraintViolations> fieldViolations : fieldConstraintViolations(invocationContext).entrySet()) {
            addConstraintViolationFieldErrors(stack, va, fieldViolations.getKey(), fieldViolations.getValue());
            propertyOverrides.put(fieldViolations.getKey(), getOverrideExpr(invocation, fieldViolations.getValue()));
        }
        // if there were some errors, put the original (fake) values in place right before the result
        if (!propertyOverrides.isEmpty()) {
            overrideActionValues(invocation, stack, propertyOverrides);
        }
    }
    return invocation.invoke();
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) HashMap(java.util.HashMap) ValidationAware(com.opensymphony.xwork2.ValidationAware) ActionContext(com.opensymphony.xwork2.ActionContext) Collections.emptyMap(java.util.Collections.emptyMap) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ActionContext (com.opensymphony.xwork2.ActionContext)32 ValueStack (com.opensymphony.xwork2.util.ValueStack)15 AgiActionName (org.onebusaway.probablecalls.AgiActionName)7 ActionProxy (com.opensymphony.xwork2.ActionProxy)6 ServletActionContext (org.apache.struts2.ServletActionContext)6 ActionInvocation (com.opensymphony.xwork2.ActionInvocation)5 List (java.util.List)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 HashMap (java.util.HashMap)4 Locale (java.util.Locale)4 Map (java.util.Map)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 XWorkRequestAttributes (org.onebusaway.presentation.impl.users.XWorkRequestAttributes)3 StopBean (org.onebusaway.transit_data.model.StopBean)3 IOException (java.io.IOException)2 SessionAware (org.apache.struts2.interceptor.SessionAware)2 Test (org.junit.Test)2 BookmarkWithStopsBean (org.onebusaway.presentation.model.BookmarkWithStopsBean)2 NameBean (org.onebusaway.transit_data.model.NameBean)2 RouteBean (org.onebusaway.transit_data.model.RouteBean)2