SF.net SVN: mx4j:[2275] branches/patches_3.1.0-beta1/mx4j/tools/src/main/ java/mx4j/tools/adaptor/http
[email protected] Sun, 22 Mar 2009 21:31:33 +0000
| Newsgroups | gmane.comp.java.mx4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 2275
http://mx4j.svn.sourceforge.net/mx4j/?rev=2275&view=rev
Author: altheengineer
Date: 2009-03-22 21:31:33 +0000 (Sun, 22 Mar 2009)
Log Message:
-----------
Feature that allows user to check a checkbox near the submit button of an operation to tell the InvokeOperationCommandProcessor to render the output unescaped. If no template is supplied, the new invokeplain.xsl template will be used to render the operation's result such that it only returns the output as the result (e.g. it removes the MX4J navigation and other chrome from the output so that all you get is unescaped output).
Modified Paths:
--------------
branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/InvokeOperationCommandProcessor.java
branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/invoke.xsl
branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/mbean.xsl
branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/mbean_attributes.xsl
branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/strings_en.xml
Added Paths:
-----------
branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/invokeplain.xsl
Modified: branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/InvokeOperationCommandProcessor.java
===================================================================
--- branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/InvokeOperationCommandProcessor.java 2009-03-21 20:53:21 UTC (rev 2274)
+++ branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/InvokeOperationCommandProcessor.java 2009-03-22 21:31:33 UTC (rev 2275)
@@ -28,6 +28,9 @@
*/
public class InvokeOperationCommandProcessor extends HttpCommandProcessorAdaptor
{
+ private static final String XSL_DOC_NAME_FOR_RENDER_INVOKE_PLAIN = "invokeplain";
+ private static final String RETURN_UNESCAPED_PARAM_NAME = "returnunescaped";
+
public InvokeOperationCommandProcessor()
{
}
@@ -44,6 +47,12 @@
String objectVariable = in.getVariable("objectname");
String operationVariable = in.getVariable("operation");
+ String returnUnescaped = in.getVariable(RETURN_UNESCAPED_PARAM_NAME);
+ if (returnUnescaped == null) {
+ returnUnescaped = "false";
+ } else if ("true".equalsIgnoreCase(returnUnescaped) && in.getVariable("template") == null) {
+ in.getVariables().put("template", XSL_DOC_NAME_FOR_RENDER_INVOKE_PLAIN);
+ }
if (objectVariable == null || objectVariable.equals("")
|| operationVariable == null || operationVariable.equals(""))
{
@@ -173,6 +182,7 @@
operationElement.setAttribute("returnclass", null);
operationElement.setAttribute("return", null);
}
+ operationElement.setAttribute(RETURN_UNESCAPED_PARAM_NAME, returnUnescaped);
}
catch (Exception e)
{
Modified: branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/invoke.xsl
===================================================================
--- branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/invoke.xsl 2009-03-21 20:53:21 UTC (rev 2274)
+++ branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/invoke.xsl 2009-03-22 21:31:33 UTC (rev 2275)
@@ -53,9 +53,10 @@
<xsl:call-template name="str">
<xsl:with-param name="id">invoke.operation.success.result</xsl:with-param>
<xsl:with-param name="p0">
- <xsl:call-template name="renderobject">
+ <xsl:call-template name="renderobjectescapeoption">
<xsl:with-param name="objectclass" select="@returnclass"/>
<xsl:with-param name="objectvalue" select="@return"/>
+ <xsl:with-param name="objectvalueunescaped" select="@returnunescaped" />
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
Added: branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/invokeplain.xsl
===================================================================
--- branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/invokeplain.xsl (rev 0)
+++ branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/invokeplain.xsl 2009-03-22 21:31:33 UTC (rev 2275)
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:output method="text" />
+
+ <!-- Overall parameters -->
+ <xsl:param name="html.stylesheet">stylesheet.css</xsl:param>
+ <xsl:param name="html.stylesheet.type">text/css</xsl:param>
+ <xsl:param name="head.title">invoke.title</xsl:param>
+
+ <!-- Request parameters -->
+ <xsl:param name="request.objectname"/>
+ <xsl:param name="request.method"/>
+
+ <xsl:include href="common.xsl"/>
+ <xsl:include href="mbean_attributes.xsl"/>
+
+ <!-- Operation invoke -->
+ <xsl:template name="operation">
+ <xsl:for-each select="Operation">
+ <xsl:if test="@result='success'">
+ <xsl:if test="not (@return='')">
+ <xsl:call-template name="str">
+ <xsl:with-param name="id">invoke.operation.success.resultplain</xsl:with-param>
+ <xsl:with-param name="p0">
+ <xsl:call-template name="renderobjectescapeoption">
+ <xsl:with-param name="objectclass" select="@returnclass"/>
+ <xsl:with-param name="objectvalue" select="@return"/>
+ <xsl:with-param name="objectvalueunescaped" select="@returnunescaped" />
+ </xsl:call-template>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="@return=''">
+ <xsl:call-template name="str">
+ <xsl:with-param name="id">invoke.operation.success.noresult</xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:if>
+ <xsl:if test="@result='error'">
+ <xsl:call-template name="str">
+ <xsl:with-param name="id">invoke.operation.success.error</xsl:with-param>
+ <xsl:with-param name="p0">
+ <xsl:value-of select="@errorMsg"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:template>
+
+ <!-- Main template -->
+ <xsl:template match="MBeanOperation" name="main">
+ <xsl:call-template name="operation"/>
+ </xsl:template>
+</xsl:stylesheet>
+
Modified: branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/mbean.xsl
===================================================================
--- branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/mbean.xsl 2009-03-21 20:53:21 UTC (rev 2274)
+++ branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/mbean.xsl 2009-03-22 21:31:33 UTC (rev 2275)
@@ -166,6 +166,7 @@
</td>
<xsl:if test="$hasParameters='false'">
<td align="center" class="mbean_row">
+ Check for output only: <input type="checkbox" name="returnunescaped" value="true"/> <br />
<input type="submit" value="{$invoke.str}"/>
</td>
</xsl:if>
@@ -215,7 +216,8 @@
<xsl:with-param name="class" select="$classtype"/>
</xsl:call-template>
</table>
- <td align="center" valign="bottom">
+ <td align="center" valign="bottom" class="mbean_row">
+ Check for output only: <input type="checkbox" name="returnunescaped" value="true"/> <br />
<input style="pad-right: 1em;" type="submit" value="{$invoke.str}"/>
</td>
</td>
Modified: branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/mbean_attributes.xsl
===================================================================
--- branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/mbean_attributes.xsl 2009-03-21 20:53:21 UTC (rev 2274)
+++ branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/mbean_attributes.xsl 2009-03-22 21:31:33 UTC (rev 2275)
@@ -195,7 +195,24 @@
<xsl:template name="renderobject">
<xsl:param name="objectclass"/>
<xsl:param name="objectvalue"/>
+ <xsl:call-template name="renderobjectescapeoption">
+ <xsl:with-param name="objectclass" select="$objectclass"/>
+ <xsl:with-param name="objectvalue" select="$objectvalue"/>
+ <xsl:with-param name="objectvalueunescaped">false</xsl:with-param>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template name="renderobjectescapeoption">
+ <xsl:param name="objectclass"/>
+ <xsl:param name="objectvalue"/>
+ <xsl:param name="objectvalueunescaped" />
<xsl:choose>
+ <xsl:when test="$objectvalueunescaped='true'">
+ <!-- Use the following line when the result of an invocation
+ returns e.g. HTML or XML data
+ -->
+ <xsl:value-of select="$objectvalue" disable-output-escaping="yes" />
+ </xsl:when>
<xsl:when test="$objectclass='javax.management.ObjectName'">
<xsl:variable name="name_encoded">
<xsl:call-template name="uri-encode">
@@ -209,10 +226,6 @@
</a>
</xsl:when>
<xsl:otherwise>
- <!-- Use the following line when the result of an invocation
- returns e.g. HTML or XML data
- <xsl:value-of select="$objectvalue" disable-output-escaping="true" />
- -->
<xsl:value-of select="$objectvalue"/>
</xsl:otherwise>
</xsl:choose>
Modified: branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/strings_en.xml
===================================================================
--- branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/strings_en.xml 2009-03-21 20:53:21 UTC (rev 2274)
+++ branches/patches_3.1.0-beta1/mx4j/tools/src/main/java/mx4j/tools/adaptor/http/xsl/strings_en.xml 2009-03-22 21:31:33 UTC (rev 2275)
@@ -181,6 +181,7 @@
<str id="invoke.operation.title">MBean operation: invoke method {0} on MBean {1}</str>
<str id="invoke.operation.success">Invocation successful</str>
<str id="invoke.operation.success.result">Result value: <pre>{0}</pre></str>
+ <str id="invoke.operation.success.resultplain">{0}</str>
<str id="invoke.operation.success.noresult">No result</str>
<str id="invoke.operation.success.error">Error during MBean operation invocation<br/>Message: {0}</str>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com