Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4168

NullPointerException on Checkboxlist

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.15.1
    • Fix Version/s: 2.3.16
    • Labels:
      None
    • Environment:

      tomcat/centos 5

      Description

      Hello,

      I am getting null pointer exceptions on line :

      Caused by: java.lang.NullPointerException
      at template.events.CheckboxListHandler.isChecked(CheckboxListHandler.java:125)
      at template.events.CheckboxListHandler.generate(CheckboxListHandler.java:80)
      at org.apache.struts2.views.java.DefaultTheme.renderTag(DefaultTheme.java:120)
      at org.apache.struts2.views.java.JavaTemplateEngine.renderTemplate(JavaTemplateEngine.java:95)
      at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:572)
      at org.apache.struts2.components.UIBean.end(UIBean.java:526)

      we need to check for if(nameValues)!=null

      ie:

      private Boolean isChecked(Map<String, Object> params, String itemKeyStr) {
        Boolean checked = false;
        if (itemKeyStr != null) {
          String[] nameValues = (String[]) params.get("nameValue");
          if(nameValues)!=null  // need this <<<<<<<<<<
            for (String value : nameValues) {
              if (checked = value.equalsIgnoreCase(itemKeyStr))
              { break; }
            }
          }
        }
          return checked;
      }
      
      

      Cheers Greg

        Attachments

          Activity

            People

            • Assignee:
              bphillips Bruce Phillips
              Reporter:
              ghuber Greg Huber
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: