You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Cruz, Edward J." <e....@radium.ncsc.mil> on 2003/04/11 18:27:20 UTC

tag understanding.

Hi All, 
	
	As I understand the <html:messages/> tag it is an iterator type tag
that iterates through a bean that is in request scope.  By default this bean
has a key of Action.ERROR_KEY which resolves to Globals.ERROR_KEY.  If you
use the message="true" attribute it no using the bean stored in the request
scope under Action.MESSAGE_KEY which resolves to Globals.MESSAGE_KEY.
Therefore, depending on the message attribute and the name attribute, which
allows you to specific any key name you would like, the <html:messages/>
will iterate on an appropriate request scope bean. 

	Then we have the required id attribute.  This attribute defines the
name of the page scope bean which will be created to hold the value of the
current index in the request scope bean the <html:messages/> tag is
iterating upon.  Then within the open and close <html:messages> tag one can
use the <bean:write/> tag with the name attribute set to the value specified
in the <html:messages/> id attribute to display the value at the current
index of the <html:messages/> tag's iteration.  

So,  by placing the following set of tags 

    <html:messages id="message" message="true">
	<bean:write name="message"/>
    </html:messages>

    This would display the values of the request scope bean with key
Action.MESSAGE_KEY. 

    <html:messages id="error"> 
	<bean:write name="error"/>
    </html:messages>
    
    This would display the values of the request scope bean with key
Action.ERROR_KEY.

    My question is how can these above tags throw a [Servlet Exception]
Cannot find bean error in any scope.

    I am using the BaseAction class default catchExceptions method.  I
traced it through and clearly see it saving the errors as   ERROR_KEY which
resolves to Globals.ERROR_KEY. 

    I have also created my own ActionErrors and stored it in the
Globals.ERROR_KEY using the saveErrors() method.  
   
    I have also tried to create ActionMessages and stored it in the
Globals.MESSAGE_KEY using the saveMessages() method.

    Yet I still receive the [Servlet Exception] Cannot find bean error (or
messages depending on which was created) in any scope.

    Please Help, 
Jamie