use of com.opensymphony.xwork2.ActionInvocation in project bamboobsc by billchen198318.
the class BaseSimpleActionInfo method handlerActionAnnotations.
public void handlerActionAnnotations() {
if (this.actionAnnotations != null) {
return;
}
ActionInvocation actionInvocation = ActionContext.getContext().getActionInvocation();
this.actionAnnotations = actionInvocation.getAction().getClass().getAnnotations();
Method[] methods = actionInvocation.getAction().getClass().getMethods();
for (Method method : methods) {
if (this.actionMethodName.equals(method.getName())) {
this.actionMethodAnnotations = method.getAnnotations();
}
}
}
use of com.opensymphony.xwork2.ActionInvocation in project dhis2-core by dhis2.
the class I18nInterceptor method intercept.
@Override
public String intercept(ActionInvocation invocation) throws Exception {
Action action = (Action) invocation.getAction();
I18n i18n = i18nManager.getI18n(action.getClass());
I18nFormat i18nFormat = i18nManager.getI18nFormat();
Locale locale = localeManager.getCurrentLocale();
// ---------------------------------------------------------------------
// Make the objects available for web templates
// ---------------------------------------------------------------------
Map<String, Object> i18nMap = new HashMap<>(3);
i18nMap.put(KEY_I18N, i18n);
i18nMap.put(KEY_I18N_FORMAT, i18nFormat);
i18nMap.put(KEY_LOCALE, locale);
invocation.getStack().push(i18nMap);
// ---------------------------------------------------------------------
// Set the objects in the action class if the properties exist
// ---------------------------------------------------------------------
Map<?, ?> contextMap = invocation.getInvocationContext().getContextMap();
try {
Ognl.setValue(KEY_I18N, contextMap, action, i18n);
} catch (NoSuchPropertyException ignored) {
}
try {
Ognl.setValue(KEY_I18N_FORMAT, contextMap, action, i18nFormat);
} catch (NoSuchPropertyException ignored) {
}
try {
Ognl.setValue(KEY_LOCALE, contextMap, action, locale);
} catch (NoSuchPropertyException ignored) {
}
return invocation.invoke();
}
use of com.opensymphony.xwork2.ActionInvocation in project KeyBox by skavanagh.
the class ClickjackingInterceptor method intercept.
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ActionContext context = invocation.getInvocationContext();
HttpServletResponse response = (HttpServletResponse) context.get(StrutsStatics.HTTP_RESPONSE);
String headerValue = VALUE;
response.addHeader(HEADER, headerValue);
return invocation.invoke();
}
use of com.opensymphony.xwork2.ActionInvocation 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();
}
use of com.opensymphony.xwork2.ActionInvocation in project bamboobsc by billchen198318.
the class BaseSimpleActionInfo method execute.
public void execute() {
ActionInvocation actionInvocation = ActionContext.getContext().getActionInvocation();
HttpServletRequest request = ServletActionContext.getRequest();
String action = SimpleUtils.getStr(actionInvocation.getProxy().getActionName(), "");
String namespace = SimpleUtils.getStr(actionInvocation.getProxy().getNamespace(), "");
String remoteAddr = SimpleUtils.getStr(request.getRemoteAddr(), "");
String referer = SimpleUtils.getStr(request.getHeader("referer"), "");
this.actionMethodName = actionInvocation.getProxy().getMethod();
ActionContext.getContext().getSession().put(Constants.SESS_PAGE_INFO_ACTION_ByAction, action);
ActionContext.getContext().getSession().put(Constants.SESS_PAGE_INFO_NAMESPACE_ByAction, namespace);
ActionContext.getContext().getSession().put(Constants.SESS_PAGE_INFO_RemoteAddr_ByAction, remoteAddr);
ActionContext.getContext().getSession().put(Constants.SESS_PAGE_INFO_Referer_ByAction, referer);
this.pageInfoActionName = action;
this.pageInfoNamespace = namespace;
this.pageInfoRemoteAddr = remoteAddr;
this.pageInfoReferer = referer;
}
Aggregations