You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mu...@apache.org on 2007/06/11 04:09:28 UTC

svn commit: r545989 - in /struts/struts2/trunk/apps/showcase/src/main/webapp/interactive: index.jsp jsp_0.jsp jsp_1.txt ognl_1.jsp ognl_2.jsp ognl_3.jsp ognl_4.jsp ognl_5.jsp ognl_6.jsp ognl_7.jsp ognl_8.jsp ognl_9.jsp

Author: musachy
Date: Sun Jun 10 19:09:27 2007
New Revision: 545989

URL: http://svn.apache.org/viewvc?view=rev&rev=545989
Log:
WW-1848 Showcase, create an interactive OGNL demo

Added:
    struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_1.txt
    struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_8.jsp
    struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_9.jsp
Modified:
    struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/index.jsp
    struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_0.jsp
    struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_1.jsp
    struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_2.jsp
    struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_3.jsp
    struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_4.jsp
    struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_5.jsp
    struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_6.jsp
    struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_7.jsp

Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/index.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/index.jsp?view=diff&rev=545989&r1=545988&r2=545989
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/index.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/index.jsp Sun Jun 10 19:09:27 2007
@@ -13,13 +13,12 @@
     
     <script src="${struts}/webconsole.js"></script>
     <sx:head/>
-    
     <script>
         var index = -1;
         var runningOgnl = true;
         var ognlBase = "${ognlBase}";
         var jspBase = "${jspBase}";
