You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "R. Markham" <ma...@gmx.de> on 2005/09/17 20:39:47 UTC
Cannot find bean" error" in any scope / Error
I get following error if I push the submit button. I get following error
message
javax.servlet.ServletException: Cannot find bean error in any scope
I have following in my JSP File
<tr>
<td>Lastname</td>
<td><struts-html:text property="lastname"/></td>
<td>
<struts-html:messages id="error" property="lastname">
<struts-bean:write name="error"/>
</struts-html:messages>
</td>
</tr>
I want to produce an error message beside the input field if the input field
is empty. If I delete the line <struts-bean:write name="error"/> the program
works but there is no error message
Any idea?
Richard Markham
Re: Cannot find bean" error" in any scope / Error
Posted by Murray Collingwood <mu...@focus-computing.com.au>.
If the bean "error" doesn't exist in the request or the session then this is the error you
get.
1. either generate the "error" form bean and add it to the scope (any scope will do)
or
2. add logic code to test for the presence of the bean before you try using it.
<logic:present name="error">
...do the error here.
</logic:present>
Kind regards
mc
On 17 Sep 2005 at 16:23, Laurie Harper wrote:
> R. Markham wrote:
> > I get following error if I push the submit button. I get following error
> > message
> >
> > javax.servlet.ServletException: Cannot find bean error in any scope
> >
> > I have following in my JSP File
> >
> > <tr>
> > <td>Lastname</td>
> > <td><struts-html:text property="lastname"/></td>
> > <td>
> > <struts-html:messages id="error" property="lastname">
> > <struts-bean:write name="error"/>
> > </struts-html:messages>
> > </td>
> > </tr>
> >
> > I want to produce an error message beside the input field if the input field
> > is empty. If I delete the line <struts-bean:write name="error"/> the program
> > works but there is no error message
>
> Looks right to me... Is that the only place in your JSP that references
> a bean named 'error'? Is deleting that one line the only difference
> between getting the error and not?
>
> What version of Struts are you using? AFAIK, the body of the messages
> tag should only be evaluated if there are messages to display, and the
> scripting variable named by 'id' should always be defined. You could try
> explicitly telling bean:write to look in page scope, though that
> shouldn't be necessary.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.344 / Virus Database: 267.10.25/102 - Release Date: 14/09/2005
>
FOCUS Computing
Mob: 0415 24 26 24
murray@focus-computing.com.au
http://www.focus-computing.com.au
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.25/102 - Release Date: 14/09/2005
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Cannot find bean" error" in any scope / Error
Posted by Laurie Harper <la...@holoweb.net>.
R. Markham wrote:
> I get following error if I push the submit button. I get following error
> message
>
> javax.servlet.ServletException: Cannot find bean error in any scope
>
> I have following in my JSP File
>
> <tr>
> <td>Lastname</td>
> <td><struts-html:text property="lastname"/></td>
> <td>
> <struts-html:messages id="error" property="lastname">
> <struts-bean:write name="error"/>
> </struts-html:messages>
> </td>
> </tr>
>
> I want to produce an error message beside the input field if the input field
> is empty. If I delete the line <struts-bean:write name="error"/> the program
> works but there is no error message
Looks right to me... Is that the only place in your JSP that references
a bean named 'error'? Is deleting that one line the only difference
between getting the error and not?
What version of Struts are you using? AFAIK, the body of the messages
tag should only be evaluated if there are messages to display, and the
scripting variable named by 'id' should always be defined. You could try
explicitly telling bean:write to look in page scope, though that
shouldn't be necessary.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org