Search in sources :

Example 6 with Context

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

the class StopFoundAction method execute.

@Override
public String execute() throws Exception {
    Integer navState = (Integer) sessionMap.get("navState");
    if (navState == null) {
        navState = DISPLAY_DATA;
    }
    _log.debug("StopsForRouteNavigationAction:navState: " + navState);
    if (navState == DISPLAY_DATA) {
        ActionContext context = ActionContext.getContext();
        ValueStack vs = context.getValueStack();
        StopBean stop = (StopBean) vs.findValue("stop");
        sessionMap.put("stop", stop);
        addMessage(Messages.THE_STOP_NUMBER_FOR);
        addText(_destinationPronunciation.modify(stop.getName()));
        String stopDir = stop.getDirection();
        if (stopDir != null && stopDir.length() > 0) {
            String direction = _directionPronunciation.modify(stopDir);
            addMessage(Messages.DIRECTION_BOUND, direction);
        }
        addMessage(Messages.IS);
        addText(stop.getCode() + ".");
        addMessage(Messages.STOP_FOUND_ARRIVAL_INFO);
        // AgiActionName arrivalInfoAction = addAction("1", "/stop/arrivalsAndDeparturesForStopId");
        // arrivalInfoAction.putParam("stopIds", Arrays.asList(stop.getId()));
        addMessage(Messages.STOP_FOUND_BOOKMARK_THIS_LOCATION);
        // AgiActionName bookmarkAction = addAction("2", "/stop/bookmark");
        // bookmarkAction.putParam("stop", stop);
        addMessage(Messages.STOP_FOUND_RETURN_TO_MAIN_MENU);
        // addAction("3", "/index");
        // addAction("[04-9]", "/repeat");
        addMessage(Messages.HOW_TO_GO_BACK);
        // addAction("\\*", "/back");
        addMessage(Messages.TO_REPEAT);
        sessionMap.put("navState", new Integer(DO_ROUTING));
        return SUCCESS;
    } else {
        if (PREVIOUS_MENU_ITEM.equals(getInput())) {
            return "back";
        } else if ("1".equals(getInput())) {
            StopBean stop = (StopBean) sessionMap.get("stop");
            _stopIds = Arrays.asList(stop.getId());
            return "arrivals-and-departures";
        } else if ("2".equals(getInput())) {
            StopBean stop = (StopBean) sessionMap.get("stop");
            _stopIds = Arrays.asList(stop.getId());
            return "bookmark-stop";
        }
        return SUCCESS;
    }
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) StopBean(org.onebusaway.transit_data.model.StopBean) ActionContext(com.opensymphony.xwork2.ActionContext)

Example 7 with Context

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

the class StopsForRouteNavigationAction method buildStopsList.

// protected void buildPredictedArrivals(List<ArrivalAndDepartureBean> arrivals) {
protected void buildStopsList() {
    ActionContext context = ActionContext.getContext();
    ValueStack vs = context.getValueStack();
    // NavigationBean navigation = (NavigationBean) vs.findValue("navigation");
    NavigationBean navigation = (NavigationBean) sessionMap.get("navigation");
    List<NameBean> names = navigation.getNames();
    index = navigation.getCurrentIndex();
    _log.debug("StopsForRoute.buildStopsList: index: " + index);
    if (index < 0)
        index = 0;
    /**
     * We always listen for the key-press for the previous name in case it takes
     * the user a second to press
     */
    _log.debug("in StopsForRouteNavigationAction, index = " + index + ", names.size = " + names.size());
    if (index > 0)
        addNavigationSelectionActionForIndex(navigation, index - 1);
    /**
     * If we're at the first entry and there is a second, we allow the user to
     * jump ahead
     */
    if (index == 0 && names.size() > 1) {
        addNavigationSelectionActionForIndex(navigation, index + 1);
    }
    if (index >= names.size()) {
        // AgiActionName action = setNextAction("/search/navigate-to");
        // action.putParam("navigation", navigation);
        // action.putParam("index", 0);
        // action.setExcludeFromHistory(true);
        // Add an extra pause so the user has a chance to make a selection from
        // the previous entry
        addMessage("<Pause length=\"1\"/>");
        // addPause(1000);
        addMessage(Messages.TO_REPEAT);
    } else {
        String key = addNavigationSelectionActionForIndex(navigation, index);
        NameBean name = names.get(index);
        handleName(name, key);
        addNavigateToAction(navigation, "4", first(index - 1));
        addNavigateToAction(navigation, "6", index + 1);
        addNavigateToAction(navigation, "7", first(index - 10));
        addNavigateToAction(navigation, "9", index + 10);
    // AgiActionName action = setNextAction("/search/navigate-to");
    // action.putParam("navigation", navigation);
    // action.putParam("index", index + 1);
    // action.setExcludeFromHistory(true);
    // setNextAction("navigate-to");
    }
    sessionMap.put("navigation", navigation);
// addAction("\\*", "/back");
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) ActionContext(com.opensymphony.xwork2.ActionContext) NameBean(org.onebusaway.transit_data.model.NameBean)

Example 8 with Context

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

the class TwilioSupport method addMessage.

protected void addMessage(String msg, Object... args) {
    ActionContext context = ActionContext.getContext();
    Locale locale = context.getLocale();
    ValueStack valueStack = context.getValueStack();
    String text = LocalizedTextUtil.findText(TwilioSupport.this.getClass(), msg, locale, msg, args, valueStack);
    _log.debug("message: " + text);
    _message.append(" " + text + " ");
    _log.debug(getText(msg));
}
Also used : Locale(java.util.Locale) ValueStack(com.opensymphony.xwork2.util.ValueStack) ActionContext(com.opensymphony.xwork2.ActionContext)

Example 9 with Context

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

the class Debug method execute.

@Override
public String execute() throws Exception {
    ActionContext context = ActionContext.getContext();
    ActionInvocation invocation = context.getActionInvocation();
    ActionProxy proxy = invocation.getProxy();
    String name = proxy.getActionName().toLowerCase();
    String namespace = proxy.getNamespace().toLowerCase();
    // return the 404 message if so. There has to be a better way than this?
    if ((name.equals("") || name.equals("index") || name.equals("debug")) && (namespace.equals("") || namespace.equals("/"))) {
        return SUCCESS;
    }
    return "NotFound";
}
Also used : ActionProxy(com.opensymphony.xwork2.ActionProxy) ActionInvocation(com.opensymphony.xwork2.ActionInvocation) ActionContext(com.opensymphony.xwork2.ActionContext)

Example 10 with Context

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

the class ResourceUrlFunction method setServletContext.

@Inject(required = true)
public void setServletContext(ServletContext servletContext) {
    WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    context.getAutowireCapableBeanFactory().autowireBean(this);
}
Also used : WebApplicationContext(org.springframework.web.context.WebApplicationContext) Inject(com.opensymphony.xwork2.inject.Inject)

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