ICEfaces
  1. ICEfaces
  2. ICE-8345

NPE in DOMPartialViewContext.applyBrowserChanges(Map parameters, Document document)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: EE-3.0.0.GA
    • Fix Version/s: 3.1, EE-3.0.0.GA_P01
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      ICEfaces
    • Assignee Priority:
      P1

      Description

      Suggestion bellow is a fix for a possible NPE issue in our code located in org.icefaces.impl.context.DOMPartialViewContext.applyBrowserChanges(Map parameters, Document document), around lines 470-480:

      // if we cannot loop through optionElements, we must have
      // just a text node
      if (0 == optionElementsLength) {
      Node optionBodyNode = selectElement.getFirstChild();
      // QUICK BUGFIX oboede 2012-06-04: In case of f:ajax updates this node value
      // was sometimes <code>null</code>.
      if (optionBodyNode != null) { <--------- (1) to avoid NPE at (2)
      String optionBody = optionBodyNode.getNodeValue(); <--------------- (2)

      // Should be constant, but may vary with JSF implementation
      String SELECTED = "selected=\"true\"";
      Matcher tagMatcher = OPTION_TAG.matcher(optionBody);
      StringBuffer outBuffer = new StringBuffer();
      while (tagMatcher.find()) {
      String optionTag = tagMatcher.group(0);
      Matcher valueMatcher = OPTION_VALUE.matcher(optionTag);
      Matcher selectedMatcher = OPTION_SELECTED.matcher(optionTag);
      String valuePair = null;
      String value = null;
      String selected = null;
      if (valueMatcher.find()) {
      valuePair = valueMatcher.group(0);
      value = valueMatcher.group(1);
      }
      if (selectedMatcher.find()) {
      selected = selectedMatcher.group(1);
      SELECTED = selected;
      }

      if (values.contains(value)) {
      if (null == selected) {
      optionTag = optionTag.replace(valuePair, valuePair + " " + SELECTED);
      }
      } else {
      if (null != selected) {
      optionTag = optionTag.replace(" " + selected, "");
      }
      }
      tagMatcher.appendReplacement(outBuffer, optionTag);
      }
      tagMatcher.appendTail(outBuffer);
      optionBodyNode.setNodeValue(outBuffer.toString());
      }
      }

        Activity

          People

          • Assignee:
            Deryk Sinotte
            Reporter:
            Evgheni Sadovoi
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: