2011-09-07 82 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