cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From coli...@apache.org
Subject cvs commit: cocoon-2.1/src/scratchpad/webapp/samples/petstore/view/jxpath Cart.xml SearchProducts.xml
Date Tue, 22 Apr 2003 20:03:44 GMT
coliver     2003/04/22 13:03:43

  Modified:    src/scratchpad/src/org/apache/cocoon/generation
                        FlowVelocityGenerator.java JXTemplate.java
               src/scratchpad/webapp/samples/petstore/view/jexl Cart.xml
                        SearchProducts.xml
               src/scratchpad/webapp/samples/petstore/view/jxpath Cart.xml
                        SearchProducts.xml
  Log:
  clean up
  
  Revision  Changes    Path
  1.6       +33 -15    cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/FlowVelocityGenerator.java
  
  Index: FlowVelocityGenerator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/FlowVelocityGenerator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FlowVelocityGenerator.java	15 Apr 2003 06:52:28 -0000	1.5
  +++ FlowVelocityGenerator.java	22 Apr 2003 20:03:42 -0000	1.6
  @@ -112,16 +112,39 @@
   /**
    * <p>Cocoon {@link Generator} that produces dynamic XML SAX events
    * from a Velocity template file.</p>
  - *
  - * <p> This differs from VelocityGenerator only in the objects that
  - * populate the velocity context passed to the template. In this
  - * generator there are two objects:
  - * <ul>
  - * <li><code>flowContext</code> - which represents the bean that was
from the Flowscript </li>
  - * <li><code>continuation</code> - which represents the current continuation
- an instance of {@link org.apache.cocoon.components.flow.WebContinuation}</li>
  - * </ul>
  - * The immediate properties of the bean object are also available in the context
  + * If called from a Flowscript, the immediate properties of the context object from the
Flowscript are available in the Velocity context.
  + * In that case, the current Web Continuation from the Flowscript 
  + * is also available as a variable named <code>continuation</code>. You would

  + * typically access its <code>id</code>:
  + * <p><pre>
  + *    &lt;form action="$continuation.id"&gt;
  + * </pre></p>
  + * <p>You can also reach previous continuations by using the <code>getContinuation()</code>
function:</p>
  + * <p><pre>
  + *     &lt;form action="$continuation.getContinuation(1).id}" >
  + * </pre></p>
    * 
  + * In addition the following implicit objects are always available in
  + * the Velocity context:
  + * <p>
  + * <dl>
  + * <dt><code>request</code> (<code>org.apache.cocoon.environment.Request</code>)</dt>
  + * <dd>The Cocoon current request</dd>
  + *
  + * <dt><code>response</code> (<code>org.apache.cocoon.environment.Response</code>)</dt>
  + * <dd>The Cocoon response associated with the current request</dd>
  + *
  + * <dt><code>session</code> (<code>org.apache.cocoon.environment.Session</code>)</dt>
  + * <dd>The Cocoon session associated with the current request</dd>
  + *
  + * <dt><code>context</code> (<code>org.apache.cocoon.environment.Context</code>)</dt>
  + * <dd>The Cocoon context associated with the current request</dd>
  + *
  + * <dt><code>parameters</code> (<code>org.apache.avalon.framework.parameters.Parameters</code>)</dt>
  + * <dd>Any parameters passed to the generator in the pipeline</dd>
  + * </dl>
  + * </p>
  + *
    *
    * <h2>Sitemap Configuration</h2>
    *
  @@ -850,11 +873,6 @@
               final WebContinuation kont =
                   (WebContinuation) ((Environment) resolver).getAttribute("kont");
               
  -            // This velocity context provides two variables: "this" which represents the
  -            // bean object passed to sendPage*() and "continuation" which is the
  -            // current continuation. The immediate properties of the bean object are
  -            // also available in the context.
  -            //
               // Hack? I use JXPath to determine the properties of the bean object
               final JXPathBeanInfo bi = JXPathIntrospector.getBeanInfo(bean.getClass());
               DynamicPropertyHandler h = null;
  
  
  
  1.2       +27 -20    cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/JXTemplate.java
  
  Index: JXTemplate.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/JXTemplate.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JXTemplate.java	21 Apr 2003 05:34:46 -0000	1.1
  +++ JXTemplate.java	22 Apr 2003 20:03:43 -0000	1.2
  @@ -231,7 +231,7 @@
    * &lt;c:macro name="tablerows"&gt;
    *   &lt;c:parameter name="list"/&gt;
    *   &lt;c:parameter name="color"/&gt;
  - *   &lt;c:forEach var="item" items=${list}&gt;
  + *   &lt;c:forEach var="item" items="${list}"&gt;
    *     &lt;tr&gt;&lt;td bgcolor="${color}"&gt;${item}&lt;/td&gt;&lt;/tr&gt;
    *   &lt;/c:forEach&gt;
    * &lt;/c:macro&gt;
  @@ -762,29 +762,38 @@
       private Object getValue(Object expr, JexlContext jexlContext,
                               JXPathContext jxpathContext) 
           throws Exception {
  -        if (expr instanceof CompiledExpression) {
  -            CompiledExpression e = (CompiledExpression)expr;
  -            return e.getValue(jxpathContext);
  -        } else if (expr instanceof org.apache.commons.jexl.Expression) {
  -            org.apache.commons.jexl.Expression e = 
  -                (org.apache.commons.jexl.Expression)expr;
  -            return e.evaluate(jexlContext);
  +        try {
  +            if (expr instanceof CompiledExpression) {
  +                CompiledExpression e = (CompiledExpression)expr;
  +                return e.getValue(jxpathContext);
  +            } else if (expr instanceof org.apache.commons.jexl.Expression) {
  +                org.apache.commons.jexl.Expression e = 
  +                    (org.apache.commons.jexl.Expression)expr;
  +                return e.evaluate(jexlContext);
  +            }
  +            return expr;
  +        } catch (InvocationTargetException e) {
  +            throw e.getTargetException();
           }
  -        return expr;
       }
   
  +    // Hack: try to prevent JXPath from converting result to a String
       private Object getNode(Object expr, JexlContext jexlContext,
                               JXPathContext jxpathContext) 
           throws Exception {
  -        if (expr instanceof CompiledExpression) {
  -            CompiledExpression e = (CompiledExpression)expr;
  -            return e.getPointer(jxpathContext, "").getNode();
  -        } else if (expr instanceof org.apache.commons.jexl.Expression) {
  -            org.apache.commons.jexl.Expression e = 
  -                (org.apache.commons.jexl.Expression)expr;
  -            return e.evaluate(jexlContext);
  +        try {
  +            if (expr instanceof CompiledExpression) {
  +                CompiledExpression e = (CompiledExpression)expr;
  +                return e.getPointer(jxpathContext, "").getNode();
  +            } else if (expr instanceof org.apache.commons.jexl.Expression) {
  +                org.apache.commons.jexl.Expression e = 
  +                    (org.apache.commons.jexl.Expression)expr;
  +                return e.evaluate(jexlContext);
  +            }
  +            return expr;
  +        } catch (InvocationTargetException e) {
  +            throw e.getTargetException();
           }
  -        return expr;
       }
   
       class Event {
  @@ -1388,7 +1397,6 @@
                   } else {
                       if (params) {
                           params = false;
  -                        System.out.println("body="+e);
                           body = e;
                       }
                   }
  @@ -1444,8 +1452,7 @@
           }
       }
   
  -
  -    class Parser implements LexicalHandler, ContentHandler {
  +    class Parser implements ContentHandler, LexicalHandler {
   
           StartDocument startEvent;
           Event lastEvent;
  
  
  
  1.4       +8 -8      cocoon-2.1/src/scratchpad/webapp/samples/petstore/view/jexl/Cart.xml
  
  Index: Cart.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/scratchpad/webapp/samples/petstore/view/jexl/Cart.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Cart.xml	21 Apr 2003 05:34:46 -0000	1.3
  +++ Cart.xml	22 Apr 2003 20:03:43 -0000	1.4
  @@ -16,7 +16,7 @@
     <td><b>Item ID</b></td>  <td><b>Product ID</b></td>
 <td><b>Description</b></td>  <td><b>Quantity</b></td>
 <td><b>List Price</b></td>  <td> </td>
     </tr>
   
  -<t:if test="#{number(cartForm/cart/numberOfItems) = 0}"> 
  +<t:if test="${cartForm.cart.numberOfItems.intValue() == 0}"> 
   <tr bgcolor="#FFFF88"><td colspan="6"><b>Your cart is empty.</b></td></tr>
   </t:if>
   <t:forEach var="cartItem" items="${cartItems}">
  @@ -37,7 +37,7 @@
     <td align="center">
     <input type="text" size="3" name="${cartItem.item.ItemId}" value="${cartItem.quantity}"
/>
     </td>
  -  <td align="right">#{format-number(item/listPrice, '$#,##0.00')}</td>
  +  <td align="right">${fmt.formatNumber(item.listPrice, '$#,##0.00')}</td>
     <td><a href="removeItemFromCart.do?workingItemId=${cartItem.item.itemId}">
     <img border="0" src="images/button_remove.gif" /></a></td>
     </tr>
  @@ -45,7 +45,7 @@
   <tr bgcolor="#FFFF88">
   <td colspan="5" align="right">
   
  -<b>Sub Total: #{ format-number(cartForm/cart/subTotal, '$#,##0.00') }</b><br
/>
  +<b>Sub Total: ${fmt.formatNumber(cartForm.cart.subTotal, '$#,##0.00') }</b><br
/>
   <input type="image" border="0" src="images/button_update_cart.gif" name="update" />
   
   </td><td> </td>
  @@ -53,7 +53,7 @@
   </table>
   </form>
   
  -<t:if test="#{number(cartForm/cart/numberOfItems) > 0}">
  +<t:if test="$(cartForm.cart.numberOfItems.intValue() > 0}">
   <br /><center><a href="checkout.do"><img border="0" src="images/button_checkout.gif"
/></a></center>
   </t:if>
   
  @@ -61,10 +61,10 @@
   
   
   <td valign="top" width="20%" align="right">
  -<t:if test="#{accountForm}">
  - <t:if test="#{accountForm/account}">
  -  <t:if test="#{accountForm/account/username}">
  -    <t:if test="#{accountForm/account/listOption}">
  +<t:if test="${accountForm != null}">
  + <t:if test="${accountForm.account != null}">
  +  <t:if test="${accountForm.account.username != null}">
  +    <t:if test="${accountForm.account.listOption != null}">
         <t:import uri="view/jexl/IncludeMyList.xml"/>
       </t:if>
     </t:if>
  
  
  
  1.4       +1 -1      cocoon-2.1/src/scratchpad/webapp/samples/petstore/view/jexl/SearchProducts.xml
  
  Index: SearchProducts.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/scratchpad/webapp/samples/petstore/view/jexl/SearchProducts.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SearchProducts.xml	21 Apr 2003 05:34:46 -0000	1.3
  +++ SearchProducts.xml	22 Apr 2003 20:03:43 -0000	1.4
  @@ -5,7 +5,7 @@
           <backpointer name="Main Menu" do="index.do" />
           <search>
               <c:forEach var="item" items="${searchResultsProductList}" >
  -                <product name="${item.name} id="${item.productId}">
  +                <product name="${item.name}" id="${item.productId}">
                       <product-desc>${descn}</product-desc>
                   </product>
               </c:forEach>
  
  
  
  1.7       +3 -3      cocoon-2.1/src/scratchpad/webapp/samples/petstore/view/jxpath/Cart.xml
  
  Index: Cart.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/scratchpad/webapp/samples/petstore/view/jxpath/Cart.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Cart.xml	21 Apr 2003 05:34:47 -0000	1.6
  +++ Cart.xml	22 Apr 2003 20:03:43 -0000	1.7
  @@ -37,7 +37,7 @@
     <td align="center">
     <input type="text" size="3" name="#{item/itemId}" value="#{quantity}" />
     </td>
  -  <td align="right">#{ format-number(item/listPrice, '$#,##0.00') }</td>
  +  <td align="right">#{format-number(item/listPrice, '$#,##0.00')}</td>
     <td><a href="removeItemFromCart.do?workingItemId=#{item/itemId}">
     <img border="0" src="images/button_remove.gif" /></a></td>
     </tr>
  @@ -45,7 +45,7 @@
   <tr bgcolor="#FFFF88">
   <td colspan="5" align="right">
   
  -<b>Sub Total: #{ format-number(cartForm/cart/subTotal, '$#,##0.00') }</b><br
/>
  +<b>Sub Total: #{format-number(cartForm/cart/subTotal, '$#,##0.00')}</b><br
/>
   <input type="image" border="0" src="images/button_update_cart.gif" name="update" />
   
   </td><td> </td>
  @@ -54,7 +54,7 @@
   </form>
   
   <t:if test="#{number(cartForm/cart/numberOfItems) > 0}">
  -<br /><center><a href="checkout.do"><img border="0" src="images/button_checkout.gif"
/></a></center>
  +   <br /><center><a href="checkout.do"><img border="0" src="images/button_checkout.gif"
/></a></center>
   </t:if>
   
   </td>
  
  
  
  1.4       +1 -1      cocoon-2.1/src/scratchpad/webapp/samples/petstore/view/jxpath/SearchProducts.xml
  
  Index: SearchProducts.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/scratchpad/webapp/samples/petstore/view/jxpath/SearchProducts.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SearchProducts.xml	21 Apr 2003 05:34:47 -0000	1.3
  +++ SearchProducts.xml	22 Apr 2003 20:03:43 -0000	1.4
  @@ -1,6 +1,6 @@
   <?xml version="1.0"?>
   
  -<page xmlns:c="http://cocoon.apache.org/transformation/jxpath/1.0">
  +<page xmlns:c="http://cocoon.apache.org/generation/jx/1.0">
       <site signOn="#{accountForm/signOn}" view="jxpath">
           <backpointer name="Main Menu" do="index.do" />
           <search>
  
  
  

Mime
View raw message