Hi, i'm new to Stripes and I've been having problems using ForwardResolution
when I want to navigate to another page in my aplication.

The first page is index.jsp It uses a simple Bean (OsebaActionBean) that
checks if the form is valid. This happens when user clicks the submit
button.
If the form is not valid it sets errorMessageXX and stays on the same page.
Otherwise it navigates to another page that is a Calculator developed in
Stripes.

The problems occur when it navigates to calculator. It shows the Calculator
but when I click a button it displays an error message, that basicly says
that it can't find errorMessageXX in CalculatorActionBean
on index.jsp (but it is showing me the calculator that is in calculator.jsp)
I'm confused because of this strange mix (wrong page using the wrong bean)

I'm using RedirectResolution. If i try to use ForwardResolution it doesn't even 
show 
the calculator, instead it says that it cant find result in the 
calc.PersonActionBean.
This also makes no sense because Calculator should use calc.CalculatorActionBean
where result is defined.




Can anybody help ? I will put the error and the code i think is relevant
below 


----------ERROR MESSSAGE WITH REDIRECT RESOLUTION
-------------------------------------------------------------------------



org.apache.jasper.JasperException: An exception occurred processing JSP page
/index.jsp at line 49

46:         </tr>
47:         <tr>
48:             <td>Result:</td>
49:             <td>${actionBean.errorMessageXX}</td>
50:         </tr>
51:     </table>
52: 

root cause 

javax.el.PropertyNotFoundException: Property 'errorMessageXX' not found on
type calc.CalculatorActionBean
    javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:193)
    javax.el.BeanELResolver.property(BeanELResolver.java:267)
    javax.el.BeanELResolver.getValue(BeanELResolver.java:60)
    javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53

----------------------------------------------------------------------------------------------------
----ERROR MESSAGE WITH FORWARD RESOLUTION--------------------------------------


org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: Property 
'result' not found on type calc.PersonActionBean
        
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:535)
        
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:429)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        
net.sourceforge.stripes.action.ForwardResolution.execute(ForwardResolution.java:110)
        
net.sourceforge.stripes.controller.DispatcherHelper$7.intercept(DispatcherHelper.java:483)
        
net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158)
        
net.sourceforge.stripes.controller.HttpCacheInterceptor.intercept(HttpCacheInterceptor.java:99)
        
net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
        
net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
        
net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
        
net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74)
        
net.sourceforge.stripes.controller.DispatcherHelper.executeResolution(DispatcherHelper.java:477)
        
net.sourceforge.stripes.controller.DispatcherServlet.executeResolution(DispatcherServlet.java:286)
        
net.sourceforge.stripes.controller.DispatcherServlet.service(DispatcherServlet.java:170)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        
net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:247)
        
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

root cause 
javax.el.PropertyNotFoundException: Property 'result' not found on type 
calc.PersonActionBean


------------------------------------------------------------------------------------------------------
-----index.jsp--------------------------------------------------------------------------------------

<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="stripes"
    uri="http://stripes.sourceforge.net/stripes.tld"%>
<%@ taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>

<%
    String contextPath = request.getContextPath();
    String jsPath = (String) application.getInitParameter("javascript");
    String cssPath = (String) application.getInitParameter("css");
%>

<html>
<head>
<title>Stripes Calculator welcome page</title>
<link rel="stylesheet" href="<%= contextPath + cssPath %>calculator.css"
    type="text/css" />
<script src="<%= contextPath + jsPath %>calculator.js"></script>
</head>
<body>
<h1 class="header">Stripes Calculator</h1>




