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/10 03:13:06 UTC
svn commit: r545825 - in /struts/struts2/trunk/apps/showcase/src/main:
java/org/apache/struts2/showcase/action/ webapp/interactive/
Author: musachy
Date: Sat Jun 9 18:13:05 2007
New Revision: 545825
URL: http://svn.apache.org/viewvc?view=rev&rev=545825
Log:
WW-1848 Showcase, create an interactive OGNL demo
Added:
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/java/org/apache/struts2/showcase/action/ExampleAction.java
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_0.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_1.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_4.jsp
Modified: struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/action/ExampleAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/action/ExampleAction.java?view=diff&rev=545825&r1=545824&r2=545825
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/action/ExampleAction.java (original)
+++ struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/action/ExampleAction.java Sat Jun 9 18:13:05 2007
@@ -21,6 +21,7 @@
package org.apache.struts2.showcase.action;
import java.util.Arrays;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -28,7 +29,12 @@
import com.opensymphony.xwork2.ActionSupport;
public class ExampleAction extends ActionSupport {
-
+ public static final String CONSTANT = "Struts Rocks!";
+
+ public static Date getCurrentDate() {
+ return new Date();
+ }
+
public String getName() {
return "John Galt";
}
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=545825&r1=545824&r2=545825
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/index.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/index.jsp Sat Jun 9 18:13:05 2007
@@ -19,7 +19,7 @@
var runningOgnl = true;
var ognlBase = "${ognlBase}";
var jspBase = "${jspBase}";
- var ognlCount = 5;
+ var ognlCount = 7;
var jspCount = 1;
dojo.addOnLoad(function() {
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=545825&r1=545824&r2=545825
==============================================================================
--- 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 Sat Jun 9 18:13:05 2007
@@ -12,7 +12,7 @@
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>To print the value of the expression <i>name</i> to the page type:
<p>
<i id="example">
<s:property value="name" />
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_0.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_0.jsp?view=diff&rev=545825&r1=545824&r2=545825
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_0.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_0.jsp Sat Jun 9 18:13:05 2007
@@ -5,7 +5,7 @@
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
<p>
- <b>Accessing properites</b>
+ <b>Accessing properties</b>
</p>
<p>
The framework uses a standard naming context to evaluate OGNL expressions.
@@ -17,7 +17,8 @@
In this example (and in your JSP pages) the last action executed will be on the top of the stack.
</p>
<p>
- <a href="#" onclick="selectClassSrcTab()">This action</a> is available on the third tab above. To access the <i>name</i> field enter:
+ <a href="#" onclick="selectClassSrcTab()">This action</a> is available on the third tab above.
+ To access the <i>name</i> field type:
</p>
<p>
<i id="example">
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=545825&r1=545824&r2=545825
==============================================================================
--- 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 Sat Jun 9 18:13:05 2007
@@ -5,7 +5,7 @@
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
<p>
- <b>Accessing nested properites</b>
+ <b>Accessing nested properties</b>
</p>
<p>
To access nested properties, use the dot "." operator to concatenate the property names. The action
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=545825&r1=545824&r2=545825
==============================================================================
--- 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 Sat Jun 9 18:13:05 2007
@@ -5,7 +5,7 @@
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
<p>
- <b>Accessing properites</b>
+ <b>Accessing properties on the stack</b>
</p>
<p>
Object that are not on the top of the Value Stack are accessed using the "#name" notation.
@@ -17,10 +17,10 @@
<li>#request</li>
<li>#parameters</li>
</ul>
-<p>To see the value os the parameters type</p>
+<p>To see the value of the first parameter type:</p>
<p>
<i id="example">
- #parameters
+ #parameters['debug'][0]
</i>
</p>
<p>
Added: 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=auto&rev=545825
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_5.jsp (added)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_5.jsp Sat Jun 9 18:13:05 2007
@@ -0,0 +1,32 @@
+<%
+ 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>Static fields</b>
+</p>
+<p>
+ Static fields can easily be accessed in OGNL expressions using the notation
+ <i>@some.package.ClassName@PROPERTY_NAME</i> for properties, and <i>@some.package.ClassName@METHOD_NAME()</i>
+ for methods.
+</p>
+<p>To access the value of the <i>CONSTANT</i> field in the ExampleAction type:</p>
+<p>
+ <i id="example0">
+ @org.apache.struts2.showcase.action.ExampleAction@CONSTANT
+ </i>
+</p>
+<p>
+ on the OGNL console and it 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>
+ <i id="example1">
+ @org.apache.struts2.showcase.action.ExampleAction@getCurrentDate()
+ </i>
+</p>
+<p>
+ on the OGNL console and it enter. <a href="#" onclick="execOgnl('example1')">Do it for me</a>
+</p>
\ No newline at end of file
Added: 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=auto&rev=545825
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_6.jsp (added)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_6.jsp Sat Jun 9 18:13:05 2007
@@ -0,0 +1,21 @@
+<%
+ 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>Calling methods</b>
+</p>
+<p>
+ OGNL follows Java's syntax to execute a method.
+</p>
+<p>To execute the <i>getTitle()</i> method on the <i>book</i> object type:</p>
+<p>
+ <i id="example">
+ book.getTitle()
+ </i>
+</p>
+<p>
+ on the OGNL console and it enter. <a href="#" onclick="execOgnl()">Do it for me</a>
+</p>
\ No newline at end of file
Added: 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=auto&rev=545825
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_7.jsp (added)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/ognl_7.jsp Sat Jun 9 18:13:05 2007
@@ -0,0 +1,21 @@
+<%
+ 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>Expressions</b>
+</p>
+<p>
+ OGNL supports expressions using primitive values.
+</p>
+<p>Example 1:</p>
+<p>
+ <i id="example">
+ (6 - 2)/2
+ </i>
+</p>
+<p>
+ on the OGNL console and it enter. <a href="#" onclick="execOgnl()">Do it for me</a>
+</p>
\ No newline at end of file