2011-09-07 81 views
-1

以下是.JSP代码来填充组合框:帮助与组合框在JSP代码

<% 
    { 
    List <String> lststringIncidentIds = new ArrayList <String>(); 
    lststringIncidentIds.clear(); 
    String AllIds; 
    AllIds = ""; 

    for (int i =0; i<wp.size();i++) 
    { 

AllIds = ""; 
//1st work product 
WorkProduct wpa; 
wpa = wp.get(i); 

//Metadata of Work Product 
PackageMetadataType pms; 
pms = wpa.getPackageMetadata(); 

IdentificationType Elementa; 
pms.getPackageMetadataExtensionAbstract().get(0).getValue(); 

Elementa = (IdentificationType) 
wp.get(i).getPackageMetadata().getPackageMetadataExtensionAbstract().get(0).getValue(); 
AllIds = Elementa.getIdentifier().getValue(); 
lststringIncidentIds.add(AllIds); 
out.println("Incident ID: " + i + " " +AllIds + "<br>"); 

我想AllIds变量传递给一个组合框。

回答

0
<body> 
    <h1>Hello World!</h1> 
    <% 
     JFrame f; 
     JComboBox cmbox; 
     JPanel panel; 


     //ComboBox b= new ComboBox(); 
     String course[] = {"BCA","MCA","PPC","CIC"}; 
     cmbox = new JComboBox(course); 
     panel = new JPanel(); 
     panel.add(cmbox); 
     //panel.setSize(400,400); 
     //panel.setVisible(true); 
     f=new JFrame("My Frame"); 
     f.add(panel); 
     f.setSize(400,300); 
     f.setVisible(true); 
     %> 

    </body> 
     the combobox will not appear in the browser as its a swing component but this 

     code will help u understand the difference....try it... 
+0

非常感谢Aparna。 – kanak

+0

你能告诉我上述问题的解决方案吗? – kanak