Drop Down List - setSelected from Database

Hi there!

I added a drop-down list: cboActive onto a page. I use the "configure default options" to add to options: 1) Active.. Value 1.. 2)Non Active.. Value 0.

I can save it to the Database it works fine.

I then do this in the prerender to read the values...

When I try to read it from the database... the following line shows the CORRECT value in the message box:

info("Here: " + stock_stockUpdateDataProvider1.getValue("Active"));

BUT

When I try to set the value, it doesn't set it:

String sVal = (String) stock_stockUpdateDataProvider1.getValue("Active");

cboActive.setSelected(sVal);

Doesn't work....

cboActive.setSelected(stock_stockUpdateDataProvider1.getValue("Active"));

Also doesnt work...

Here's the whole code for that section...

public void prerender() {

//cboGroupID.setSelected(new Integer(0)); //Default to be N/A

try {

getSessionBean1().getStock_stockUpdateRowSet1().setObject(1, getSessionBean1().getStockID());

stock_stockUpdateDataProvider1.refresh();

info("Here: " + stock_stockUpdateDataProvider1.getValue("Active"));

txtPackSize.setValue((Double) stock_stockUpdateDataProvider1.getValue("PackSize"));

String sVal = (String) stock_stockUpdateDataProvider1.getValue("Active");

cboActive.setSelected(sVal);

} catch (Exception ex) {

log("Error Description", ex);

}

}

Please help me - thanks

[1482 byte] By [mpraath] at [2007-11-26 11:52:03]
# 1
From the code I guess you want to set selected item for checkboxgroup component, is that right? If it is the case, it has to be arrary of String cboActive.setSelected(new String[] {sVal} );
sherryz at 2007-7-7 12:07:40 > top of Java-index,Development Tools,Java Tools...