Changeset 4421


Ignore:
Timestamp:
Feb 25, 2013, 2:48:31 PM (10 years ago)
Author:
olle
Message:

Refs #797. Regular update of the job table via Ajax updated to prevent the Ajax action from being used as "last action", in case no forward action is set:

  1. JavaScript www/static/js/script.js in client/servlet/ updated in function updateJobTableColumns() to add a parameter requestType to the Ajax request, and set its value to "Ajax".
  2. Class/file se/lu/thep/waf/Event.java in api/waf updated with new public method AbstractAction getLastNonAjaxAction(), that returns the last action in the queue, that is not marked as being an Ajax request.
  3. Class/file action/ActionFactory.java in client/servlet/ updated in public method void setLastEvent(Event event) to call new Event public method AbstractAction getLastNonAjaxAction() instead of AbstractAction getLastAction(), when obtaining an action id to set as session attribute "previous.action.id" for the event.
  4. Class/file action/job/ListJobsAjax.java in client/servlet/ updated to take no special action depending on the value of the cmd parameter, and make a log entry snd return if the value of the requestType parameter differs from "Ajax". The changes to this class are strictly not necessary for the new functionality to work, but the log entries are used to check if the action is used, when not intended.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/api/waf/src/se/lu/thep/waf/Event.java

    r2677 r4421  
    259259
    260260  /**
     261   * @return the last action in the queue, that is not marked as being an Ajax request
     262   */
     263  public AbstractAction getLastNonAjaxAction()
     264  {
     265    AbstractAction lastAction = null;
     266    if (actionChain.size() > 0)
     267    {
     268      // Return last AbstractAction that is not an Ajax type action
     269      for (int i = 0; i < actionChain.size(); i++)
     270      {
     271        AbstractAction action = actionChain.get(actionChain.size() - 1 - i);
     272        if (action != null)
     273        {
     274          String requestType = "";
     275          HttpServletRequest req = action.getRequest();
     276          if (req != null)
     277          {
     278            requestType = req.getParameter("requestType");
     279          }
     280          if (requestType == null || !requestType.equals("Ajax"))
     281          {
     282            // Set action as last action
     283            lastAction = action;
     284            break;
     285          }
     286        }
     287      }
     288    }
     289    return lastAction;
     290  }
     291
     292
     293  /**
    261294   * Runs the specified action and returning the next action to run
    262295   *
  • trunk/client/servlet/src/org/proteios/action/ActionFactory.java

    r4159 r4421  
    774774    public void setLastEvent(Event event)
    775775    {
    776         event.getRequest().getSession().setAttribute("previous.action.id",
    777         event.getLastAction().getId());
     776      AbstractAction action = event.getLastNonAjaxAction();
     777      if (action != null)
     778      {
     779            event.getRequest().getSession().setAttribute("previous.action.id",
     780                action.getId());
     781      }
    778782    }
    779783       
  • trunk/client/servlet/src/org/proteios/action/job/ListJobsAjax.java

    r4420 r4421  
    7979  {
    8080          String ID = req.getParameter("ID");
     81          String requestType = req.getParameter("requestType");
    8182          String cmd = req.getParameter("cmd");
    8283          String jobIdListStr = req.getParameter("jobIdList");
    8384          log.debug("doGet(): ID = \"" + ID + "\"");
     85          log.debug("doGet(): requestType = \"" + requestType + "\"");
    8486          log.debug("doGet(): cmd = \"" + cmd + "\"");
    8587          log.debug("doGet(): jobIdList = \"" + jobIdListStr + "\"");
    86           if (cmd == null || !cmd.equals("updateJobTable"))
     88          if (requestType == null || !requestType.equals("Ajax"))
    8789          {
    88             // Request not intended for this servlet, forward to ListJobs
    89             setForwardTo(ListJobs.class);
     90            // Request not intended for this servlet
     91            log.debug("doGet(): requestType = \"" + requestType + "\" - Immediate return");
    9092            return;
    9193          }
  • trunk/client/servlet/www/static/js/script.js

    r4419 r4421  
    438438function updateJobTableColumns()
    439439{
    440   // Set cmd so Ajax application can verify that the request was not intended for other servlet
     440  // Set cmd
    441441  var cmd = 'updateJobTable';
     442  // Set requestType to "Ajax" to prevent action from being returned as "last action"
     443  var requestType = 'Ajax';
    442444  // Get job id values in comma-separated list
    443445  var jobIdList = getJobIdList();
    444   var url = 'app?action=org.proteios.action.job.ListJobsAjax&cmd=' + cmd + '&jobIdList=' + jobIdList;
     446  // Create url for Ajax XMLHttpRequest
     447  var url = 'app?action=org.proteios.action.job.ListJobsAjax&requestType=' + requestType + '&cmd=' + cmd + '&jobIdList=' + jobIdList;
    445448  var request = new XMLHttpRequest();
    446449  request.open("GET", url, false);
Note: See TracChangeset for help on using the changeset viewer.