<stripes:form name="personForm" action="/calc/Person.action" focus="">
    <stripes:errors />

    <table>
        <tr>
            <td>Ime in primek </td>
            <td><stripes:text name="nameAndSurname"/></td>
        </tr>    
        <tr>
            <td>Starost</td>
            <td><stripes:text name="age"/></td>
        </tr>
        <tr>
            <td>Ali je matematični izraz pravilen: 1 + 1 = 2 ? (DA/NE)</td>
            <td><stripes:text name="mathExpresionValid"/></td>
        </tr>
        <tr>
            <td colspan="2">
                <stripes:submit name="submit" value="Submit"/>                  
  
            </td>
        </tr>
        <tr>
            <td>Result:</td>
            <td>${actionBean.errorMessageXX}</td>
        </tr>
    </table>


</stripes:form>
</body>
</html>

------------------------------------------------------------------------------------------------------
---PersonActionBean----------------------------------------------------------------------------------
package calc;

import java.io.StringReader;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.HandlesEvent;
import net.sourceforge.stripes.action.RedirectResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.UrlBinding;

import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
import org.drools.compiler.PackageBuilder;
import org.drools.decisiontable.InputType;
import org.drools.decisiontable.SpreadsheetCompiler;
import org.drools.rule.Package;

@UrlBinding("/calc/Person.action")
public class PersonActionBean implements ActionBean {
  private ActionBeanContext context;
  private int age;
  private String  mathExpresionValid;
  private String nameAndSurname;
  
  private boolean personPassed;
  private String errorMessageXX;

  public String getErrorMessageXX()
  {
    return errorMessageXX;
  }


  public void setErrorMessageXX(String errorMessage)
  {
    this.errorMessageXX = errorMessage;
  }

  public int getAge() 
  {
    return age;
  }

  public void setAge(int age) 
  {
    this.age = age;
  }


  public String getMathExpresionValid() 
  {
    return mathExpresionValid;
  }


  public void setMathExpresionValid(String mathExpresionValid)
  {
    this.mathExpresionValid = mathExpresionValid;
  }


  public String getNameAndSurname() 
  {
    return nameAndSurname;
  }


  public void setNameAndSurname(String nameAndSurname) 
  {
    this.nameAndSurname = nameAndSurname;
  }


  public boolean isPersonPassed() 
  {
    return personPassed;
  }


  public void setPersonPassed(boolean personPassed) 
  {
    this.personPassed = personPassed;
  }
  
  
  public ActionBeanContext getContext() 
  {
    return context;
  }

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

  
  @HandlesEvent("submit")
  //public ForwardResolution submit() {
  public Resolution submit(){
    boolean isFormValid = this.checkTheForm();
    if (isFormValid)
    {
      return new RedirectResolution("/jsp/calculator.jsp");
    }
    else
    {
      this.errorMessageXX = "Obstajajo napake pri validaciji forme";
      return new ForwardResolution("/index.jsp");
      
    }
  }  
  
  private boolean checkTheForm()
  {
    try
    {
    RuleBase ruleBase = readDecisionTable();
    WorkingMemory workingMemory = ruleBase.newStatefulSession(); 
    workingMemory.insert(this);
    workingMemory.fireAllRules();
    } 
    catch (Throwable t) {
      t.printStackTrace();
      return false;
    }  
    return this.personPassed;
  }
  
  private static RuleBase readDecisionTable() throws Exception {
    //read in the source
    final SpreadsheetCompiler converter = new SpreadsheetCompiler();
    //final String drl = converter.compile( "/SampleMiha2.xls",
InputType.XLS );
    final String drl = converter.compile( "/SampleMiha2.xls", InputType.XLS
);
    PackageBuilder builder = new PackageBuilder();
    builder.addPackageFromDrl( new StringReader( drl ) );
    Package pkg = builder.getPackage();
    RuleBase ruleBase = RuleBaseFactory.newRuleBase();
    ruleBase.addPackage( pkg );
    return ruleBase;
} 

  
}
------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------calculator.jsp--------------------------------------------------------------------------------------------------------------------

<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="stripes"
    uri="http://stripes.sourceforge.net/stripes.tld"%>
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>

