Search in sources :

Example 21 with Context

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

the class StopFoundTemplate method buildTemplate.

@Override
public void buildTemplate(ActionContext context) {
    ValueStack vs = context.getValueStack();
    StopBean stop = (StopBean) vs.findValue("stop");
    addMessage(Messages.THE_STOP_NUMBER_FOR);
    addText(_destinationPronunciation.modify(stop.getName()));
    String direction = _directionPronunciation.modify(stop.getDirection());
    addMessage(Messages.DIRECTION_BOUND, direction);
    addText(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);
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) StopBean(org.onebusaway.transit_data.model.StopBean) AgiActionName(org.onebusaway.probablecalls.AgiActionName)

Example 22 with Context

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

the class StopsForRouteNavigationTemplate method buildTemplate.

@Override
public void buildTemplate(ActionContext context) {
    ValueStack vs = context.getValueStack();
    NavigationBean navigation = (NavigationBean) vs.findValue("navigation");
    List<NameBean> names = navigation.getNames();
    int index = navigation.getCurrentIndex();
    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
     */
    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
        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);
    }
    addAction("\\*", "/back");
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) NavigationBean(org.onebusaway.phone.actions.search.NavigationBean) NameBean(org.onebusaway.transit_data.model.NameBean) AgiActionName(org.onebusaway.probablecalls.AgiActionName)

Example 23 with Context

use of com.opensymphony.xwork2.inject.Context 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();
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) ActionContext(com.opensymphony.xwork2.ActionContext)

Example 24 with Context

use of com.opensymphony.xwork2.inject.Context in project bamboobsc by billchen198318.

the class ActionInfoSupportInterceptor method intercept.

@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
    /*
		ActionInvocation ai=(ActionInvocation)ActionContext.getContext().get(ActionContext.ACTION_INVOCATION); 
		String action=ai.getProxy().getActionName(); 
		String namespace=ai.getProxy().getNamespace();
		*/
    HttpServletRequest request = ServletActionContext.getRequest();
    ActionContext context = actionInvocation.getInvocationContext();
    String action = actionInvocation.getProxy().getActionName();
    String namespace = actionInvocation.getProxy().getNamespace();
    String remoteAddr = request.getRemoteAddr();
    String referer = request.getHeader("referer");
    context.getSession().put(Constants.SESS_PAGE_INFO_ACTION_ByInterceptor, action);
    context.getSession().put(Constants.SESS_PAGE_INFO_NAMESPACE_ByInterceptor, namespace);
    context.getSession().put(Constants.SESS_PAGE_INFO_RemoteAddr_ByInterceptor, remoteAddr);
    context.getSession().put(Constants.SESS_PAGE_INFO_Referer_ByInterceptor, referer);
    return actionInvocation.invoke();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ActionContext(com.opensymphony.xwork2.ActionContext) ServletActionContext(org.apache.struts2.ServletActionContext)

Example 25 with Context

use of com.opensymphony.xwork2.inject.Context in project bamboobsc by billchen198318.

the class JsonOutermostBracketsInterceptor method intercept.

@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
    ActionContext context = actionInvocation.getInvocationContext();
    HttpServletResponse response = (HttpServletResponse) context.get(StrutsStatics.HTTP_RESPONSE);
    response.setCharacterEncoding("utf8");
    response.setContentType("text/html");
    PrintWriter writer = response.getWriter();
    writer.print("[");
    writer.flush();
    String forward = actionInvocation.invoke();
    writer.print("]");
    writer.flush();
    return forward;
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) ActionContext(com.opensymphony.xwork2.ActionContext) PrintWriter(java.io.PrintWriter)

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