gsDialog.setTitle(new Model(windowTitle));
gsDialog.showOkCancel(target, new GeoServerDialog.DialogDelegate() {
@Override
protected boolean onSubmit(AjaxRequestTarget target, Component contents) {
GeoServerFileChooser chooser = (GeoServerFileChooser) contents;
String path = ((File) chooser.getDefaultModelObject()).getAbsolutePath();
// clear the raw input of the field won't show the new model value
textField.clearInput();
textField.setModelValue(new String[] { path });
target.addComponent(textField);
return true;
}
@Override
public void onClose(AjaxRequestTarget target) {
// update the field with the user chosen value
target.addComponent(textField);
}
@Override
protected Component getContents(String id) {
File file = null;
textField.processInput();
String input = (String) textField.getConvertedInput();
if (input != null && !input.equals("")) {
file = new File(input);
}
GeoServerFileChooser chooser = new GeoServerFileChooser(id, new Model(file));
chooser.setFilter(fileFilter);
return chooser;
}
});
}