Search in sources :

Example 16 with Context

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

the class NextActionSupport method getNextActionOrSuccess.

protected String getNextActionOrSuccess() {
    List<NextAction> stack = getNextActionStack(false);
    if (stack == null || stack.isEmpty())
        return SUCCESS;
    NextAction next = stack.remove(stack.size() - 1);
    Map<String, String[]> params = next.getParameters();
    if (params != null && !params.isEmpty()) {
        ActionContext context = ActionContext.getContext();
        Map<String, Object> contextParameters = context.getParameters();
        contextParameters.putAll(params);
    }
    return next.getAction();
}
Also used : ActionContext(com.opensymphony.xwork2.ActionContext) NextAction(org.onebusaway.presentation.model.NextAction)

Example 17 with Context

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

the class IntegrationTestingInterceptor method intercept.

@Override
public String intercept(ActionInvocation invocation) throws Exception {
    ActionContext context = invocation.getInvocationContext();
    AgiRequest request = AgiEntryPoint.getAgiRequest(context);
    Map<?, ?> r = request.getRequest();
    /**
     * This interceptor will be called multiple times in the course of
     * processing the actions for a call, so we only check the reset user param
     * once
     */
    Object value = r.remove(RESET_USER);
    if (value != null && value.equals("true"))
        context.getParameters().put(PhoneNumberLoginInterceptor.RESET_USER, Boolean.TRUE);
    return invocation.invoke();
}
Also used : ActionContext(com.opensymphony.xwork2.ActionContext) AgiRequest(org.asteriskjava.fastagi.AgiRequest)

Example 18 with Context

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

the class ArrivalsAndDeparturesTemplate method buildTemplate.

@Override
public void buildTemplate(ActionContext context) {
    ValueStack valueStack = context.getValueStack();
    PhoneArrivalsAndDeparturesModel model = (PhoneArrivalsAndDeparturesModel) valueStack.findValue("model");
    StopsWithArrivalsAndDeparturesBean result = model.getResult();
    buildPredictedArrivalsTemplate(result.getArrivalsAndDepartures());
    addMessage(Messages.ARRIVAL_INFO_ON_SPECIFIC_ROUTE);
    AgiActionName byRouteAction = addActionWithParameterFromMatch("1(\\d+)#", "/stop/arrivalsAndDeparturesForRoute", "route", 1);
    byRouteAction.putParam("model", model);
    addMessage(Messages.ARRIVAL_INFO_BOOKMARK_THIS_LOCATION);
    AgiActionName bookmarkAction = addAction("2", "/stop/bookmark");
    bookmarkAction.putParam("stops", result.getStops());
    addMessage(Messages.ARRIVAL_INFO_RETURN_TO_MAIN_MENU);
    addAction("3", "/index");
    addAction("(#|[04-9]|1.*\\*)", "/repeat");
    addMessage(Messages.HOW_TO_GO_BACK);
    addAction("\\*", "/back");
    addMessage(Messages.TO_REPEAT);
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) StopsWithArrivalsAndDeparturesBean(org.onebusaway.transit_data.model.StopsWithArrivalsAndDeparturesBean) PhoneArrivalsAndDeparturesModel(org.onebusaway.phone.impl.PhoneArrivalsAndDeparturesModel) AgiActionName(org.onebusaway.probablecalls.AgiActionName)

Example 19 with Context

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

the class MultipleStopsFoundTemplate method buildTemplate.

@SuppressWarnings("unchecked")
@Override
public void buildTemplate(ActionContext context) {
    ValueStack vs = context.getValueStack();
    List<StopBean> stops = (List<StopBean>) vs.findValue("stops");
    int index = 1;
    addMessage(Messages.MULTIPLE_STOPS_WERE_FOUND);
    for (StopBean stop : stops) {
        addMessage(Messages.FOR);
        addText(_destinationPronunciation.modify(stop.getName()));
        addMessage(Messages.PLEASE_PRESS);
        String key = Integer.toString(index++);
        addText(key);
        AgiActionName action = addAction(key, "/stop/arrivalsAndDeparturesForStopId");
        action.putParam("stopIds", Arrays.asList(stop.getId()));
    }
    addMessage(Messages.HOW_TO_GO_BACK);
    addAction("\\*", "/back");
    addMessage(Messages.TO_REPEAT);
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) StopBean(org.onebusaway.transit_data.model.StopBean) List(java.util.List) AgiActionName(org.onebusaway.probablecalls.AgiActionName)

Example 20 with Context

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

the class ManageTemplate method buildTemplate.

@SuppressWarnings("unchecked")
@Override
public void buildTemplate(ActionContext context) {
    ValueStack stack = context.getValueStack();
    List<BookmarkWithStopsBean> bookmarks = (List<BookmarkWithStopsBean>) stack.findValue("bookmarks");
    if (bookmarks.isEmpty()) {
        addMessage(Messages.BOOKMARKS_EMPTY);
    } else {
        int index = 1;
        for (BookmarkWithStopsBean bookmark : bookmarks) {
            addMessage(Messages.BOOKMARKS_TO_DELETE_THE_BOOKMARK_FOR);
            addBookmarkDescription(bookmark);
            addMessage(Messages.PLEASE_PRESS);
            String toPress = Integer.toString(index);
            addText(toPress);
            AgiActionName deleteAction = addAction(toPress, "/bookmarks/deleteByIndex");
            deleteAction.putParam("index", index - 1);
            index++;
        }
    }
    addAction("(#|0|.+\\*)", "/repeat");
    addMessage(Messages.HOW_TO_GO_BACK);
    addAction("\\*", "/back");
    addMessage(Messages.TO_REPEAT);
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) BookmarkWithStopsBean(org.onebusaway.presentation.model.BookmarkWithStopsBean) List(java.util.List) AgiActionName(org.onebusaway.probablecalls.AgiActionName)

Aggregations

ActionContext (com.opensymphony.xwork2.ActionContext)21 ValueStack (com.opensymphony.xwork2.util.ValueStack)14 AgiActionName (org.onebusaway.probablecalls.AgiActionName)7 List (java.util.List)5 ActionProxy (com.opensymphony.xwork2.ActionProxy)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 ActionInvocation (com.opensymphony.xwork2.ActionInvocation)3 StopBean (org.onebusaway.transit_data.model.StopBean)3 XWorkException (com.opensymphony.xwork2.XWorkException)2 Inject (com.opensymphony.xwork2.inject.Inject)2 Constructor (java.lang.reflect.Constructor)2 DateFormat (java.text.DateFormat)2 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 Map (java.util.Map)2 ServletActionContext (org.apache.struts2.ServletActionContext)2 SessionAware (org.apache.struts2.interceptor.SessionAware)2 XWorkRequestAttributes (org.onebusaway.presentation.impl.users.XWorkRequestAttributes)2 BookmarkWithStopsBean (org.onebusaway.presentation.model.BookmarkWithStopsBean)2