Commits

Anonymous committed 91c68b4

Updating config-browser for new syntax with a backward-compatible option

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@667573baa09-0c28-0410-bef9-dab3c582ae83

Comments (0)

Files changed (7)

src/config-browser/com/opensymphony/webwork/config_browser/ShowValidatorAction.java

             for (int i = 0; i < pds.length; i++) {
                 PropertyDescriptor pd = pds[i];
                 String name = pd.getName();
-                try {
-                    Object expr = OgnlUtil.compile(name);
-                    Object value = Ognl.getValue(expr, context, validator);
-                    properties.add(new PropertyInfo(name, pd.getPropertyType(), value));
-                } catch (OgnlException e) {
-                    addActionError("Caught OGNL exception while getting property value for '" + name + "' on validator of type " + validator.getClass().getName());
+                Object value = null;
+                if (pd.getReadMethod() == null) {
+                    value = "No read method for property";
+                } else {
+                    try {
+                        Object expr = OgnlUtil.compile(name);
+                        value = Ognl.getValue(expr, context, validator);
+                    } catch (OgnlException e) {
+                        addActionError("Caught OGNL exception while getting property value for '" + name + "' on validator of type " + validator.getClass().getName());
+                    }
                 }
+                properties.add(new PropertyInfo(name, pd.getPropertyType(), value));
             }
         } catch (Exception e) {
             log.warn("Unable to retrieve properties.", e);

src/config-browser/config-browser-oldSyntax.xml

+<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.0.dtd">
+
+<xwork>
+    <include file="webwork-default.xml"/>
+
+    <package name="config" extends="webwork-default" namespace="/config-browser">
+        <interceptors>
+            <interceptor-stack name="config-browser-default">
+                <interceptor-ref name="component"/>
+                <interceptor-ref name="validationWorkflowStack"/>
+            </interceptor-stack>
+        </interceptors>
+        <default-interceptor-ref name="config-browser-default"/>
+
+        <global-results>
+            <result name="error" type="velocity">/error.vm</result>
+            <result name="input" type="velocity">/error.vm</result>
+        </global-results>
+
+        <action name="actionNames" class="com.opensymphony.webwork.config_browser.ActionNamesAction">
+            <result type="velocity" name="success">/actionNames.vm</result>
+        </action>
+
+        <action name="showConfig" class="com.opensymphony.webwork.config_browser.ShowConfigAction">
+            <result type="velocity" name="success">/old-syntax/showConfig.vm</result>
+        </action>
+
+        <action name="showValidators" class="com.opensymphony.webwork.config_browser.ListValidatorsAction">
+            <result name="error" type="velocity">/simple-error.vm</result>
+            <result name="input" type="velocity">/simple-error.vm</result>
+            <result type="velocity" name="success">/showValidators.vm</result>
+        </action>
+
+        <action name="validatorDetails" class="com.opensymphony.webwork.config_browser.ShowValidatorAction">
+            <result type="velocity" name="success">/old-syntax/validatorDetails.vm</result>
+        </action>
+    </package>
+</xwork>

src/config-browser/old-syntax/showConfig.vm

+#parse("/tigris-macros.vm")
+#startPage("Action information")
+<h3>Action information - $actionName</h3>
+
+#set ($params = "")
+#foreach ($name in $config.params.keySet())
+	#set ($params = "$name = $config.params.get($name)<br>")
+#end
+<table>
+	<tr><td width="100%">
+#bodytag (Form)
+	#tag (Label "label='Action name'" "name='actionName'")
+	#tag (Label "label='Namespace'" "name='namespace'")
+	#tag (Label "label='Action class'" "name='config.class'")
+	#tag (Label "label='Action method'" "name='config.method.name'")
+	#tag (Label "label='Parameters'" "name='config.params'")
+	<tr><td align="right">Location :</td><td><a href="${req.contextPath}${namespace}/${actionName}.action">${req.contextPath}${namespace}/${actionName}.action</a></td></tr>
+	<!-- #tag (Label "label='Location'" "name='<a href=\"${req.contextPath}${namespace}/${actionName}.action\">${req.contextPath}${namespace}/${actionName}.action</a>'") -->
+#end
+
+	</td><td style="text-align: right;"><!-- Placeholder for Action Graph --></td></tr>
+</table>
+<!-- URLTag is faulty -->
+#set($url = "showConfig.action?namespace=$namespace&actionName=$actionName&detailView=")
+<!-- Set all to false -->
+#set($detailsSelected = false)
+#set($interceptorsSelected = false)
+#set($propertiesSelected = false)
+#set($validatorsSelected = false)
+<!-- Set selected to true -->
+#if($detailView == "results")
+	#set($detailsSelected = true)
+#elseif($detailView == "interceptors")
+	#set($interceptorsSelected = true)
+#elseif($detailView == "properties")
+	#set($propertiesSelected = true)
+#else
+    #set($validatorsSelected = true)
+#end
+
+#startTabs()
+	#tab("Results" "${url}results" $detailsSelected)
+	#tab("Interceptors" "${url}interceptors" $interceptorsSelected)
+	#tab("Properties" "${url}properties" $propertiesSelected)
+	#tab("Validators" "${url}validators" $validatorsSelected)
+#endTabs()
+
+#if($detailsSelected)
+	<!-- Action results -->
+    <table width="100%">
+    	<tr><th>Name</th><th>Type</th><th>Parameters</th></tr>
+    	#foreach ($r in $config.results)
+    		#rows()
+    			<td>$r.name</td>
+    			<td>$r.className</td>
+    			<td>
+    				#foreach ($name in $r.params.keySet())
+    					$name = $r.params.get($name)<br>
+    				#end
+    			</td>
+    		</tr>
+    	#end
+    </table>
+#elseif ($interceptorsSelected)
+	<!-- Action interceptors -->
+    <table width="100%">
+        <tr><th>Name</th><th>Type</th></tr>
+        #foreach ($i in $config.interceptors)
+    		#rows()
+    			<td>$action.stripPackage($i.class)</td>
+    			<td>$i.class.name</td>
+    		</tr>
+    	#end
+    </table>
+#elseif ($propertiesSelected)
+    <table width="100%">
+        <tr><th>Name</th><th>Type</th></tr>
+        #foreach ($prop in $properties)
+    		#rows()
+    			<td>$prop.name</td>
+    			<td>$prop.propertyType.name</td>
+    		</tr>
+    	#end
+    </table>
+#else
+    #bodytag (Action "name='showValidators'" "executeResult=true")
+        #param("clazz" "$config.className")
+        #param("context" "$actionName")
+    #end
+#end
+
+#endPage()

src/config-browser/old-syntax/validatorDetails.vm

+#parse("/tigris-macros.vm")
+#set ($hideNav = true)
+#startPage("Validator Details")
+<table>
+<tr><td width="100%">
+#bodytag (Form)
+    #tag( Label "label='Validated Class'" "name='$action.stripPackage($clazz)'")
+    #tag( Label "label='Context'" "name='$context'")
+    #tag( Label "label='Validator Number'" "name='$selected'")
+    #tag( Label "label='Validator Type'" "name='$action.stripPackage($selectedValidator.class)'")
+#end
+</td><td style="text-align: right;"><!-- Placeholder for Action Graph --></td></tr>
+</table>
+<table width="100%" title="Properties">
+    <tr><th>Name</th><th>Value</th><th>Type</th></tr>
+    #foreach ($prop in $properties)
+        #rows()
+            <td>$prop.name</td>
+            <td>#if ($prop.value) $prop.value #else <b>null</b> #end</td>
+            <td>$prop.type.name</td>
+        </tr>
+    #end
+</table>
+#endPage()

src/config-browser/showConfig.vm

 <table>
 	<tr><td width="100%">
 #bodytag (Form)
-	#tag (Label "label='Action name'" "name='actionName'")
-	#tag (Label "label='Namespace'" "name='namespace'")
-	#tag (Label "label='Action class'" "name='config.class'")
-	#tag (Label "label='Action method'" "name='config.method.name'")
-	#tag (Label "label='Parameters'" "name='config.params'")
+	#tag (Label "label=Action name" "name=actionName")
+	#tag (Label "label=Namespace" "name=namespace")
+	#tag (Label "label=Action class" "name=config.class")
+	#tag (Label "label=Action method" "name=config.method.name")
+	#tag (Label "label=Parameters" "name=config.params")
 	<tr><td align="right">Location :</td><td><a href="${req.contextPath}${namespace}/${actionName}.action">${req.contextPath}${namespace}/${actionName}.action</a></td></tr>
 	<!-- #tag (Label "label='Location'" "name='<a href=\"${req.contextPath}${namespace}/${actionName}.action\">${req.contextPath}${namespace}/${actionName}.action</a>'") -->
 #end
     	#end
     </table>
 #else
-    #bodytag (Action "name='showValidators'" "executeResult=true")
+    #bodytag (Action "name=showValidators" "executeResult=true")
         #param("clazz" "$config.className")
         #param("context" "$actionName")
     #end

src/config-browser/validatorDetails.vm

 <table>
 <tr><td width="100%">
 #bodytag (Form)
-    #tag( Label "label='Validated Class'" "name='$action.stripPackage($clazz)'")
-    #tag( Label "label='Context'" "name='$context'")
-    #tag( Label "label='Validator Number'" "name='$selected'")
-    #tag( Label "label='Validator Type'" "name='$action.stripPackage($selectedValidator.class)'")
+    #tag( Label "label=Validated Class" "name=$action.stripPackage($clazz)")
+    #tag( Label "label=Context" "name=$context")
+    #tag( Label "label=Validator Number" "name=$selected")
+    #tag( Label "label=Validator Type" "name=$action.stripPackage($selectedValidator.class)")
 #end
 </td><td style="text-align: right;"><!-- Placeholder for Action Graph --></td></tr>
 </table>

src/etc/example/xwork.xml

 <xwork>
 
     <include file="webwork-default.xml"/>
-    <include file="config-browser.xml"/>
+    <include file="config-browser-oldSyntax.xml"/>
 
     <package name="default" extends="webwork-default">