You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by rossdevereux <ro...@lifecycle-software.com> on 2008/10/23 15:00:01 UTC

RadioGroup set selection from database results

Hi,

>From a database I am retrieving two columns, the label for the radio and a
boolean value to say whether or not it should be selected. I have written
the code below to get the values from the database, the ObjectSelect class
contains the object (in this case the string label) and selected which is a
boolean value. When the page loads the none of the radio choices are
selected. 

Is it possible to set the default value in this way, if not how can it be
done?

-------------------------------------CODE--------------------------------------------
//Add query type radio group
queryTypes = new LoadableDetachableModel() {
	@Override
	protected Object load() {
		QueryTypeWrapper.setObjects(queryDefDao.getQueryType(queryDefId));
		return QueryTypeWrapper.getObjects();
	}
};
	   
//Generate list of groups with checkboxes
final RadioGroup radioGroup = new RadioGroup("radioGroup", queryTypes);
f.add(radioGroup);
ListView radioList = new ListView("queryTypes", queryTypes)
{
	protected void populateItem(ListItem item)
	{
		ObjectSelect os = (ObjectSelect) item.getModelObject();
		item.setModel(new CompoundPropertyModel(os));
		item.add(new Radio("selected"));
		item.add(new Label("object"));
	}

};
radioGroup.add(radioList);
-------------------------------------CODE--------------------------------------------

Thanks in advanced
Ross
-- 
View this message in context: http://www.nabble.com/RadioGroup-set-selection-from-database-results-tp20130427p20130427.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org