You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "ZACHCIAL,SLAWOMIR (HP-France,ex1)" <sl...@hp.com> on 2001/02/15 09:16:04 UTC

ActionErrors & logic:iterate

Hi,

Currently ActionErrors class has method "get" returning the iterator of all
the errors. Unfortunately, as far as I know you can't use this feature
directly with <logic:iterate> tag as it the method name is not
JavaBeans-like (getXXX).

The only way I found today to use ActionErrors with <logic:iterate> is:


<bean:define id="errors" 
             name="<%=org.apache.struts.action.Action.ERROR_KEY%>"
             type="org.apache.struts.action.ActionErrors"/>
<strong>The following error(s) occured:</strong>
<ul>
   <logic:iterate collection="<%=errors.get()%>" 
                  id="error" 		
                  type="org.apache.struts.action.ActionError">
   <li><bean:message key="<%=error.getKey()%>"/></li>
   </logic:iterate>
</ul>


Why not to change the method name from "get" to something like "getErrors"?
The the code above
would look like:


<strong>The following error(s) occured:</strong>
<ul>
   <logic:iterate name="<%=org.apache.struts.action.Action.ERROR_KEY%>"
                  property="errors" 
                  id="error" 		
                  type="org.apache.struts.action.ActionError">
   <li><bean:message key="<%=error.getKey()%>"/></li>
   </logic:iterate>
</ul>


Or maybe did I missed something?


Best Regards,
Slawek

************************************
SLAWEK ZACHCIAL
Hewlett-Packard France
Software Application Engineer
tel: +33 4 76 14 50 44
fax: +33 4 76 14 14 65
 TN: 779-5044 
************************************

Re: ActionErrors & logic:iterate

Posted by Craig Tataryn <Cr...@msdw.com>.
Yes, that method should probably be renamed to something like getIterator() or
something.

Just out of curiosity, what would happen if you set the property to "", would
the Introspector still just pre-pend "get" to a blank string and call the
"get()" method on the ActionErrors class?

Craig T.

"ZACHCIAL,SLAWOMIR (HP-France,ex1)" wrote:

> Hi,
>
> Currently ActionErrors class has method "get" returning the iterator of all
> the errors. Unfortunately, as far as I know you can't use this feature
> directly with <logic:iterate> tag as it the method name is not
> JavaBeans-like (getXXX).
>
> The only way I found today to use ActionErrors with <logic:iterate> is:
>
> <bean:define id="errors"
>              name="<%=org.apache.struts.action.Action.ERROR_KEY%>"
>              type="org.apache.struts.action.ActionErrors"/>
> <strong>The following error(s) occured:</strong>
> <ul>
>    <logic:iterate collection="<%=errors.get()%>"
>                   id="error"
>                   type="org.apache.struts.action.ActionError">
>    <li><bean:message key="<%=error.getKey()%>"/></li>
>    </logic:iterate>
> </ul>
>
> Why not to change the method name from "get" to something like "getErrors"?
> The the code above
> would look like:
>
> <strong>The following error(s) occured:</strong>
> <ul>
>    <logic:iterate name="<%=org.apache.struts.action.Action.ERROR_KEY%>"
>                   property="errors"
>                   id="error"
>                   type="org.apache.struts.action.ActionError">
>    <li><bean:message key="<%=error.getKey()%>"/></li>
>    </logic:iterate>
> </ul>
>
> Or maybe did I missed something?
>
> Best Regards,
> Slawek
>
> ************************************
> SLAWEK ZACHCIAL
> Hewlett-Packard France
> Software Application Engineer
> tel: +33 4 76 14 50 44
> fax: +33 4 76 14 14 65
>  TN: 779-5044
> ************************************