panel.add(lbl, c);
}
private void sendForm(XDataCallback callback)
{
XDataBuilder builder = new XDataBuilder();
builder.type ="submit";
for (Iterator iter = fields.iterator(); iter.hasNext();)
{
Object element = iter.next();
String var = null;
String value = null;
if(element instanceof Object[])
{
var =(String)((Object[])element)[0];
value =(String)((Object[])element)[1];
if(value != null)
{
builder.addField(new XDataField(var,value));
}
}
else
{
JComponent component = (JComponent)element;
var = component.getName();
if(component instanceof JCheckBox)
{
value = String.valueOf(((JCheckBox)component).isSelected()?1:0);
}
else if(component instanceof JTextComponent)
{
value = ((JTextComponent)component).getText();
}
else if(component instanceof JComboBox)
{
value =((LabelValue)((JComboBox)component).getSelectedItem()).value;
}
if(value != null)
{
builder.addField(new XDataField(var,value));
}
if(component instanceof JList)
{
JList list = ((JList)component);
if (!list.isSelectionEmpty())
{
Object[] values = list.getSelectedValues();
for (int i = 0; i < values.length; i++)
{
builder.addField(new XDataField(var,((LabelValue)values[i]).value));
}
}
}
}
}
try
{
callback.sendForm(builder.build());
}
catch (InstantiationException e)
{
e.printStackTrace();
}