Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-2761

JavaScript variable "item" wont be reinitialized

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.7
    • Fix Version/s: 2.2.8
    • Component/s: None
    • Labels:
      None
    • Environment:

      Mac OS X

      Description

      Take a look at the generated JS-Code, and especially at the variable item.

      function ws_ejb_core_lunchroulette_de__userGetMeetingpoints_deserialize (cxfjsutils, element) {
          var newobject = new ws_ejb_core_lunchroulette_de__userGetMeetingpoints();
          cxfjsutils.trace('element: ' + cxfjsutils.traceElementName(element));
          var curElement = cxfjsutils.getFirstElementChild(element);
          var item;
          cxfjsutils.trace('curElement: ' + cxfjsutils.traceElementName(curElement));
          cxfjsutils.trace('processing session');
          var value = null;
          if (!cxfjsutils.isElementNil(curElement)) {
           value = cxfjsutils.getNodeText(curElement);
           item = value;
          }
          newobject.setSession(item);
          if (curElement != null) {
           curElement = cxfjsutils.getNextElementSibling(curElement);
          }
          cxfjsutils.trace('curElement: ' + cxfjsutils.traceElementName(curElement));
          cxfjsutils.trace('processing filter');
          var value = null;
          if (!cxfjsutils.isElementNil(curElement)) {
           item = ws_ejb_core_lunchroulette_de__filter_deserialize(cxfjsutils, curElement);
          }
          newobject.setFilter(item);
          if (curElement != null) {
           curElement = cxfjsutils.getNextElementSibling(curElement);
          }
          return newobject;
      }
      

      It is possible that item is filled with the value of the first "element" and not changed for the second element, and so the second vlement will get the value for the first element.

      Easy fix (in my opinion):

              utils.appendLine("newobject." + accessorName + "(item);");
              utils.appendLine("var item = null;");
              if (!itemInfo.isArray()) {
                  utils.startIf("curElement != null");
                  utils.appendLine("curElement = cxfjsutils.getNextElementSibling(curElement);");
                  utils.endBlock();
              }
      

      Line 661 and following in SchemaJavascriptBuilder.java.

      Thanks in advance,
      Björn

        Attachments

          Activity

            People

            • Assignee:
              dkulp Daniel Kulp
              Reporter:
              bhaeuser Björn Häuser
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: