Hi David,

Ok .... forgive me now, but this is getting confusing.  Where does
result come into this picture?  Were you expecting actionBean to be an
instance of a different class?  You aren't offering a lot to go on here.

Sorry for mixup. I've just thought that it is just about some option
in Tomcat configuration or something, and I haven't knew it. Like I
see... It may be not. :(

Here goes more background.

login.jsp (handled by LoginActionBean class) redirects after
submission login form to calculator.jsp. After submition form from
calculator.jsp  (what is handled by CalculatorActionBean class) it
returns to calculator.jsp and shows the result of mathematical
equation. Sources of calculator.jsp and it's class are placed below.

Problem shows when I'm submiting from LoginActionVean to
calculator.jsp. Like I wrote before, LoginActionBean doesn't have
result field because it doesn't need it. But JSP (in this case used by
two classes) expects result in:
46:        <c:if test="${!empty actionBean.result}">
47:            Result: ${actionBean.result}<br/>
line.

Here actionBean could be an instance of different class.

Sorry for so much source in thread, here it goes:




#########################
package com.some.packages.action;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.DontValidate;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.validation.LocalizableError;
import net.sourceforge.stripes.validation.Validate;
import net.sourceforge.stripes.validation.ValidationErrors;
import net.sourceforge.stripes.validation.ValidationMethod;

/**
* A very simple calculator action.
* @author Tim Fennell
*/

public class CalculatorActionBean implements ActionBean {

        private ActionBeanContext context;
        private String forwardSuccess = "/calculator.jsp";
        private String forwardFail = "/index.jsp";
        
        private Double result;
        @Validate(required=true, mask="^\\d*$") private double numberOne;
        @Validate(required=true, mask="^\\d*$") private double numberTwo;

        public CalculatorActionBean() {
        }
        
        /***** execution *****/
        
        /*
         * Handler method.
         * Handles addition functionality of web application form.
         */
        @DefaultHandler
        @DontValidate
        public Resolution init() {
                return new ForwardResolution(forwardSuccess);
        }

        /*
         * Handler method.
         * Handles addition functionality of web application form.
         */
        public Resolution addition() {
                result = getNumberOne() + getNumberTwo();
                return new ForwardResolution(forwardSuccess);
        }

        /***** getters and setters *****/
        
        public ActionBeanContext getContext() {
                return context;
        }

        public void setContext(ActionBeanContext context) {
                this.context = context;
        }

        public double getNumberOne() {
                return numberOne;
        }

        public void setNumberOne(double numberOne) {
                this.numberOne = numberOne;
        }

        public double getNumberTwo() {
                return numberTwo;
        }

        public void setNumberTwo(double numberTwo) {
                this.numberTwo = numberTwo;
        }

        public Double getResult() {
                return result;
        }

        public void setResult(Double result) {
                this.result = result;
        }

}
#########################




#########################
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld"%>
<%@ taglib prefix="display" uri="http://displaytag.sf.net"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"; %>
<fmt:setBundle basename="StripesResources"/>

<stripes:layout-render name="/pages/layout/default.jsp">

   <stripes:layout-component name="contents">

       <h3><fmt:message key="title" /> - <fmt:message
key="title.calculator"/></h3>

       <stripes:errors />

       <stripes:form action="/Calculator.action" focus="">

           <table>
               <tr>
                   <td>
                       <div>
                           <div style="width:150px;"><stripes:label
for="numberOne"/></div>
                           <div style="display:inline"><stripes:text
name="numberOne"/></div>
                       </div>
                       <div>
                           <div style="width:150px;"><stripes:label
for="numberTwo"/></div>
                           <div style="display:inline"><stripes:text
name="numberTwo"/></div>
                       </div>
                   </td>
                   <td valign="bottom">
                       <div>
                           <stripes:submit name="addition"/>
                           <stripes:submit name="subtraction"/>
                           <stripes:submit name="multiplication"/>
                           <stripes:submit name="division"/>
                       <div>
                   </td>
               </tr>
           </table>

       </stripes:form>

       <br/>

       <hr size="1" noshade color="#000" align="left"><br/>
       <c:if test="${!empty actionBean.result}">
           Result: ${actionBean.result}<br/>
       </c:if>
       <c:if test="${!empty sessionScope.user.userName}">
           Logged in as: ${sessionScope.user.firstName}
${sessionScope.user.lastName} (${sessionScope.user.userName})<br/>
       </c:if>

   </stripes:layout-component>

</stripes:layout-render>
#########################




--
Piotr Kiraga
K i r a g a d e s i g n
+48 693 104 834
http://www.kiragadesign.pl/

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to