struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Huber (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-3919) Checkboxlist does not render label tag correctly
Date Fri, 02 Aug 2013 18:49:49 GMT

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

Greg Huber commented on WW-3919:
--------------------------------

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:

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

</javacode>


Cheers Greg
                
> Checkboxlist does not render label tag correctly
> ------------------------------------------------
>
>                 Key: WW-3919
>                 URL: https://issues.apache.org/jira/browse/WW-3919
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Java Templates
>            Reporter: Greg Huber
>            Assignee: Lukasz Lenart
>            Priority: Minor
>             Fix For: 2.3.12
>
>
> Hello,
> Here are the mods to get the label working!
> {code:java}
> //Checkbox button section
> Attributes a = new Attributes();
> a.add("type", "checkbox")
> .add("name", name)
> .add("value", itemKeyStr)
> .addIfTrue("checked", checked)
> .addIfTrue("readonly", params.get("readonly"))
> .addIfTrue("disabled", disabled)
> .addIfExists("tabindex", params.get("tabindex"))
> //.addIfExists("id", name + "-" + Integer.toString(cnt++));
> .addIfExists("id", id + "-" + Integer.toString(cnt));  << CHANGED
> start("input", a);
> end("input");
> //Label section
> a = new Attributes();
> //a.add("for",id);
> a.add("for",id + "-" + Integer.toString(cnt))  << CHANGED
> .addIfExists("class", params.get("cssClass"))
> .addIfExists("style", params.get("cssStyle"));
> super.start("label", a);
>    if (StringUtils.isNotEmpty(itemValueStr))
>                     characters(itemValueStr);
>                 super.end("label");
>                 //Hidden input section
>                 a = new Attributes();
>                 a.add("type", "hidden")
>                         .add("id", "__multiselect_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(id)))
>                         .add("name", "__multiselect_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(name)))
>                         .add("value", "")
>                         .addIfTrue("disabled", disabled);
>                 start("input", a);
>                 end("input");
>                 super.end("br");
>                 stack.pop();
>                 
>                 cnt++;  // Increment <<< ADDED
> {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

Mime
View raw message