Panel parameterPanel;
if("dbtype".equals(paramName) || "filetype".equals(paramName)) {
// skip the two well known discriminators
IModel model = new MapModel(paramsModel, paramName);
TextParamPanel tp = new TextParamPanel(componentId,
model, new ResourceModel(paramLabel, paramLabel), required);
tp.setVisible(false);
parameterPanel = tp;
} else if ("namespace".equals(paramName)) {
IModel namespaceModel = new NamespaceParamModel(paramsModel, paramName);
IModel paramLabelModel = new ResourceModel(paramLabel, paramLabel);
parameterPanel = new NamespacePanel(componentId, namespaceModel, paramLabelModel, true);
} else if (Boolean.class == binding) {
// TODO Add prefix for better i18n?
parameterPanel = new CheckBoxParamPanel(componentId, new MapModel(paramsModel,
paramName), new ResourceModel(paramLabel, paramLabel));
} else if (String.class == binding && paramMetadata.isPassword()) {
parameterPanel = new PasswordParamPanel(componentId, new MapModel(paramsModel,
paramName), new ResourceModel(paramLabel, paramLabel), required);
} else {
IModel model;
if("url".equalsIgnoreCase(paramName)) {
model = new URLModel(paramsModel, paramName);
} else {
model = new MapModel(paramsModel, paramName);
}
TextParamPanel tp = new TextParamPanel(componentId,
model, new ResourceModel(paramLabel, paramLabel), required);
// if it can be a reference to the local filesystem make sure it's valid
if (paramName.equalsIgnoreCase("url")) {
tp.getFormComponent().add(new FileExistsValidator());
}
// make sure the proper value is returned, but don't set it for strings otherwise
// we incur in a wicket bug (the empty string is not converter back to a null)
// GR: it doesn't work for File neither.
// AA: better not mess with files, the converters turn data dir relative to
// absolute and bye bye data dir portability
if (binding != null && !String.class.equals(binding) && !File.class.equals(binding)
&& !URL.class.equals(binding)) {
tp.getFormComponent().setType(binding);
}
parameterPanel = tp;
}
return parameterPanel;
}