KARAF-1793 Fix configuration edit form (file missed in previous commit).
authorŁukasz Dywicki <ldywicki@apache.org>
Wed, 5 Sep 2012 22:33:10 +0000 (22:33 +0000)
committerŁukasz Dywicki <ldywicki@apache.org>
Wed, 5 Sep 2012 22:33:10 +0000 (22:33 +0000)
Signed-off-by: Lukasz Dywicki <luke@code-house.org>
git-svn-id: https://svn.apache.org/repos/asf/karaf/webconsole/trunk@1381425 13f79535-47bb-0310-9956-ffa450edef68

osgi/config/src/main/java/org/apache/karaf/webconsole/osgi/config/ConfigurationEditPage.java

index f53895e..1c23ce1 100644 (file)
@@ -53,20 +53,20 @@ public class ConfigurationEditPage extends OsgiPage {
         pid = params.get("pid").toString();
 
         add(new Label("pid", pid));
-        Configuration configuration = new ConfigurationModel(pid, configurationAdmin).getObject();
+        ConfigurationModel configuration = new ConfigurationModel(pid, configurationAdmin);
+        setDefaultModel(configuration);
 
         @SuppressWarnings("unchecked")
-        Map<String, String> properties = DictionaryUtils.map(configuration.getProperties());
+        Map<String, String> properties = DictionaryUtils.map(configuration.getObject().getProperties());
         Map<String, String> system = ConfigurationFilterUtil.filter(properties);
-        CompoundPropertyModel<Map<String, String>> formModel = new CompoundPropertyModel<Map<String, String>>(properties);
 
-        MapEditForm<String, String> mapEditForm = new MapEditForm<String, String>("edit", formModel) {
+        MapEditForm<String, String> mapEditForm = new MapEditForm<String, String>("edit", new CompoundPropertyModel<Map<String, String>>(properties)) {
             @Override
             protected void onSubmit() {
                 Map<String, String> map = getModelObject();
 
+                Configuration configuration = (Configuration) ConfigurationEditPage.this.getDefaultModelObject();
                 try {
-                    Configuration configuration = new ConfigurationModel(pid, configurationAdmin).getObject();
                     if (configuration.getBundleLocation() != null) {
                         configuration.setBundleLocation(null);
                     }
@@ -75,7 +75,7 @@ public class ConfigurationEditPage extends OsgiPage {
                     Session.get().info("Configuration " + pid + " updated.");
                     RequestCycle.get().setResponsePage(ConfigurationsPage.class);
                 } catch (IOException e) {
-                    e.printStackTrace();
+                    error("Unable to update configuration " + e.getMessage());
                 }
             }
         };