public class DateConverter extends StrutsTypeConverter { private DateFormat dateFormat; { ActionContext ctx = ActionContext.getContext(); ActionSupport action = (ActionSupport) ctx.getActionInvocation().getAction(); String formatString = action.getText("dateformat.ui"); dateFormat = new SimpleDateFormat(formatString); } public Object convertFromString(Map context, String[] values, Class toClass) { String input = values[0]; try { Date date = dateFormat.parse(input); Calendar cal = Calendar.getInstance(); cal.setTime(date); return cal; } catch (ParseException e) { return null; } } public String convertToString(Map context, Object object) { Calendar cal = (Calendar) object; return dateFormat.format(cal.getTime()); } }
HttpServletResponse response = ServletActionContext.getResponse(); ActionContext context = ActionContext.getContext(); ActionInvocation invocation = context.getActionInvocation();
/** * @param ac The action context * @return the parameters from the action mapping in the context. If none found, returns * an empty map. */ protected Map<String, String> retrieveParameters(ActionContext ac) { ActionConfig config = ac.getActionInvocation().getProxy().getConfig(); if (config != null) { return config.getParams(); } else { return Collections.emptyMap(); } }
protected void logUserInteraction(Object... objects) { Map<String, Object> entry = _userInteractionLoggingService.isInteractionLoggedForCurrentUser(); if (entry == null) return; ActionContext context = ActionContext.getContext(); ActionInvocation invocation = context.getActionInvocation(); ActionProxy proxy = invocation.getProxy(); entry.put("interface", "phone"); entry.put("namespace", proxy.getNamespace()); entry.put("actionName", proxy.getActionName()); entry.put("method", proxy.getMethod()); if( objects.length % 2 != 0 ) throw new IllegalStateException("expected an even number of arguments"); for( int i=0; i<objects.length; i+= 2) entry.put(objects[i].toString(),objects[i+1]); _userInteractionLoggingService.logInteraction(entry); } }
ActionInvocation invocation = ActionContext.getContext().getActionInvocation(); ActionProxy proxy = invocation.getProxy(); ActionConfig config = proxy.getConfig();
ActionContext ctx = ActionContext.getContext(); if (outcome != null) { if (ctx == null || ctx.getActionInvocation() == null) { delegateToParentNavigation(facesContext, fromAction, outcome); } else { ActionConfig config = ctx.getActionInvocation().getProxy().getConfig(); Map results = config.getResults(); ctx.getActionInvocation().setResultCode(outcome); } else { delegateToParentNavigation(facesContext, fromAction, outcome);
/** * Initializes the validation resources */ private void initResources(ServletContext servletContext) { if (pathnames != null) { ActionContext ctx = ActionContext.getContext(); try { ValidatorResources resources = this.loadResources(servletContext); String prefix = ctx.getActionInvocation().getProxy().getNamespace(); servletContext.setAttribute(ValidatorPlugIn.VALIDATOR_KEY + prefix, resources); servletContext.setAttribute(ValidatorPlugIn.STOP_ON_ERROR_KEY + '.' + prefix, (this.stopOnFirstError ? Boolean.TRUE : Boolean.FALSE)); } catch (Exception e) { throw new StrutsException( "Cannot load a validator resource from '" + pathnames + "'", e); } } }
@Override public Object evaluate(String expression, Request request) { Object result = expression; 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!"); } TextProviderFactory tpf = ctx.getContainer().getInstance(TextProviderFactory.class); TextProvider textProvider = tpf.createInstance(ctx.getActionInvocation().getAction().getClass()); if (textProvider != null) { LOG.debug("Trying find text [{}] using TextProvider {}", expression, textProvider); result = textProvider.getText(expression); } return result; }
if (model == null) { ActionContext ctx = ServletActionContext.getActionContext(request); model = freemarkerManager.buildTemplateModel(ctx.getValueStack(), ctx.getActionInvocation().getAction(), servletContext, request, response, wrapper); String resultCode = ActionContext.getContext().getActionInvocation().getResultCode(); if (req == null){ req = request;
/** * <p> * Will return a reference to the current action if the action name matches * the requested variable name. Otherwise it will attempt to resolve the * name from the value stack. Otherwise it will delegate to the original jsf * resolver. * </p> * * @param name * Variable name to be resolved */ public Object resolveVariable(FacesContext context, String name) throws EvaluationException { if (STRUTS_VARIABLE_NAME.equals(name)) { return ActionContext.getContext().getActionInvocation().getAction(); } Object obj = ActionContext.getContext().getValueStack().findValue(name); if (obj != null) { return obj; } else { return original.resolveVariable(context, name); } }
Template template = config.getTemplate(oldDecorator.getPage(), getLocale(ctx.getActionInvocation(), config)); // WW-1181 model = freemarkerManager.buildTemplateModel(ctx.getValueStack(), ctx.getActionInvocation().getAction(), servletContext, request, response, config.getObjectWrapper());
Action action = (Action) context.getActionInvocation().getAction();
@Override public void render(String path, Request request) throws IOException { if (path != null) { LOG.trace("Rendering freemarker tile [{}]", path); ActionContext ctx = readActionContext(request); registerTilesBeanModel(ctx); FreemarkerResult result = new FreemarkerResult(path); result.setWriter(request.getWriter()); Container container = ctx.getContainer(); container.inject(result); try { ActionInvocation invocation = ctx.getActionInvocation(); result.doExecute(path, invocation); } catch (TemplateException e) { LOG.error("Exception was thrown during rendering value {}: {}", path, e.getMessage()); throw new InvalidTemplateException(e); } } else { LOG.error("Path is null, cannot render template!"); throw new InvalidTemplateException("Cannot render a null template"); } }
ActionContext context = ActionContext.getContext(); ActionInvocation actionInvocation = context.getActionInvocation();
public void repopulateField(Object object) throws ValidationException { ActionInvocation invocation = ActionContext.getContext().getActionInvocation(); Map<String, Object> conversionErrors = ActionContext.getContext().getConversionErrors();
/** * {@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); } }
if (context.getActionInvocation() == null) {
private void executeServlet(String expectedProtocol, String expectedAuthority, String expectedPath) throws Exception { UrlHelper urlHelper = this.getContainerObject(UrlHelper.class); this.initAction("/do/Api/Service", "list"); FrontServletActionRedirectResult servlet = new FrontServletActionRedirectResult(); servlet.setActionName("details"); servlet.setUrlHelper(urlHelper); servlet.execute(super.getActionContext().getActionInvocation()); URL aURL = new URL(servlet.getLocation()); assertEquals(expectedProtocol, aURL.getProtocol()); assertEquals(expectedAuthority, aURL.getAuthority()); assertEquals(expectedPath, aURL.getPath()); List<NameValuePair> params = URLEncodedUtils.parse(aURL.getQuery(), Charset.forName("UTF-8")); for (NameValuePair param : params) { System.out.println(param.getName() + " : " + param.getValue()); if (param.getName().equals("internalServletActionPath")) { assertEquals("/ExtStr2/do/Api/Service/details", param.getValue()); } else if (param.getName().equals("internalServletFrameDest")) { assertEquals("0", param.getValue()); } else { fail(); } } }
public String execute() throws Exception { ActionContext ctx = ActionContext.getContext(); ActionConfig actionConfig = ctx.getActionInvocation().getProxy().getConfig(); Action action = null; try {
vs.getContext().putAll(Dispatcher.getInstance().createContextMap(request, response, null)); ctx = new ActionContext(vs.getContext()); if (ctx.getActionInvocation() == null) {