struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r422423 - in /struts/struts2/trunk/apps/showcase/src/main: java/org/apache/struts2/showcase/hangman/ resources/ webapp/hangman/
Date Sun, 16 Jul 2006 09:58:16 GMT
Author: tmjee
Date: Sun Jul 16 02:58:16 2006
New Revision: 422423

URL: http://svn.apache.org/viewvc?rev=422423&view=rev
Log:
WW-1375 finnish up hangman example

Added:
    struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanMenu.ftl
    struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanNonAjax.ftl
Modified:
    struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GuessCharacterAction.java
    struts/struts2/trunk/apps/showcase/src/main/resources/struts-hangman.xml
    struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanAjax.ftl
    struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/updateCharacterAvailable.ftl

Modified: struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GuessCharacterAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GuessCharacterAction.java?rev=422423&r1=422422&r2=422423&view=diff
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GuessCharacterAction.java
(original)
+++ struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GuessCharacterAction.java
Sun Jul 16 02:58:16 2006
@@ -12,18 +12,17 @@
 	
 	private Map session;
 	private Character character;
-	
+	private Hangman hangman;
 	
 	public String execute() throws Exception {
-		Hangman hangman = (Hangman) session.get(HangmanConstants.HANGMAN_SESSION_KEY);
+		hangman = (Hangman) session.get(HangmanConstants.HANGMAN_SESSION_KEY);
 		hangman.guess(character);
 		
-		System.out.println("\n\n\n");
-		System.out.println("character="+character);
-		System.out.println("available="+hangman.getCharactersAvailable().size());
-		System.out.println("\n\n\n");
-		
 		return SUCCESS;
+	}
+	
+	public Hangman getHangman() {
+		return hangman;
 	}
 
 	public void setSession(Map session) {

Modified: struts/struts2/trunk/apps/showcase/src/main/resources/struts-hangman.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/resources/struts-hangman.xml?rev=422423&r1=422422&r2=422423&view=diff
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/resources/struts-hangman.xml (original)
+++ struts/struts2/trunk/apps/showcase/src/main/resources/struts-hangman.xml Sun Jul 16 02:58:16
2006
@@ -7,14 +7,20 @@
 <struts>
 	<include file="struts-default.xml" />
 	<package name="hangman" extends="struts-default" namespace="/hangman">
-		<action name="hangman" class="startHangmanAction">
-			<result type="freemarker">/hangman/hangman.ftl</result>		
+		<action name="hangmanAjax" class="startHangmanAction">
+			<result type="freemarker">/hangman/hangmanAjax.ftl</result>		
+		</action>
+		<action name="hangmanNonAjax" class="startHangmanAction">
+			<result type="freemarker">/hangman/hangmanNonAjax.ftl</result>
 		</action>
 		<action name="test">
 			<result type="freemarker">/hangman/test.ftl</result>
 		</action>
 		<action name="guessCharacter" class="guessCharacterAction">
 			<result type="freemarker">/hangman/blank.ftl</result>
+		</action>
+		<action name="guessCharacterNonAjax" class="guessCharacterAction">
+			<result type="freemarker">/hangman/hangmanNonAjax.ftl</result>
 		</action>
 	</package>
 	

Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanAjax.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanAjax.ftl?rev=422423&r1=422422&r2=422423&view=diff
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanAjax.ftl (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanAjax.ftl Sun Jul 16
02:58:16 2006
@@ -179,7 +179,7 @@
     <@saf.iterator id="currentCharacter" value="%{hangman.vocab.inCharacters()}" stat="stat">
     	<#if hangman.characterGuessedBefore(currentCharacter)>
     		<@saf.set name="chalkboardImageName" value="%{'Chalkboard_'+#currentCharacter.toString()+'.png'}"
/>
-    		<@saf.url id="url" value="%{'/hangman/images/'+#url}" />
+    		<@saf.url id="url" value="%{'/hangman/images/'+#chalkboardImageName}" />
     		<img height="36" alt="<@saf.property value="%{#currentCharacter}" />"
         		src="<@saf.property value="%{#url}" />" width="36" border="0"/>
     	<#else>

Added: struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanMenu.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanMenu.ftl?rev=422423&view=auto
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanMenu.ftl (added)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanMenu.ftl Sun Jul 16
02:58:16 2006
@@ -0,0 +1,18 @@
+
+<html>
+<head>
+	<title>Showcase - Hangman - Menu</title>
+</head>
+<body>
+	<ul>
+		<li>
+			<@saf.url id="url" action="hangmanAjax" namespace="/hangman" />
+			<@saf.a href="%{#url}">Hangman (Ajax)</@saf.a>
+		</li>
+		<li>
+			<@saf.url id="url" action="hangmanNonAjax" namespace="/hangman" />
+			<@saf.a href="%{#url}">Hangman (Non Ajax)</@saf.a>
+		</li>
+	</ul>
+</body>
+</html>

Added: struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanNonAjax.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanNonAjax.ftl?rev=422423&view=auto
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanNonAjax.ftl (added)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanNonAjax.ftl Sun Jul
16 02:58:16 2006
@@ -0,0 +1,135 @@
+<html>
+<head>
+	<title>Showcase - Hangman</title>
+	<@saf.head theme="xhtml" />
+</head>
+<body>
+<table bgcolor="green"> 
+  <tr> 
+    <td>
+    <@saf.url id="url" value="/hangman/images/hangman.png" />
+    <img alt="Hangman" src="<@saf.property value="%{#url}" />" 
+           width="197" height="50" border="0"/> 
+    </td> 
+    <td width="70" align="right">
+      <#-- Guesses Left -->
+      <div id="updateGuessLeftDiv">
+      <#if (hangman.guessLeft() >= 0)>
+      <@saf.set name="guessLeftImageName" value="%{'Chalkboard_'+hangman.guessLeft()+'.png'}"
/>
+      <@saf.url id="url" value="%{'/hangman/images/'+#guessLeftImageName}" />
+      <img alt="No. Guesses Left"
+      	   src="<@saf.property value="%{#url}"/>" width="20" height="20" border="0"
/>
+      </#if>
+      </div>
+    </td>
+    <td>
+    	<@saf.url id="url" value="/hangman/images/guesses-left.png" /> 
+    	<img alt="Guesses Left"
+            src="<@saf.property value="%{#url}" />" width="164" height="11" border="0"/>

+    </td>
+  </tr> 
+  <tr> 
+  	<td></td>
+    <td align="left">
+    <#-- Display Scaffold -->
+  	<div id="updateScaffoldDiv">
+    	<@saf.set name="scaffoldImageName" value="%{'scaffold_'+hangman.guessLeft()+'.png'}"
/>
+    	<@saf.url id="url" value="%{'/hangman/images/'+#scaffoldImageName}" />
+    	<img src="<@saf.property value="%{#url}" />" border="0"/> 
+    </div>
+    </td>
+    <td></td>
+    </tr> 
+  <tr>
+    <td width="160"> 
+      <p align="right">
+      	<@saf.url id="url" value="/hangman/images/guess.png" />
+        <img alt="Current Guess" src="<@saf.property value="%{#url}" />"
+           align="MIDDLE" width="127" height="20" border="0"/></p> 
+    </td> 
+    <td>
+    <#-- Display Vacab  -->
+    <div id="updateVocabDiv">
+    <#if hangman.gameEnded()>
+		<@saf.iterator id="currentCharacter" value="%{hangman.vocab.inCharacters()}" stat="stat">
+			<@saf.url id="url" value="%{'/hangman/images/Chalkboard_'+#currentCharacter.toString()+'.png'}"
/>
+			<img height="36" alt="<@saf.property value="%{#currentCharacter}" />"
+		 			src="<@saf.property value="%{#url}" />" width="36" border="0" />
+		</@saf.iterator>
+	<#else>
+    <@saf.iterator id="currentCharacter" value="%{hangman.vocab.inCharacters()}" stat="stat">
+    	<#if hangman.characterGuessedBefore(currentCharacter)>
+    		<@saf.set name="chalkboardImageName" value="%{'Chalkboard_'+#currentCharacter.toString()+'.png'}"
/>
+    		<@saf.url id="url" value="%{'/hangman/images/'+#chalkboardImageName}" />
+    		<img height="36" alt="<@saf.property value="%{#currentCharacter}" />"
+        		src="<@saf.property value="%{#url}" />" width="36" border="0"/>
+    	<#else>
+    		<@saf.url id="url" value="/hangman/images/Chalkboard_underscroll.png" />
+    		<img height="36" alt="_"
+        		src="<@saf.property value="%{#url}" />" width="36" border="0"/>
+    	</#if>
+	</@saf.iterator>
+	</#if>
+	</div>
+    </td> 
+  </tr>
+  <tr> 
+    <td valign="top"> 
+      <p align="right">
+      	<@saf.url id="url" value="/hangman/images/choose.png" />
+        <img alt="Choose" src="<@saf.property value="%{#url}" />" 
+             height="20" width="151" border="0"/>
+      </p> 
+    </td> 
+    <td width="330">
+    
+    <#-- Show Characters Available -->
+    <div id="updateCharacterAvailableDiv">
+    <#if hangman.gameEnded()>
+	<@saf.set name="winImageName" value="%{'you-win.png'}" />
+	<@saf.set name="looseImageName" value="%{'you-lose.png'}" />
+	<@saf.set name="startImageName" value="%{'start.png'}" />
+	<@saf.url id="winImageUrl" value="%{'/hangman/images/'+#winImageName}"  />
+	<@saf.url id="looseImageUrl" value="%{'/hangman/images/'+#looseImageName}" />
+	<@saf.url id="startImageUrl" value="%{'/hangman/images/'+#startImageName}" />
+	<@saf.url id="startHref" action="hangmanNonAjax" namespace="/hangman" />
+	
+	<#if hangman.isWin()>
+	<img src="<@saf.property value="%{#winImageUrl}" />" width="341" height="44" />
+	<#else>
+	<img src="<@saf.property value="%{#looseImageUrl}" />" width="381" height="44"
/>
+	</#if>
+	<@saf.a href="%{#startHref}">
+		<img src="<@saf.property value="%{#startImageUrl}" />" width="250" height="43"
/>
+	</@saf.a>
+	<#else>
+	<@saf.iterator id="currentCharacter" value="%{hangman.charactersAvailable}" status="stat">
+      <@saf.set name="chalkboardImageName" value="%{'Chalkboard_'+#currentCharacter+'.png'}"
/>
+      <@saf.url id="chalkboardImageUrl" value="%{'/hangman/images/'+#chalkboardImageName}"
/>
+      <@saf.url id="spacerUrl" value="/hangman/images/letter-spacer.png" />
+      <@saf.url id="url" action="guessCharacterNonAjax" namespace="/hangman">
+      	<@saf.param name="character" value="%{#currentCharacter}" />
+      </@saf.url>
+      
+      <@saf.a href="%{#url}"
+      		  id="%{#currentCharacter}" 
+      		  >
+      	<img height="36" alt="" src="<@saf.property value="%{#chalkboardImageUrl}" />"
width="36" border="0" />
+      </@saf.a>
+	</@saf.iterator>
+	</#if>
+	</div>
+ 
+   
+   </td>
+  </tr> 
+  <tr>
+  	<td>
+  		
+  	</td>
+  </tr>
+</table>
+</body>
+</html>
+
+

Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/updateCharacterAvailable.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/updateCharacterAvailable.ftl?rev=422423&r1=422422&r2=422423&view=diff
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/updateCharacterAvailable.ftl
(original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/updateCharacterAvailable.ftl
Sun Jul 16 02:58:16 2006
@@ -5,7 +5,7 @@
 	<@saf.url id="winImageUrl" value="%{'/hangman/images/'+#winImageName}"  />
 	<@saf.url id="looseImageUrl" value="%{'/hangman/images/'+#looseImageName}" />
 	<@saf.url id="startImageUrl" value="%{'/hangman/images/'+#startImageName}" />
-	<@saf.url id="startHref" action="hangman" namespace="/hangman" />
+	<@saf.url id="startHref" action="hangmanAjax" namespace="/hangman" />
 	
 	<#if hangman.isWin()>
 	<img src="<@saf.property value="%{#winImageUrl}" />" width="341" height="44" />



Mime
View raw message