Subject: "Too Many items in listbox error" in xdatalistsingle when rendering node config form
When asking for a node configuration OpenFire 3.6.4 returns options list as <value> elements with no <label> elements.
<field type="list-single" label="Publisher model" var="pubsub#publish_model"><option><value>publishers</value></option><option><value>subscribers</value></option><option><value>open</value></option><value>publishers</value></field>
This causes an error when loading the xdatacontrol because the underlying xdatalistitem class returns a null value for ToString() when loading values into the combo box of the Xdatalistsingle user control. The MS combo box control has an issue when an item is added and the ToString() of that item is a null value.
public override string ToString()
{
return m_Label;
}
I have made two changes to protect against this:
1. Changes in the xdatalistitem object to handle this value only situation.
public override string ToString()
{
if (!string.IsNullOrEmpty(m_Label))
{
return m_Label;
}
else
{
if (!string.IsNullOrEmpty(m_Value))
{
return m_Value;
}
else
{
return string.Empty;
}
}
}
2. Changes in the xdatalistsingle class
public void AddValue(string val, string label)
{
XDataListItem item = new XDataListItem(label, val);
if (!string.IsNullOrEmpty(item.ToString()))
{
comboBox.Items.Add(item);
}
}
<field type="list-single" label="Publisher model" var="pubsub#publish_model"><option><value>publishers</value></option><option><value>subscribers</value></option><option><value>open</value></option><value>publishers</value></field>
This causes an error when loading the xdatacontrol because the underlying xdatalistitem class returns a null value for ToString() when loading values into the combo box of the Xdatalistsingle user control. The MS combo box control has an issue when an item is added and the ToString() of that item is a null value.
public override string ToString()
{
return m_Label;
}
I have made two changes to protect against this:
1. Changes in the xdatalistitem object to handle this value only situation.
public override string ToString()
{
if (!string.IsNullOrEmpty(m_Label))
{
return m_Label;
}
else
{
if (!string.IsNullOrEmpty(m_Value))
{
return m_Value;
}
else
{
return string.Empty;
}
}
}
2. Changes in the xdatalistsingle class
public void AddValue(string val, string label)
{
XDataListItem item = new XDataListItem(label, val);
if (!string.IsNullOrEmpty(item.ToString()))
{
comboBox.Items.Add(item);
}
}
ThomWill
Show profile
Link to this post