-        var ognlCount = 7;
+        var ognlCount = 10;
         var jspCount = 1;
         
         dojo.addOnLoad(function() {
@@ -177,13 +176,14 @@
     <sx:tabbedpanel id="mainTabContainer" cssClass="tabContainer">
         <sx:div label="OGNL Console" id="ognlTab">
             <div id="shell" class="shell">
-               <form onsubmit="return false">
+               <form onsubmit="return false" id="wc-form">
                     <div class="wc-results" id="wc-result">
                          Welcome to the OGNL console!
                          <br />
                          :-&gt;
                     </div>
-                    OGNL Expression <input onkeyup="keyEvent(event, '${jspEval}')" class="wc-command" id="wc-command" type="text" />
+                    <input type="hidden" name="debug" value="command" />
+                    OGNL Expression <input name="expression" onkeyup="keyEvent(event, '${jspEval}')" class="wc-command" id="wc-command" type="text" />
                 </form>
             </div>
         </sx:div>
@@ -197,7 +197,6 @@
                                 value="Eval JSP Fragment" 
                                 href="%{#jspEval}" 
                                 targets="jspResult" 
-                                highlightColor="#818EBD"
                                 listenTopics="/evalJSP"/>
                        </form>
                     </td>

Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_0.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_0.jsp?view=diff&rev=545989&r1=545988&r2=545989
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_0.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_0.jsp Sun Jun 10 19:09:27 2007
@@ -5,19 +5,55 @@
     response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
 %>
 <p>
-    <b>Accessing properites</b>
+    <b>String Attributes</b>
 </p>
 <p>
-    On the OGNL demo you learned how to access values from the Value Stack using OGNL expressions.
-    The <i>property</i> tag is used to print to the page, the result of an OGNL expression. The expression
-    is specified in the <i>value</i> attribute.
+    Some tag attributes are expected to be Strings in which case String literals
+    can be passed as the value, like the <i>href</i> attribute in the <i>a</i> tag.
 </p>
-<p>To print the value of the expression <i>name</i> to the page type:
 <p>
-    <i id="example">
-        &lt;s:property value=&quot;name&quot; /&gt;
+    <i>
+        &lt;s:a href=&quot;http://struts.apache.org/&quot; /&gt; 
     </i>
 </p>
 <p>
-    on the JSP console and hit enter. <a href="#" onclick="evalJSP()">Do it for me</a>
+   If the value that you want to use in one of these string literal attributes, is stored on the Value Stack,
+   then the <i>%{#name}</i> syntax (alternative syntax) needs to be used. Assuming there is a value
+   with the name "url" stored on the stack:
+</p>
+<p>
+    <i>
+        &lt;s:a href=&quot;%{#url}&quot; /&gt;
+    </i>
+</p>
+<p>
+  will create an anchor and use the value of "url" for the <i>href</i> attribute.
+</p>
+<p>
+    <b>Value Attributes</b>
+</p>
+<p>
+    Other attributes expect an object as their value(not an string literal). In these attributes you can specify
+    the name of a variable stored on the Value Stack, and the tag will look it up and use it. Like the
+    <i>value</i> attribute in the <i>property</i> tag. Assuming there is an object stored on the Value Stack with
+    the name "movie", then:
+</p>
+<p>
+    <i>
+        &lt;s:property value=&quot;movie&quot; /&gt;
+    </i>
+</p>
+<p>
+  will print the value to the page. To pass an String literal to an attribute that expects a value use the <i>%{'string'}</i>
+  notation.
+</p>
+<p>
+  If you don't remember if an attribute expects an string literal or a value, you can always use the <i>%{value}</i> notation:
+</p>
+<p>
+    <i>
+        &lt;s:a href=&quot;%{'http://struts.apache.org/'}&quot; /&gt;
+        <br />
+        &lt;s:property value=&quot;%{#movie}&quot; /&gt;
+    </i>
 </p>

Added: struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_1.txt
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_1.txt?view=auto&rev=545989
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_1.txt (added)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_1.txt Sun Jun 10 19:09:27 2007
@@ -0,0 +1,36 @@
+<%
+    request.setAttribute("decorator", "none");
+    response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
+    response.setHeader("Pragma","no-cache"); //HTTP 1.0
+    response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
+%>
+<p>
+    <b>Print property value, using the <i>property tag</i></b>
+</p>
+<p>
+    On the OGNL demo you learned how to access values from the Value Stack using OGNL expressions.
+    The <i>property</i> tag is used to print to the page the result of an OGNL expression. The expression
+    is specified in the <i>value</i> attribute.
+</p>
+<p>To print the value of the expression <i>name</i> to the page type:
+<p>
+    <i id="example0">
+        &lt;s:property value=&quot;name&quot; /&gt;
+    </i>
+</p>
+<p>
+    on the JSP console and hit enter. <a href="#" onclick="evalJSP('example0')">Do it for me</a>
+</p>
+<p>
+    <b>Print property value, using the <i>$</i> operator</b>
+</p>
+<p>Use the <i>${name}</i> notation to print values from the Value Stack to the page.
+<p>To print the value of the expression <i>name</i> to the page type:
+<p>
+    <i id="example1">
+        &#36;{name}
+    </i>
+</p>
+<p>
+    on the JSP console and hit enter. <a href="#" onclick="evalJSP('example1')">Do it for me</a>
+</p>

Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_1.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_1.jsp?view=diff&rev=545989&r1=545988&r2=545989
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_1.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_1.jsp Sun Jun 10 19:09:27 2007
@@ -21,4 +21,8 @@
 </p>
 <p>
     on the OGNL console and hit enter. <a href="#" onclick="execOgnl()">Do it for me</a>
+</p>
+<br/>
+<p>
+    <a href="#" onclick="window.open('http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/properties.html')">[More details]</a>
 </p>

Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_2.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_2.jsp?view=diff&rev=545989&r1=545988&r2=545989
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_2.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_2.jsp Sun Jun 10 19:09:27 2007
@@ -20,7 +20,7 @@
     </i>
 </p>
 <p>
-    on the OGNL console and it enter. <a href="#" onclick="execOgnl('example0')">Do it for me</a>
+    on the OGNL console and hit enter. <a href="#" onclick="execOgnl('example0')">Do it for me</a>
 </p>
 <p>
     <b>Accessing properties inside Lists</b>
@@ -36,4 +36,8 @@
 </p>
 <p>
     on the OGNL console and hit enter.  <a href="#" onclick="execOgnl('example1')">Do it for me</a>
+</p>
+<br/>
+<p>
+    <a href="#" onclick="window.open('http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/indexing.html#N10184')">[More details]</a>
 </p>

Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_3.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_3.jsp?view=diff&rev=545989&r1=545988&r2=545989
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_3.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_3.jsp Sun Jun 10 19:09:27 2007
@@ -48,3 +48,7 @@
 <p>
     on the OGNL console and hit enter. <a href="#" onclick="execOgnl('example2')">Do it for me</a>
 </p>
+<br/>
+<p>
+    <a href="#" onclick="window.open('http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/indexing.html#N10184')">[More details]</a>
+</p>

Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_4.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_4.jsp?view=diff&rev=545989&r1=545988&r2=545989
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_4.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_4.jsp Sun Jun 10 19:09:27 2007
@@ -24,5 +24,9 @@
     </i>
 </p>
 <p>
-    on the OGNL console and it enter.  <a href="#" onclick="execOgnl()">Do it for me</a>
+    on the OGNL console and hit enter.  <a href="#" onclick="execOgnl()">Do it for me</a>
+</p>
+<br/>
+<p>
+    <a href="#" onclick="window.open('http://struts.apache.org/2.x/docs/ognl.html')">[More details]</a>
 </p>

Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_5.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_5.jsp?view=diff&rev=545989&r1=545988&r2=545989
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_5.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_5.jsp Sun Jun 10 19:09:27 2007
@@ -19,7 +19,7 @@
     </i>
 </p>
 <p>
-    on the OGNL console and it enter.  <a href="#" onclick="execOgnl('example0')">Do it for me</a>
+    on the OGNL console and hit enter.  <a href="#" onclick="execOgnl('example0')">Do it for me</a>
 </p>
 <p>To execute the static method <i>getCurrentDate</i> in the ExampleAction type:</p>
 <p>
@@ -28,5 +28,10 @@
     </i>
 </p>
 <p>
-    on the OGNL console and it enter.  <a href="#" onclick="execOgnl('example1')">Do it for me</a>
+    on the OGNL console and hit enter.  <a href="#" onclick="execOgnl('example1')">Do it for me</a>
+</p>
+<br/>
+<p>
+    <a href="#" onclick="window.open('http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/staticFields.html')">[More details on static fields]</a>
+    <a href="#" onclick="window.open('http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/staticMethods.html')">[More details on static methods]</a>
 </p>

Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_6.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_6.jsp?view=diff&rev=545989&r1=545988&r2=545989
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_6.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_6.jsp Sun Jun 10 19:09:27 2007
@@ -17,5 +17,9 @@
     </i>
 </p>
 <p>
-    on the OGNL console and it enter.  <a href="#" onclick="execOgnl()">Do it for me</a>
+    on the OGNL console and hit enter.  <a href="#" onclick="execOgnl()">Do it for me</a>
+</p>
+<br/>
+<p>
+    <a href="#" onclick="window.open('http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/methods.html')">[More details]</a>
 </p>

Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_7.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_7.jsp?view=diff&rev=545989&r1=545988&r2=545989
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_7.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_7.jsp Sun Jun 10 19:09:27 2007
@@ -10,12 +10,34 @@
 <p>
   OGNL supports expressions using primitive values.
 </p>
-<p>Example 1:</p>
+<p>Arithmetic:</p>
 <p>
-    <i id="example">
-        (6 - 2)/2 
+    <i id="example0">
+        (6 - 2)/2
     </i>
 </p>
 <p>
-    on the OGNL console and it enter.  <a href="#" onclick="execOgnl()">Do it for me</a>
+    on the OGNL console and hit enter.  <a href="#" onclick="execOgnl('example0')">Do it for me</a>
+</p>
+<p>Logical:</p>
+<p>
+    <i id="example1">
+        (true || false) and true
+    </i>
+</p>
+<p>
+    on the OGNL console and hit enter.  <a href="#" onclick="execOgnl('example1')">Do it for me</a>
+</p>
+<p>Equality:</p>
+<p>
+    <i id="example2">
+        'a' == 'a'
+    </i>
+</p>
+<p>
+    on the OGNL console and hit enter.  <a href="#" onclick="execOgnl('example2')">Do it for me</a>
+</p>
+<p>
+    OGNL supports many more operators and expressions, see <a href="#" onclick="window.open('http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/apa.html#operators')">[Operators Reference]</a>
+    for more details.
 </p>

Added: struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_8.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_8.jsp?view=auto&rev=545989
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_8.jsp (added)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_8.jsp Sun Jun 10 19:09:27 2007
@@ -0,0 +1,55 @@
+<%
+    request.setAttribute("decorator", "none");
+    response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
+    response.setHeader("Pragma","no-cache"); //HTTP 1.0
+    response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
+%>
+<p><b>Creating arrays</b></p>
+<p>
+    OGNL follows Java syntax to create arrys.
+</p>
+<p>
+    Create an array of integers:
+</p>
+<p>
+    <i id="example0">
+        new int[] {0, 1, 2}
+    </i>
+</p>
+<p>
+    on the OGNL console and hit enter. <a href="#" onclick="execOgnl('example0')">Do it for me</a>
+</p>
+<p><b>Creating lists</b></p>
+<p>
+    To create a list, enclose a list of comma separated expression in a pair of braces.
+</p>
+<p>
+    Create a list of Strings:
+</p>
+<p>
+    <i id="example1">
+        {'Is', 'there', 'any', 'body', 'out', 'there?'}
+    </i>
+</p>
+<p>
+    on the OGNL console and hit enter. <a href="#" onclick="execOgnl('example1')">Do it for me</a>
+</p>
+<p><b>Creating maps</b></p>
+<p>
+    To create a map, use the syntax #@MAP_TYPE@{key:value}.
+</p>
+<p>
+    Create a LinkedHashMap:
+</p>
+<p>
+    <i id="example2">
+        #@java.util.LinkedHashMap@{'name': 'John Galt', 'job' : 'Engineer'}
+    </i>
+</p>
+<p>
+    on the OGNL console and hit enter. <a href="#" onclick="execOgnl('example2')">Do it for me</a>
+</p>
+<br/>
+<p>
+    <a href="#" onclick="window.open('http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/collectionConstruction.html#listConstruction')">[More details]</a>
+</p>
\ No newline at end of file

Added: struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_9.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_9.jsp?view=auto&rev=545989
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_9.jsp (added)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_9.jsp Sun Jun 10 19:09:27 2007
@@ -0,0 +1,17 @@
+<%
+    request.setAttribute("decorator", "none");
+    response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
+    response.setHeader("Pragma","no-cache"); //HTTP 1.0
+    response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
+%>
+<p>
+    <b>More on OGNL</b>
+</p>
+<p>
+  There are a lot of OGNL features that we have not covered on this short tutorial. 
+</p>
+<br/>
+<p>
+    To learn more see the <a href="#" onclick="window.open('http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/index.html')">[OGNL Documentation]</a>
+</p>
+<a href="#" onclick="startJSP()">Start JSP Interactive Demo</a>
\ No newline at end of file