PropertyModel<String> storeNameModel = new PropertyModel<String>(diskQuotaModel, "quotaStore");
if(diskQuotaModel.getObject().getQuotaStore() == null) {
storeNameModel.setObject(JDBCQuotaStoreFactory.H2_STORE);
}
final DropDownChoice<String> quotaStoreChooser = new DropDownChoice<String>("diskQuotaStore", storeNameModel, storeNames,
new LocalizedChoiceRenderer(this));
quotaStoreChooser.setOutputMarkupId(true);
quotaStoreContainer.add(quotaStoreChooser);
// add the JDBC container
final WebMarkupContainer jdbcContainer = new WebMarkupContainer("jdbcQuotaStoreContainer");
jdbcContainer.setOutputMarkupId(true);
jdbcContainer.setVisible("JDBC".equals(quotaStoreChooser.getModelObject()));
quotaStoreContainer.add(jdbcContainer);
// add a chooser for the dialect type
List<String> dialectBeanNames = new ArrayList<String>(applicationContext.getBeansOfType(SQLDialect.class).keySet());
List<String> dialectNames = new ArrayList<String>();
for (String beanName : dialectBeanNames) {
int idx = beanName.indexOf("QuotaDialect");
if(idx > 0) {
dialectNames.add(beanName.substring(0, idx));
}
}
JDBCConfiguration config = jdbcQuotaConfigModel.getObject();
IModel<String> dialectModel = new PropertyModel<String>(jdbcQuotaConfigModel, "dialect");
DropDownChoice<String> dialectChooser = new DropDownChoice<String>("dialectChooser", dialectModel, dialectNames);
dialectChooser.setRequired(true);
jdbcContainer.add(dialectChooser);
// add a chooser for the connection type
List<String> connectionTypes = Arrays.asList("JNDI", "PRIVATE_POOL");
Model<String> connectionTypeModel = new Model<String>();
if(config.getJNDISource() == null) {
connectionTypeModel.setObject("PRIVATE_POOL");
} else {
connectionTypeModel.setObject("JNDI");
}
final DropDownChoice<String> connectionTypeChooser = new DropDownChoice<String>("connectionTypeChooser",
connectionTypeModel, connectionTypes, new LocalizedChoiceRenderer(this));
connectionTypeChooser.setOutputMarkupId(true);
jdbcContainer.add(connectionTypeChooser);
// make the JDBC configuration visible only when the user chose a JDBC store
quotaStoreChooser.add(new AjaxFormComponentUpdatingBehavior("onChange") {