FELIX-3817 Prepare for changing non-configuration-property parameter names
  - Define and use Java constants
  - Define and use client-side properties

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1426546 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java
index 2458aa7..9da0f08 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java
@@ -150,7 +150,7 @@
     String applyConfiguration( HttpServletRequest request, String pid )
         throws IOException
     {
-        if ( request.getParameter( "delete" ) != null ) //$NON-NLS-1$
+        if ( request.getParameter( ConfigManager.ACTION_DELETE ) != null ) //$NON-NLS-1$
         {
             // only delete if the PID is not our place holder
             if ( !ConfigManager.PLACEHOLDER_PID.equals( pid ) )
@@ -162,10 +162,10 @@
             return null; // return request.getHeader( "Referer" );
         }
 
-        String factoryPid = request.getParameter( ConfigManager.factoryPID );
+        String factoryPid = request.getParameter( ConfigManager.FACTORY_PID );
         Configuration config = null;
 
-        String propertyList = request.getParameter( "propertylist" ); //$NON-NLS-1$
+        String propertyList = request.getParameter( ConfigManager.PROPERTY_LIST ); //$NON-NLS-1$
         if ( propertyList == null )
         {
             // FIXME: this would be a bug !!
@@ -392,7 +392,7 @@
 
         if ( config.getFactoryPid() != null )
         {
-            json.key( ConfigManager.factoryPID );
+            json.key( ConfigManager.FACTORY_PID );
             json.value( config.getFactoryPid() );
         }
 
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
index 9fb2bc1..b657441 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
@@ -51,13 +51,17 @@
 
     static final String PID_FILTER = "pidFilter"; //$NON-NLS-1$
     static final String PID = "pid"; //$NON-NLS-1$
-    static final String factoryPID = "factoryPid"; //$NON-NLS-1$
+    static final String FACTORY_PID = "factoryPid"; //$NON-NLS-1$
+    static final String PLACEHOLDER_PID = "[Temporary PID replaced by real PID upon save]"; //$NON-NLS-1$
 
-    static final String CONFIGURATION_ADMIN_NAME = "org.osgi.service.cm.ConfigurationAdmin";
+    static final String ACTION_CREATE = "create"; //$NON-NLS-1$
+    static final String ACTION_DELETE = "delete"; //$NON-NLS-1$
+    static final String ACTION_APPLY = "apply"; //$NON-NLS-1$
+    static final String ACTION_UNBIND = "unbind"; //$NON-NLS-1$
+    static final String PROPERTY_LIST = "propertylist"; //$NON-NLS-1$
 
-    static final String META_TYPE_NAME = "org.osgi.service.metatype.MetaTypeService";
-
-    static final String PLACEHOLDER_PID = "[Temporary PID replaced by real PID upon save]";
+    static final String CONFIGURATION_ADMIN_NAME = "org.osgi.service.cm.ConfigurationAdmin"; //$NON-NLS-1$
+    static final String META_TYPE_NAME = "org.osgi.service.metatype.MetaTypeService"; //$NON-NLS-1$
 
     // templates
     private final String TEMPLATE;
@@ -141,12 +145,12 @@
         Configuration config = null;
 
         // should actually apply the configuration before redirecting
-        if ( request.getParameter( "create" ) != null ) //$NON-NLS-1$
+        if ( request.getParameter( ACTION_CREATE ) != null ) //$NON-NLS-1$
         {
             config = cas.getPlaceholderConfiguration( pid ); // ca.createFactoryConfiguration( pid, null );
             pid = config.getPid();
         }
-        else if ( request.getParameter( "apply" ) != null ) //$NON-NLS-1$
+        else if ( request.getParameter( ACTION_APPLY ) != null ) //$NON-NLS-1$
         {
             String redirect = cas.applyConfiguration( request, pid );
             if ( redirect != null )
@@ -172,7 +176,7 @@
         }
 
         // check for configuration unbinding
-        if ( request.getParameter( "unbind" ) != null ) //$NON-NLS-1$
+        if ( request.getParameter( ACTION_UNBIND ) != null ) //$NON-NLS-1$
         {
             if ( config != null && config.getBundleLocation() != null )
             {
@@ -367,7 +371,7 @@
         }
 
         // if a configuration is addressed, display it immediately
-        if ( request.getParameter( "create" ) != null && pid != null ) //$NON-NLS-1$
+        if ( request.getParameter( ACTION_CREATE ) != null && pid != null ) //$NON-NLS-1$
         {
             pid = PLACEHOLDER_PID; // new PlaceholderConfiguration( pid ).getPid();
         }
@@ -377,6 +381,12 @@
         DefaultVariableResolver vars = ( ( DefaultVariableResolver ) WebConsoleUtil.getVariableResolver( request ) );
         vars.put( "__data__", json.toString() ); //$NON-NLS-1$
         vars.put( "selectedPid", pid != null ? pid : ""); //$NON-NLS-1$ //$NON-NLS-2$
+        vars.put( "param.apply", ACTION_APPLY ); //$NON-NLS-1$
+        vars.put( "param.create", ACTION_CREATE ); //$NON-NLS-1$
+        vars.put( "param.unbind", ACTION_UNBIND ); //$NON-NLS-1$
+        vars.put( "param.delete", ACTION_DELETE ); //$NON-NLS-1$
+        vars.put( "param.propertylist", PROPERTY_LIST ); //$NON-NLS-1$
+        vars.put( "param.pidFilter", PID_FILTER ); //$NON-NLS-1$
 
         response.getWriter().print(TEMPLATE);
     }
diff --git a/webconsole/src/main/resources/res/ui/config.js b/webconsole/src/main/resources/res/ui/config.js
index 1fb4e6a..581fb5f 100644
--- a/webconsole/src/main/resources/res/ui/config.js
+++ b/webconsole/src/main/resources/res/ui/config.js
@@ -36,7 +36,7 @@
 	// we have to add a cache killer for IE8
 	var postUri = uri + '?';
 	if ( create ) {
-		postUri = postUri + 'create=1&';
+		postUri += param.create + '=1&';
 	}
 	postUri = postUri + 'ts='+new Date().getMilliseconds();
 	$.post(postUri, null, displayConfigForm, 'json');
@@ -61,7 +61,7 @@
     
     var inputEl = createElement( "input", null, {
             type: "hidden",
-            name: "apply",
+            name: param.apply,
             value: "true"
         });
     formEl.appendChild( inputEl );
@@ -78,11 +78,11 @@
     }
     
     // add the PID filter as a hidden form field if present
-    if (obj.pidFilter)
+    if (obj[ param.pidFilter ])
     {
         inputEl = createElement( "input", null, {
                 type: "hidden",
-                name: "pidFilter",
+                name: param.pidFilter,
                 value: obj.pidFilter
             });
         formEl.appendChild( inputEl );
@@ -186,7 +186,7 @@
     
     parent.appendChild( createElement( "input", null, {
             type: "hidden",
-            name: "propertylist",
+            name: param.propertylist,
             value: propList
         })
     );
@@ -405,7 +405,7 @@
 function deleteConfig(/* String */ configId, /* String */ bundleLocation)
 {
     if ( configConfirm(i18n.del_ask, configId, bundleLocation) ) {
-	$.post(pluginRoot + '/' + configId + '?apply=1&delete=1', null, function() {
+	$.post(pluginRoot + '/' + configId + '?' + param.apply + '=1&' + param.dele + '=1', null, function() {
 	    document.location.href = pluginRoot;
 	}, 'json');
 	return true;
@@ -416,7 +416,7 @@
 function unbindConfig(/* String */ configId, /* String */ bundleLocation)
 {
     if ( configConfirm(i18n.unbind_ask, configId, bundleLocation) ) {
-	$.post(pluginRoot + '/' + configId + '?unbind=1', null, function() {
+	$.post(pluginRoot + '/' + configId + '?' + param.unbind + '=1', null, function() {
 	    document.location.href = pluginRoot + '/' + configId;
 	}, 'json');
 	return true;
diff --git a/webconsole/src/main/resources/templates/config.html b/webconsole/src/main/resources/templates/config.html
index 5b0b852..1934d43 100644
--- a/webconsole/src/main/resources/templates/config.html
+++ b/webconsole/src/main/resources/templates/config.html
@@ -25,7 +25,15 @@
 	del_bundle   : '${config.del.bundle}', // "Bundle: ";
 	unbind_ask   : '${config.unbind.ask}', // "Are you sure to unbind this configuration ?"
 	err_bind     : '${config.bind.error}' // Error: the PID'{0}' is bound to '{1}' but the actual managed service is registered from '{2}' bundle
-}
+};
+var param = { // param
+    apply        : '${param.apply}',
+    create       : '${param.create}',
+    unbind       : '${param.unbind}',
+    dele         : '${param.delete}',
+    propertylist : '${param.propertylist}',
+    pidFilter    : '${param.pidFilter}'
+};
 // ]]>
 </script>