public void renderListCell(ItsNatList list, int index, Object value, boolean isSelected, boolean hasFocus, Element cellContentElem, boolean isNew)
{
ItsNatListMultSel listMult = (ItsNatListMultSel)list;
final DefaultListModel listModel = (DefaultListModel)listMult.getListModel();
final Person person = (Person)listModel.getElementAt(index);
if (isNew)
{
ItsNatDocument itsNatDoc = listMult.getItsNatDocument();
if (!itsNatDoc.getItsNatDocumentTemplate().isAutoBuildComponents())
{
ItsNatComponentManager compMgr = listMult.getItsNatComponentManager();
compMgr.buildItsNatComponents(cellContentElem);
}
final ItsNatHTMLInputText firstNameComp = getInputText("firstNameId",cellContentElem,listMult);
final ItsNatHTMLInputText lastNameComp = getInputText("lastNameId",cellContentElem,listMult);
firstNameComp.setText(person.getFirstName());
lastNameComp.setText(person.getLastName());
DocumentListener firstNameListener = new DocumentListener()
{
public void insertUpdate(DocumentEvent e)
{
update();
}
public void removeUpdate(DocumentEvent e)
{
update();
}
public void changedUpdate(DocumentEvent e)
{
update();
}
public void update()
{
person.setFirstName(firstNameComp.getText());
}
};
firstNameComp.getDocument().addDocumentListener(firstNameListener);
DocumentListener lastNameListener = new DocumentListener()
{
public void insertUpdate(DocumentEvent e)
{
update();
}
public void removeUpdate(DocumentEvent e)
{
update();
}
public void changedUpdate(DocumentEvent e)
{
update();
}
public void update()
{
person.setLastName(lastNameComp.getText());
}
};
lastNameComp.getDocument().addDocumentListener(lastNameListener);
}
else
{
ItsNatHTMLInputText firstNameComp = getInputText("firstNameId",cellContentElem,listMult);
ItsNatHTMLInputText lastNameComp = getInputText("lastNameId",cellContentElem,listMult);
firstNameComp.setText(person.getFirstName());
lastNameComp.setText(person.getLastName());
}
}