<%
    String contextPath = request.getContextPath();
    String jsPath = (String) application.getInitParameter("javascript");
    String cssPath = (String) application.getInitParameter("css");
%>

<html>
<head>
<title>Stripes Calculator</title>
<link rel="stylesheet" href="<%= contextPath + cssPath %>calculator.css"
    type="text/css" />
<script src="<%= contextPath + jsPath %>calculator.js"></script>
</head>
<body
    onload="setNum1( '${actionBean.result}' , '${actionBean.numberOne}' )">
<h1 class="header">Stripes Calculator</h1>
<stripes:form name="calcForm" action="/calc/Calculator.action"  focus="">
    <stripes:errors />
    
    
    <table class="tableB">
        <tr>
            <th colspan="4" scope="col"><span class="inputText"> <stripes:text
                class="inputBox" id="numberOne" name="numberOne"
                onkeypress="return onlyNumbers(event)" /> </span></th>
        </tr>
        <tr class="rows">
            <td align="center"><input name="one" type="button"
                class="calcButton"
                onclick="beforeClick(true);toScreen(this.form.name,this.name)"
                value="1" /></td>
            <td align="center"><input name="two" type="button"
                class="calcButton"
                onclick="beforeClick(true);toScreen(this.form.name,this.name) "
                value="2" /></td>
            <td align="center"><input name="three" type="button"
                class="calcButton"
                onclick="beforeClick(true);toScreen(this.form.name,this.name)"
                value="3" /></td>
            <td align="center"><stripes:submit name="plus"
                class="calcButton" value="+" /></td>
        </tr>
        <tr class="rows">
            <td align="center"><input name="four" type="button"
                class="calcButton"
                onclick="beforeClick(true);toScreen(this.form.name,this.name)"
                value="4" /></td>
            <td align="center"><input name="five" type="button"
                class="calcButton"
                onclick="beforeClick(true);toScreen(this.form.name,this.name)"
                value="5" /></td>
            <td align="center"><input name="six" type="button"
                class="calcButton"
                onclick="beforeClick(true);toScreen(this.form.name,this.name)"
                value="6" /></td>
            <td align="center"><stripes:submit name="minus"
                class="calcButton" value="-" /></td>
        </tr>
        <tr class="rows">
            <td align="center"><input name="seven" type="button"
                class="calcButton"
                onclick="beforeClick(true);toScreen(this.form.name,this.name)"
                value="7" /></td>
            <td align="center"><input name="eight" type="button"
                class="calcButton"
                onclick="beforeClick(true);toScreen(this.form.name,this.name)"
                value="8" /></td>
            <td align="center"><input name="nine" type="button"
                class="calcButton"
                onclick="beforeClick(true);toScreen(this.form.name,this.name)"
                value="9" /></td>
            <td align="center"><stripes:submit name="divide"
                class="calcButton" value="/" /></td>
        </tr>
        <tr class="rows">
            <td align="center"><input name="zero" type="button"
                class="calcButton"
                onclick="beforeClick(true);toScreen(this.form.name,this.name)"
                value="0" /></td>
            <td align="center"><input name="point" type="button"
                class="calcButton"
                onclick="return 
checker1(this.form.name,this.name);beforeClick(true)"
                value="." /></td>
            <td align="center"><input name="oposite" type="button"
                class="calcButton"
                onclick="return 
checker2(this.form.name,this.name);beforeClick(true)"
                value="+-" /></td>
            <td align="center"><stripes:submit name="mul" class="calcButton"
                value="*" /></td>
        </tr>
        <tr class="rows">
            <td align="center"><input name="clear" type="button"
                class="calcButton" onclick="setNull()" value="C" /></td>
            <td align="center"><stripes:submit class="calcButtonce"
                name="ce" value="CE" /></td>
            <td colspan="4"><stripes:submit class="calcButtonEqu" name="equ"
                value="=" /></td>
        </tr>
    </table>
</stripes:form>
</body>
</html>


      
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to