You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Greg Huber (JIRA)" <ji...@apache.org> on 2013/08/08 20:46:48 UTC

[jira] [Comment Edited] (WW-4168) NullPointerException on Checkboxlist

    [ https://issues.apache.org/jira/browse/WW-4168?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13733822#comment-13733822 ] 

Greg Huber edited comment on WW-4168 at 8/8/13 6:46 PM:
--------------------------------------------------------

Hello,

Do you have the modified webapp that you used anywhere I can download?


Cheers Greg

                
      was (Author: gregh99):
    Hello,

Do you have the modified webapp that you used anywhere I can download?

I have rechecked it and it definitely needs it.

<s:checkboxlist list="pluginsList" name="bean.defaultPluginsArray" listKey="name" listValue="name" />

/**
 * Gets the plugins list.
 * 
 * @return the plugins list
*/
public List<?> getPluginsList() {
	//return pluginsList;
	return null;
}


The trace is pretty straight forward:

Caused by: java.lang.NullPointerException
at template.events.CheckboxListHandler.isChecked(CheckboxListHandler.java:125)

Can you guarantee that there is not going to be a null in the nameValues?  Don't know why the pesky for loop can't check for nulls, would save a lot of time....

Cheers Greg

                  
> 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