View Full Version : [GXT 2.2.5] NPE in Checkbox

Nico P
22 Mar 2012, 12:59 AM
at com.extjs.gxt.ui.client.widget.form.CheckBox.setBoxLabel(CheckBox.java:116)

To reproduce add a checkbox with box label null to a panel.
If after rendering the lable is changed the NPE is thrown as boxLabelEl is null.

public void setBoxLabel(String boxLabel) { this.boxLabel = boxLabel;
if (rendered) {

as of:

@Override protected void onRender(Element target, int index) {
if (boxLabel != null) {
boxLabelEl = new El(DOM.createLabel());

22 Mar 2012, 3:15 AM
As workaround you should use setBoxLabel("") initially.

Nico P
22 Mar 2012, 5:16 AM
Hello Sven,

thanks again for your fast reply.

In some cases box labels have to be null. For empty Strings the onRender method adds a label Element to the dom. My workaround overrides the CheckBox#setBoxLabel(String) Method. As in onRender my method adds or removes the label element from the dom depending on the old and new box label.

Greetings Nico.