Permalink
Browse files

KARAF-1793 Fix configuration edit form

Signed-off-by: Lukasz Dywicki <luke@code-house.org>

git-svn-id: https://svn.apache.org/repos/asf/karaf/webconsole/trunk@1381414 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 4d802b7 commit 8ff8d2d76cf1c34c0903db9386c0c7250c2a9d9b @splatch splatch committed Sep 5, 2012
@@ -30,22 +30,27 @@
private static final long serialVersionUID = 1L;
private final FormComponent<?> component;
+ private Label help;
+
public LabelBorder(String id, FormComponent<?> component) {
super(id);
this.component = component;
- getBodyContainer().add(component);
- add(new SimpleFormComponentLabel("label", component));
- add(new Label("help", ""));
- add(new ComponentFeedbackPanel("error", component));
+ add(component);
+
+ addToBorder(
+ new SimpleFormComponentLabel("label", component),
+ help = new Label("help", ""),
+ new ComponentFeedbackPanel("error", component)
+ );
}
public void setHelp(String message) {
- addOrReplace(new Label("help", message));
+ help.setDefaultModelObject(message);
}
public void setHelp(IModel<?> message) {
- addOrReplace(new Label("help", message));
+ help.setDefaultModel(message);
}
@Override
@@ -44,16 +44,21 @@ public MapEditForm(String id, CompoundPropertyModel<Map<K, V>> model) {
RepeatingView repeatingView = new RepeatingView("entries");
for (K key : model.getObject().keySet()) {
- IModel<V> bind = model.bind("" + key);
+ IModel<V> bind = model.bind("[" + key + "]");
repeatingView.add(populateItem(repeatingView.newChildId(), key, bind));
}
add(repeatingView);
}
protected Component populateItem(String componentId, K key, IModel<V> value) {
+ return new LabelBorder(componentId, createField(key, value));
+ }
+
+ private FormComponent<?> createField(K key, IModel<V> value) {
FormComponent<V> field = new TextField<V>("value", value);
+ field.setType(String.class);
field.setLabel(of(key.toString()));
- LabelBorder border = new LabelBorder(componentId, field);
- return border;
+ return field;
}
+
}
@@ -28,7 +28,7 @@
public abstract class DictionaryUtils {
private DictionaryUtils() {
- System.out.println("How you did that?");
+ // utility class, no public constructor
}
/**
@@ -67,6 +67,9 @@ protected void onSubmit() {
try {
Configuration configuration = new ConfigurationModel(pid, configurationAdmin).getObject();
+ if (configuration.getBundleLocation() != null) {
+ configuration.setBundleLocation(null);
+ }
configuration.update(DictionaryUtils.dictionary(map));
Session.get().info("Configuration " + pid + " updated.");
@@ -38,25 +38,29 @@
public ConfigurationProvider(ConfigurationAdmin configurationAdmin) {
this.configurationAdmin = configurationAdmin;
- try {
- this.configurations = configurationAdmin.listConfigurations(null);
- } catch (Exception e) {
- throw new ConfigurationNotFoundException(null, e);
- }
}
public Iterator<? extends Configuration> iterator(int from, int count) {
- return Arrays.asList(Arrays.copyOfRange(configurations, from, count)).iterator();
+ return Arrays.asList(Arrays.copyOfRange(getConfigurations(), from, from + count)).iterator();
}
public IModel<Configuration> model(Configuration object) {
return new ConfigurationModel(object, configurationAdmin);
}
public int size() {
- return configurations.length;
+ return getConfigurations().length;
}
+ public Configuration[] getConfigurations() {
+ try {
+ configurations = configurationAdmin.listConfigurations(null);
+ } catch (Exception e) {
+ throw new ConfigurationNotFoundException(null, e);
+ }
+ return configurations;
+ }
+
@Override
public void detach() {
super.detach();
@@ -46,7 +46,7 @@ public ConfigurationModel(Configuration configuration, ConfigurationAdmin config
@Override
protected Configuration load() {
try {
- return configurationAdmin.getConfiguration(pid);
+ return configurationAdmin.getConfiguration(pid, null);
} catch (IOException e) {
throw new ConfigurationNotFoundException(pid, e);
}

0 comments on commit 8ff8d2d

Please sign in to comment.