2013-04-24 56 views
0

我耗费这是我返回结果类型的“ArrayOfKeyValueOfintstring”使用字典中的Java

我很困惑如何将这些数据在java中添加到我的组合框中选择一个Web服务组合框操纵。

这里是我的代码

org.tempuri.ThirdPartyService service = new org.tempuri.ThirdPartyService(); 
org.tempuri.IThirdPartyService port = service.getBasicHttpBindingIThirdPartyService(); 
// TODO initialize WS operation arguments here 
java.lang.String key = line.trim(); 
// TODO process result here 
String>)port.getTests(key).getKeyValueOfintstring(); 
com.microsoft.schemas._2003._10.serialization.arrays.ArrayOfKeyValueOfintstring result = port.getVulnerabilities(key); 

编辑

for(int i=0;i<=result.getKeyValueOfintstring().size();i++) 
{ 
    result.getKeyValueOfintstring().get(i).getKey(); 
    result.getKeyValueOfintstring().get(i).getValue(); 
    JOptionPane.showMessageDialog(null, "key is"+result.getKeyValueOfintstring().get(i).getKey()); 
    JOptionPane.showMessageDialog(null, "Value is"+result.getKeyValueOfintstring().get(i).getValue()); 
    model.addElement(new Item(key, value)); 

} 

我试图让在对话框中的密钥对和我正确地得到它。但现在我没有得到如何将它们添加到我的组合框。我创建了表格“Vector model = new Vector();”并像这样将它添加到组合框中“cbTestName = new JComboBox(model);”

这是正确的方式,还是我需要应用任何其他功能将键值对添加到我的组合框中。

回答

0

如果你会去的

port.getTests(key).getKeyValueOfintstring()声明,

,你可能会发现它的实现为

List<KeyValuePairOfintstring> 

KeyValuePairOfintstring是看起来像

... 

    protected Integer key; 
... 
    protected String value; 

所以你可以做的其中一种方法是运行在循环中创建,然后使用您的Java业务对象构建您的地图,并且要在组合框中显示。

您可以重写对象的toString方法,作为控制它们在ComboBox中的外观的最简单方法。

+0

这里键我通过作为参数是我的身份验证密钥,而不是从“键值”对 – 2013-04-24 09:01:46

+0

您评论getKeyValueOfintstring()声明? – evgenyl 2013-04-24 09:30:42