Author: musachy
Date: Mon Jun 11 11:33:11 2007
New Revision: 546216
URL: http://svn.apache.org/viewvc?view=rev&rev=546216
Log:
WW-1848 Showcase, create an interactive OGNL demo
Added:
struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_1.jsp
- copied, changed from r545989,
struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_1.txt
struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_2.jsp
Removed:
struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_1.txt
Modified:
struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/example-action.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/index.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_0.jsp
Modified:
struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/example-action.jsp
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/example-action.jsp?view=diff&rev=546216&r1=546215&r2=546216
==============================================================================
---
struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/example-action.jsp
(original)
+++
struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/example-action.jsp
Mon Jun 11 11:33:11 2007
@@ -4,10 +4,11 @@
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy
server
%>
-<pre>
+<pre style="font-style: normal;">
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;
@@ -15,28 +16,34 @@
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";
+ return "John Galt";
}
public String[] getBands() {
- return new String[] { "Pink Floyd", "Metallica",
"Guns & Roses" };
+ return new String[] { "Pink Floyd", "Metallica", "Guns & Roses" };
}
-
- public Book getBook() {
- return new Book("Iliad", "Homer");
+
+ public List<String> getMovies() {
+ return Arrays.asList("Lord of the Rings", "Matrix");
}
- public List<String> getMovies() {
- return Arrays.asList("Lord of the Rings",
"Matrix");
+ public Book getBook() {
+ return new Book("Iliad", "Homer");
}
- public Map<String, Book> getBooks() {
- Map<String, Book> books = new HashMap<String, Book>();
- books.put("Iliad", new Book("Iliad",
"Homer"));
- books.put("The Republic", new Book("The
Replublic", "Plato"));
- books.put("Thus Spake Zarathustra", new Book("Thus
Spake Zarathustra", "Friedrich Nietzsche"));
+ public Map<String, Book> getBooks() {
+ Map<String, Book> books = new HashMap<String, Book>();
+ books.put("Iliad", new Book("Iliad", "Homer"));
+ books.put("The Republic", new Book("The Replublic", "Plato"));
+ books.put("Thus Spake Zarathustra", new Book("Thus Spake Zarathustra",
+ "Friedrich Nietzsche"));
return books;
}
}
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=546216&r1=546215&r2=546216
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/index.jsp
(original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/index.jsp
Mon Jun 11 11:33:11 2007
@@ -19,7 +19,7 @@
var ognlBase = "${ognlBase}";
var jspBase = "${jspBase}";
var ognlCount = 10;
- var jspCount = 1;
+ var jspCount = 3;
dojo.addOnLoad(function() {
var classSrc = dojo.byId("classSrc");
@@ -54,7 +54,7 @@
keyEvent({keyCode : 13}, '${jspEval}');
}
- function evalJSP(id) {
+ function execJSP(id) {
var exp = dojo.string.trim(dojo.byId(id ? id :
"example").innerHTML);
dojo.byId("jsp").value = unscape(exp);
@@ -129,12 +129,12 @@
.jsp {
border-style: solid;
width: 100%;
- height: 300px;
+ height: 200px;
}
.jspResult {
border-style: none;
width: 100%;
- height: 300px;
+ height: 200px;
padding: 5px;
}
.jspResultHeader {
@@ -166,6 +166,10 @@
}
.guide {
padding: 5px;
+ }
+ pre {
+ font-family:Verdana,Geneva,Arial,Helvetica,sans-serif;
+ font-style: italic;
}
</style>
</head>
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=546216&r1=546215&r2=546216
==============================================================================
--- 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
Mon Jun 11 11:33:11 2007
@@ -17,7 +17,7 @@
</i>
</p>
<p>
- If the value that you want to use in one of these string literal
attributes, is stored on the Value Stack,
+ 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>
@@ -56,4 +56,7 @@
<br />
<s:property value="%{#movie}" />
</i>
+</p>
+<p>
+ <a href="#"
onclick="window.open('http://struts.apache.org/2.x/docs/tag-syntax.html')">[More
details]</a>
</p>
Copied:
struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_1.jsp (from
r545989,
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.jsp?view=diff&rev=546216&p1=struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_1.txt&r1=545989&p2=struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_1.jsp&r2=546216
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_1.txt
(original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_1.jsp
Mon Jun 11 11:33:11 2007
@@ -19,7 +19,20 @@
</i>
</p>
<p>
- on the JSP console and hit enter. <a href="#"
onclick="evalJSP('example0')">Do it for me</a>
+ on the JSP console and hit enter. <a href="#"
onclick="execJSP('example0')">Do it for me</a>
+</p>
+<p>
+ As you saw in the OGNL demo, to print a property of an object that is not
on top of the stack,
+ use the <i>#object.property</i> notation.
+</p>
+<p>To print the value for the key "struts.view_uri" in <i>request</i> to the
page type:
+<p>
+ <i id="example1">
+ <s:property value="#request['struts.view_uri']" />
+ </i>
+</p>
+<p>
+ on the JSP console and hit enter. <a href="#"
onclick="execJSP('example1')">Do it for me</a>
</p>
<p>
<b>Print property value, using the <i>$</i> operator</b>
@@ -27,10 +40,13 @@
<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">
+ <i id="example2">
${name}
</i>
</p>
<p>
- on the JSP console and hit enter. <a href="#"
onclick="evalJSP('example1')">Do it for me</a>
+ on the JSP console and hit enter. <a href="#"
onclick="execJSP('example2')">Do it for me</a>
+</p>
+<p>
+ <a href="#"
onclick="window.open('http://struts.apache.org/2.x/docs/property.html')">[More
details]</a>
</p>
Added: struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_2.jsp
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_2.jsp?view=auto&rev=546216
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_2.jsp
(added)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/interactive/jsp_2.jsp
Mon Jun 11 11:33:11 2007
@@ -0,0 +1,54 @@
+<%
+ 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><i>if</i> tag</b>
+</p>
+<p>
+ The <i>if</i> tag allows you to optionally execute a JSP section. Multiple
<i>elseif</i> tags
+ and one <i>else</i> tag can be associated to an <i>if tag</i>.
+</p>
+<p>
+ To say hello to John Galt type:
+</p>
+<p>
+ <pre id="example0">
+ <s:if test="name == 'John Galt'">
+ Hi John
+ </s:if>
+ <s:else>
+ I don't know you!
+ </s:else>
+ </pre>
+</p>
+<p>
+ on the JSP console and hit enter. <a href="#"
onclick="execJSP('example0')">Do it for me</a>
+</p>
+<p>
+ <b><i>iterator</i> tag</b>
+</p>
+<p>
+ The <i>iterator</i> tag loops over an <i>Iterable</i> object one object at
a time into
+ the Value Stack (the value will be on top of the stack).
+</p>
+<p>
+ To print the all the elements in the "bands" property type:
+</p>
+<p>
+ <pre id="example1">
+ <s:iterator value="bands">
+ <s:property />
+ <br />
+ </s:iterator>
+ </pre>
+</p>
+<p>
+ on the JSP console and hit enter. <a href="#"
onclick="execJSP('example1')">Do it for me</a>
+</p>
+<p>
+ <a href="#"
onclick="window.open('http://struts.apache.org/2.x/docs/property.html')">[More
on the <i>if</i> tag]</a>
+ <a href="#"
onclick="window.open('http://struts.apache.org/2.x/docs/iterator.html')">[More
on the <i>iterator</i> tag]</a>
+</p>
\ No newline at end of file