Tapestry
  1. Tapestry
  2. TAPESTRY-2619

Event Handler adds a new JSONObject to my JSONObject return

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 5.0.14
    • Fix Version/s: 5.0.15
    • Component/s: None
    • Labels:
      None

      Description

      When trying to create an AJAX handler to process a form submit, instead of returning my JSONObject simply as "

      {"somekey":"somevalue"}

      ", it returns "

      {"somekey":"somevalue"}

      {} ", which is clearly an invalid JSON object. The {} seems to be added at org.apache.tapestry5.internal.services.AjaxComponentEventRequestHandler:108.

      See attached file for an example project showing this behavior.

      1. example.rar
        19 kB
        Tobias Wehrum

        Activity

        Hide
        Tobias Wehrum added a comment -

        Example showing said behavoir

        Show
        Tobias Wehrum added a comment - Example showing said behavoir
        Hide
        Howard M. Lewis Ship added a comment -

        I vaguely remember seeing that bug before and thought it was fixed.

        Show
        Howard M. Lewis Ship added a comment - I vaguely remember seeing that bug before and thought it was fixed.
        Hide
        Howard M. Lewis Ship added a comment -

        I'm having trouble reproducing this in 5.0.15-SNAPSHOT.

        For example, the DatePicker does exactly this:

        JSONObject onParse()
        {
        String input = request.getParameter(INPUT_PARAMETER);
        JSONObject response = new JSONObject();

        try

        { Date date = format.parse(input); response.put(RESULT, date.toString()); }

        catch (ParseException ex)

        { response.put(ERROR, ex.getMessage()); }

        return response;
        }

        And, I've verified using FireBug, it works correctly.

        Show
        Howard M. Lewis Ship added a comment - I'm having trouble reproducing this in 5.0.15-SNAPSHOT. For example, the DatePicker does exactly this: JSONObject onParse() { String input = request.getParameter(INPUT_PARAMETER); JSONObject response = new JSONObject(); try { Date date = format.parse(input); response.put(RESULT, date.toString()); } catch (ParseException ex) { response.put(ERROR, ex.getMessage()); } return response; } And, I've verified using FireBug, it works correctly.
        Hide
        Howard M. Lewis Ship added a comment -

        The difference could be between a normal Ajax request and a form submission.

        Show
        Howard M. Lewis Ship added a comment - The difference could be between a normal Ajax request and a form submission.
        Hide
        Howard M. Lewis Ship added a comment -

        Yep, that's the issue all right.

        Because its going through a form.

        The event doesn't get cancelled properly because of how the Form, the event handler method, its return value, and the @Ajax ComponentEventResultProcessor interact.

        Show
        Howard M. Lewis Ship added a comment - Yep, that's the issue all right. Because its going through a form. The event doesn't get cancelled properly because of how the Form, the event handler method, its return value, and the @Ajax ComponentEventResultProcessor interact.

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Tobias Wehrum
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development