You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Altug B. Altintas" <al...@riskturk.com> on 2003/07/31 11:16:29 UTC

Cannot find bean error in any scope

Hi, 
 
My form extends ValidationForm, and of course i have got validator-rules
and validation.xml. 
But when i want to make a custom valition in validate() method ,  i took
"javax.servlet.jsp.JspException: Cannot find bean error in any scope " 
 

My jsp page includes the code below to show the errors: 
 
*************************************
<logic:messagesPresent> 
<UL>
 <html:messages id="error"> 
 <LI><bean:write name="error"/></LI>
 </html:messages> 
</UL> 
</logic:messagesPresent>
*************************************

	
overriding validate() method
 
************************************************************************
*
 public ActionErrors validate(ActionMapping mapping,
         javax.servlet.http.HttpServletRequest request) {
 
  ActionErrors errors  = null ;
  errors = super.validate(mapping,request);
  try {
 
   
   if (errors == null) {
    errors = new ActionErrors();
   }   
   
 
   Calendar c1 = dUtils.str2Calendar(startdate);
 
   Calendar c2 = dUtils.str2Calendar(enddate);
 
   // if enddate bigger then startdate then add error
   if ( !c1.before(c2) ) { // custom validation
    errors.add(ActionErrors.GLOBAL_ERROR ,new
ActionError("errors.dateerror","test");    
   }
  
    // print out the errors
   Iterator it = errors.get();
   while ( it.hasNext() ) {
    ActionError ae = (ActionError) it.next();
    System.out.println("Errors  : " + ae.getKey() + " " );
    int length = ae.getValues().length;
    Object[] o = ae.getValues();
    for (int i=0; i<length ; i++) {
     System.out.println("  : " + o[i] + " " ); 
    }
    System.out.println("************************************" );
   }
 
  } catch ( Exception ex ) {
   System.out.println("Ex: " + ex);
  } finally {
   if (errors.isEmpty()) {
    return null;
   }
   
   return (errors);
  }
 }
************************************************************************
*

Any idea ? 
 
Regards

RE: Cannot find bean error in any scope

Posted by "Altug B. Altintas" <al...@riskturk.com>.
Strange ! Now i have got no custom validation


************************************************************************
***
public ActionErrors validate(ActionMapping mapping,
javax.servlet.http.HttpServletRequest request) {

		ActionErrors errors  = null ;
		errors = super.validate(mapping,request);
		return errors;
}
************************************************************************
***

only call parent's validation method, but again it gives me

"javax.servlet.jsp.JspException: Cannot find bean error in any scope " 

Error occurs because of the code below, but why ? 

************************************************************************
***
<logic:messagesPresent> 
<UL>
 <html:messages id="error"> 
 <LI><bean:write name="error"/></LI>
 </html:messages> 
</UL> 
</logic:messagesPresent>
************************************************************************
***

if change above code like this

************************************************************************
***
<html:errors/>
************************************************************************
***

Everything works fine.. 







-----Original Message-----
From: Altug B. Altintas [mailto:altuga@riskturk.com] 
Sent: Thursday, July 31, 2003 12:16 PM
To: 'Struts Users Mailing List'
Subject: Cannot find bean error in any scope 


Hi, 
 
My form extends ValidationForm, and of course i have got validator-rules
and validation.xml. 
But when i want to make a custom valition in validate() method ,  i took
"javax.servlet.jsp.JspException: Cannot find bean error in any scope " 
 

My jsp page includes the code below to show the errors: 
 
*************************************
<logic:messagesPresent> 
<UL>
 <html:messages id="error"> 
 <LI><bean:write name="error"/></LI>
 </html:messages> 
</UL> 
</logic:messagesPresent>
*************************************

	
overriding validate() method
 
************************************************************************
*
 public ActionErrors validate(ActionMapping mapping,
         javax.servlet.http.HttpServletRequest request) {
 
  ActionErrors errors  = null ;
  errors = super.validate(mapping,request);
  try {
 
   
   if (errors == null) {
    errors = new ActionErrors();
   }   
   
 
   Calendar c1 = dUtils.str2Calendar(startdate);
 
   Calendar c2 = dUtils.str2Calendar(enddate);
 
   // if enddate bigger then startdate then add error
   if ( !c1.before(c2) ) { // custom validation
    errors.add(ActionErrors.GLOBAL_ERROR ,new
ActionError("errors.dateerror","test");    
   }
  
    // print out the errors
   Iterator it = errors.get();
   while ( it.hasNext() ) {
    ActionError ae = (ActionError) it.next();
    System.out.println("Errors  : " + ae.getKey() + " " );
    int length = ae.getValues().length;
    Object[] o = ae.getValues();
    for (int i=0; i<length ; i++) {
     System.out.println("  : " + o[i] + " " ); 
    }
    System.out.println("************************************" );
   }
 
  } catch ( Exception ex ) {
   System.out.println("Ex: " + ex);
  } finally {
   if (errors.isEmpty()) {
    return null;
   }
   
   return (errors);
  }
 }
************************************************************************
*

Any idea ? 
 
Regards


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org