You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Doug Smith <DS...@Eviciti.com> on 2001/09/05 19:14:00 UTC

Action.ERROR_KEY problem

Hello,

I have a form in Struts which has a drop-down select list
where the options are populated by a bean that reads
the options from a database.  On the form JSP, I use:

<jsp:useBean id="formData"
             scope="request"
             class="com.eviciti.struts.test.GetQueryFormDataBean"
>
<jsp:setProperty name="formData"
                 property="datasourceName"
                 value="<%= application.getInitParameter
("mainDataSourceName") %>" />
</jsp:useBean>

Within this bean, I have defined an ActionError field that is
null unless some error occurs within the bean.  So, this block
of code will show the error:

<logic:present name="formData" property="strutsError" scope="request">
    <bean:define id="ERROR"
                 name="formData"
                 property="strutsErrors"
                 scope="request"
                 type="org.apache.struts.action.ActionErrors" />
    <%
    request.setAttribute(org.apache.struts.action.Action.ERROR_KEY, ERROR);
    %>
</logic:present>

With the above structure, the <html:errors /> tag happily sees any
errors.  However, I have to use a JSP scriptlet, as you can see, to
associate the ActionErrors object with the proper key name.  The
reason for this is that the actual Action.ERROR_KEY name is:
"org.apache.struts.action.ERROR", and that isn't a valid
Java variable name -- so I can't use it in the id parameter
of the <bean:define> tag.

So, I'm wondering ... why isn't Action.ERROR_KEY delimited by
underscores or something that would make it a legal var name?
Or, is there some other way to do this that I'm missing?

Thanks,

Doug