Search in sources :

Example 36 with ActionContext

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

the class IndexTemplate method buildTemplate.

@Override
public void buildTemplate(ActionContext context) {
    ValueStack stack = context.getValueStack();
    UserBean user = (UserBean) stack.findValue("currentUser");
    if (user.getDefaultLocationName() != null) {
        addMessage(Messages.SETTINGS_YOUR_DEFAULT_SEARCH_LOCATION_IS_CURRENTLY);
        addText(_locationPronunciation.modify(user.getDefaultLocationName()));
    }
    addMessage(Messages.INDEX_ACTION_SET_DEFAULT_SEARCH_LOCATION);
    addAction("1", "/settings/askForDefaultSearchLocation");
    if (user != null) {
        if (user.isRememberPreferencesEnabled())
            addMessage(Messages.PREFERENCES_DO_NOT_REMEMBER);
        else
            addMessage(Messages.PREFERENCES_DO_REMEMBER);
        addAction("2", "/settings/setRememberPreferences", "enabled", !user.isRememberPreferencesEnabled());
    }
    addMessage(Messages.HOW_TO_GO_BACK);
    addAction("\\*", "/back");
    addMessage(Messages.TO_REPEAT);
    addAction("[#23456789*]", "/repeat");
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) UserBean(org.onebusaway.users.client.model.UserBean)

Example 37 with ActionContext

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

the class CustomAgiEntryPoint method onActionSetup.

@Override
protected void onActionSetup(Map<String, Object> contextMap) {
    super.onActionSetup(contextMap);
    String sessionId = UUID.randomUUID().toString();
    XWorkRequestAttributes attributes = new XWorkRequestAttributes(new ActionContext(contextMap), sessionId);
    RequestContextHolder.setRequestAttributes(attributes);
}
Also used : XWorkRequestAttributes(org.onebusaway.presentation.impl.users.XWorkRequestAttributes) ActionContext(com.opensymphony.xwork2.ActionContext)

Example 38 with ActionContext

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

the class MessageTemplateDispatcher method executeTemplate.

@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);
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack)

Example 39 with ActionContext

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

the class MessageAndBackTemplate method buildTemplate.

@Override
public void buildTemplate(ActionContext context) {
    ValueStack stack = context.getValueStack();
    String message = stack.findString("message");
    String nextAction = stack.findString("nextAction");
    if (message != null)
        addMessage(message);
    else
        System.err.println("no message specified");
    if (nextAction != null) {
        setNextAction(nextAction);
    } else {
        addAction(".*\\*", "/back");
        setNextAction("/back");
    }
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack)

Example 40 with ActionContext

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

the class ResourceUrlComponent method end.

@Override
public boolean end(Writer writer, String body) {
    if (_value == null)
        _value = "top";
    String value = findStringIfAltSyntax(_value);
    Locale locale = Locale.getDefault();
    ActionContext ctx = ActionContext.getContext();
    if (ctx != null)
        locale = ctx.getLocale();
    String url = _resourceService.getExternalUrlForResource(value, locale);
    if (url != null) {
        if (getVar() != null) {
            /**
             * We either write the url out to a variable
             */
            putInContext(url);
        } else {
            /**
             * Or otherwise print out the url directly
             */
            try {
                writer.write(url);
            } catch (IOException e) {
                LOG.error("Could not write out resource-url tag", e);
            }
        }
    }
    return super.end(writer, "");
}
Also used : Locale(java.util.Locale) IOException(java.io.IOException) ActionContext(com.opensymphony.xwork2.ActionContext)

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