portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r506863 - in /portals/jetspeed-2/trunk/applications/demo/src: java/org/apache/jetspeed/demo/simple/PickANumberPortlet.java webapp/WEB-INF/demo/simple/PickANumber.jsp
Date Tue, 13 Feb 2007 05:22:12 GMT
Author: taylor
Date: Mon Feb 12 21:22:11 2007
New Revision: 506863

URL: http://svn.apache.org/viewvc?view=rev&rev=506863
Log:
better facilitate distributed prefs testing by not putting prefs in session

Modified:
    portals/jetspeed-2/trunk/applications/demo/src/java/org/apache/jetspeed/demo/simple/PickANumberPortlet.java
    portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumber.jsp

Modified: portals/jetspeed-2/trunk/applications/demo/src/java/org/apache/jetspeed/demo/simple/PickANumberPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/demo/src/java/org/apache/jetspeed/demo/simple/PickANumberPortlet.java?view=diff&rev=506863&r1=506862&r2=506863
==============================================================================
--- portals/jetspeed-2/trunk/applications/demo/src/java/org/apache/jetspeed/demo/simple/PickANumberPortlet.java
(original)
+++ portals/jetspeed-2/trunk/applications/demo/src/java/org/apache/jetspeed/demo/simple/PickANumberPortlet.java
Mon Feb 12 21:22:11 2007
@@ -141,6 +141,9 @@
         Long targetValue = null;
         Long lastGuess = null;
         
+        // get the current value in the prefs
+        long range = getHighRange(request);
+        System.out.println("cheater: top range  = " + range);
         // Get target value
         lastGuess = (Long)session.getAttribute(LAST_GUESS_NAME, PortletSession.APPLICATION_SCOPE);
         if (lastGuess == null)
@@ -154,7 +157,7 @@
         targetValue = (Long)session.getAttribute(TARGET_VALUE_NAME, PortletSession.APPLICATION_SCOPE);
         if (targetValue == null)
         {            
-            targetValue = new Long(Math.round(Math.random() * getHighRange(request)));
+            targetValue = new Long(Math.round(Math.random() * range));
             System.out.println("cheater: target value = " + targetValue);
             guessCount = new Long(0);
             session.setAttribute( TARGET_VALUE_NAME, targetValue, PortletSession.APPLICATION_SCOPE);
@@ -170,9 +173,9 @@
         }
 
         Long highRange = (Long)session.getAttribute(TOP_RANGE_NAME, PortletSession.APPLICATION_SCOPE);
-        if (highRange == null)
+        
+        if ((highRange == null) || (highRange.longValue() != range))
         {
-            long range = getHighRange(request);
             session.setAttribute( TOP_RANGE_NAME, new Long(range), PortletSession.APPLICATION_SCOPE);
         }
         

Modified: portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumber.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumber.jsp?view=diff&rev=506863&r1=506862&r2=506863
==============================================================================
--- portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumber.jsp
(original)
+++ portals/jetspeed-2/trunk/applications/demo/src/webapp/WEB-INF/demo/simple/PickANumber.jsp
Mon Feb 12 21:22:11 2007
@@ -28,36 +28,36 @@
 <%
     PortletSession portletSession = renderRequest.getPortletSession(true);
     Long value = (Long)portletSession.getAttribute("LastGuess", PortletSession.APPLICATION_SCOPE);
   
-    long lastGuess = 0;
+    long LastGuess = 0;
     if (value != null)
     {
-    	lastGuess = value.longValue();
+    	LastGuess = value.longValue();
     }       	
 %>
 
-<c:set var="guessCount" scope="session" value="${GuessCount}"/>
-<c:set var="targetValue" scope="session" value="${TargetValue}"/>
-<c:set var="lastGuess" scope="session" value="${LastGuess}"/>
-<c:set var="topRange" scope="session" value="${TopRange}"/>
+<c:set var="GuessCount" scope="session" value="${GuessCount}"/>
+<c:set var="TargetValue" scope="session" value="${TargetValue}"/>
+<c:set var="LastGuess" scope="session" value="${LastGuess}"/>
+<c:set var="TopRange" scope="session" value="${TopRange}"/>
 
 <h2>
 <fmt:message key="pickanumber.label.pickanumberguess"/>
 </h2>
 
 <c:choose>
-<c:when test="${empty guessCount}">
+<c:when test="${empty GuessCount}">
 </c:when>
-<c:when test="${targetValue == lastGuess}">
+<c:when test="${TargetValue == LastGuess}">
 </c:when>
 <c:otherwise>
 <fmt:message key="pickanumber.label.guessthusfar">
-	<fmt:param><c:out value="${guessCount}"/></fmt:param>
+	<fmt:param><c:out value="${GuessCount}"/></fmt:param>
 </fmt:message>
 </c:otherwise>
 </c:choose>
 
 <c:choose>
-<c:when test="${targetValue == lastGuess}">
+<c:when test="${TargetValue == LastGuess}">
 <p>
 <fmt:message key="pickanumber.label.startnewgame"/><br/><fmt:message key="pickanumber.label.enternumber"><fmt:param><c:out
value="${TopRange}"/></fmt:param></fmt:message>
 </p>
@@ -71,20 +71,20 @@
 
 <p>
   <c:choose>
-    <c:when test="${empty targetValue}">
+    <c:when test="${empty TargetValue}">
        <fmt:message key="pickanumber.label.readytostartanewgame"/>
     </c:when>  
-    <c:when test="${empty lastGuess}">
+    <c:when test="${empty LastGuess}">
        <fmt:message key="pickanumber.label.readytostartanewgame"/>
     </c:when>      
-    <c:when test="${targetValue == lastGuess}">
-      <center><strong><fmt:message key="pickanumber.label.guessiscorrect"><fmt:param><%=lastGuess%></fmt:param><fmt:param><c:out
value="${guessCount}"/></fmt:param></fmt:message></strong></center>
-      <c:remove var="targetValue" scope="session"/> 
+    <c:when test="${TargetValue == LastGuess}">
+      <center><strong><fmt:message key="pickanumber.label.guessiscorrect"><fmt:param><%=LastGuess%></fmt:param><fmt:param><c:out
value="${GuessCount}"/></fmt:param></fmt:message></strong></center>
+      <c:remove var="TargetValue" scope="session"/> 
     </c:when>
-    <c:when test="${targetValue < lastGuess}">
+    <c:when test="${TargetValue < LastGuess}">
       <fmt:message key="pickanumber.label.guessedtohigh"/>
     </c:when>
-    <c:when test="${targetValue > lastGuess}">
+    <c:when test="${TargetValue > LastGuess}">
       <fmt:message key="pickanumber.label.guessedtolow"/>
     </c:when>
     <c:otherwise>
@@ -94,7 +94,7 @@
 </p>
 <p>
   <form action="<%=myAction%>" method="POST">
-    <input type="text" name="Guess" value="<%=lastGuess%>"/>
+    <input type="text" name="Guess" value="<%=LastGuess%>"/>
     <input type="submit" value='<fmt:message key="pickanumber.label.guess"/>'/>
   </form>
 </p>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message