akash kubavat
akash kubavat

Reputation: 847

All checkboxes are get selected in List instead of only clicked one in codename one

I have created my own Renderer class and I am doing something like

MyClass extends Container implements ListCellRenderer

I added some TextAreas Labels with CheckBox into this class.. and setting this as a renderer to "List"

So my code for initListModel is:

@Override
protected boolean initListModelReceiptLineList(List cmp) {
    cmp.setRenderer(new RendererPOReceiptList(receiptLineList));
    //valid data in receiptLineList
    cmp.setModel(new DefaultListModel(receiptLineList));
    return true;
}

Everything is running fine, even data are also set in label & textareas.. running good in device and in emulator..

But, The issue is, when I select 1st checkbox, all checkboxes are selected..

Anyone have any idea please,

Thanks,

Akash

Upvotes: 0

Views: 230

Answers (1)

Shai Almog
Shai Almog

Reputation: 52760

The renderer is stateless hence you shouldn't check the checkbox, you check the model. Your renderer needs to select the value of the checkbox with every renderer.

This all might be complex stuff which is why I wouldn't recommend building your own and instead using a MultiList (or just adding checkboxes to a container).

Upvotes: 0

Related Questions