[
https://issues.apache.org/jira/browse/WW-4168?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13734874#comment-13734874
]
Bruce Phillips commented on WW-4168:
------------------------------------
Greg and Lukasz:
I was able to duplicate the issue in the form tags example application I
referred to in my previous comments.
For the Person object I create in the EditInServiceMemory class in that
example app I made a change to NOT set the value for the Person object's
carModels Array. This array stores the car models that a specific Person has
owned. So the use case here is that the person has not owned any previous car
models.
Then when I ran the application and loaded the form that uses s:checkboxlist
tag I got the NPE.
When not using the JavaTemplates Struts plugin I don't get the NPE.
Thanks for all the comments and help in getting me to understand the issue.
I'll review the change Greg recommended to the JavaTemplates plugin
CheckBoxListHandler class and confirm that it fixes the problem.
Bruce
> NullPointerException on Checkboxlist
> -------------------------------------
>
> Key: WW-4168
> URL: https://issues.apache.org/jira/browse/WW-4168
> Project: Struts 2
> Issue Type: Bug
> Components: Plugin - Java Templates
> Affects Versions: 2.3.15.1
> Environment: tomcat/centos 5
> Reporter: Greg Huber
> Assignee: Bruce Phillips
> Priority: Minor
> Fix For: 2.3.16
>
>
> 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:
> {code:java}
> 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;
> }
> {code}
> Cheers Greg
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira