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") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
jdbcContainer.setVisible("JDBC".equals(quotaStoreChooser.getModelObject()));
target.addComponent(quotaStoreContainer);
}
});
// a container for jndi and local private pool options
final WebMarkupContainer connectionTypeContainer = new WebMarkupContainer("connectionTypeContainer");
connectionTypeContainer.setOutputMarkupId(true);
jdbcContainer.add(connectionTypeContainer);
// add a field for editing the JNDI connection parameters
final WebMarkupContainer jndiContainer = new WebMarkupContainer("jndiLocationContainer");
jndiContainer.setVisible(config.getJNDISource() != null);
connectionTypeContainer.add(jndiContainer);
IModel<String> jndiModel = new PropertyModel<String>(jdbcQuotaConfigModel, "jNDISource");
TextField<String> jndiLocation = new TextField<String>("jndiLocation", jndiModel);
jndiLocation.setRequired(true);
jndiContainer.add(jndiLocation);
// and a panel to edit the private jdbc pool
IModel<JDBCConfiguration.ConnectionPoolConfiguration> poolConfigurationModel =
new PropertyModel<JDBCConfiguration.ConnectionPoolConfiguration>(jdbcQuotaConfigModel, "connectionPool");
final JDBCConnectionPoolPanel privatePoolPanel = new JDBCConnectionPoolPanel("connectionPoolConfigurator", poolConfigurationModel);
privatePoolPanel.setVisible(config.getJNDISource() == null);
connectionTypeContainer.add(privatePoolPanel);
// make the two ways to configure the JDBC store show up as alternatives
connectionTypeChooser.add(new AjaxFormComponentUpdatingBehavior("onChange") {