You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bOOyah <bo...@nowhere.org> on 2004/04/22 02:31:31 UTC

ActionErrors in my JSP: how can I rewrite this RT snippet as EL?

Hi

I'm displaying validate() ActionErrors in my JSP using the RT 
html:errors tag.  But I can't seem to be able to successfully rewrite my 
snippet of Struts RT in EL.

This works:

   <%@ page import="org.apache.struts.Globals"%>
   <%@ page import="org.apache.struts.action.ActionMessages"%>
   ...
   <logic-rt:present name="<%=Globals.ERROR_KEY%>">
     <html-rt:errors property="<%=ActionMessages.GLOBAL_MESSAGE%>"/>
   </logic-rt:present>


But this doesn't work (using the logic & html EL taglibs):

   <%@ page import="org.apache.struts.Globals"%>
   <%@ page import="org.apache.struts.action.ActionMessages"%>
   ...
   <logic:present name="org.apache.struts.Globals.ERROR_KEY">
     <html:errors
property="org.apache.struts.action.ActionMessages.GLOBAL_MESSAGE"/>
   </logic:present>



Can anyone help?

Thanks
-- 
bOOyah


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


Re: ActionErrors in my JSP: how can I rewrite this RT snippet as EL?

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
Ha, ha - you have to stand firm mate ;-) - having said that if my wife says
"down tools" I do too - PDQ!

The ActionMessages class and <html:messages> tag are new versions which it
seems are there to replace ActionErrors and <html:errors> so I guess they
are the future. So far I haven't got round to moving over to them yet but
yes, essentially it does the same thing but in a slightly different way.
>From what I understand the <html:messages> tag differs in the following
ways:

* You specify an "id" attribute in <html:messages> which specifies a page
scope bean in which the tag will store the current message for each
iteration - I believe you then have to use something to write out the
message - like <bean:write>

* Using the message="true" will display messages stored under the
Globals.MESSAGE_KEY constant (rather than the default Globals.ERROR_KEY ) -
means you can use it for other messages as well as errors.

* <html:errors> uses the "errors.footer" and "errors.header" keys to get the
header/footer from the application resources - <html:messages> you can
specify these keys using "header" and "footer" attributes on the tag - means
you can have different header/footer for different pages.


So to do you're example I believe you would have to do the following:

     <logic:messagesPresent>
         <html:messages id="errorMsg" header="errors.header"
footer="errors.footer"

property="org.apache.struts.action.GLOBAL_MESSAGE">
             <ul><bean:write name="errorMsg"/></ul>
       </html:messages>
     </logic:messagesPresent>

rather than

     <logic:messagesPresent>
        <html:errors  property="org.apache.struts.action.GLOBAL_MESSAGE"/>
     </logic:messagesPresent>


As I said, I haven't tried them out yet - maybe someone who uses them can
confirm whether this is correct or not.

Niall

----- Original Message ----- 
From: "bOOyah" <bo...@nowhere.org>
To: <us...@struts.apache.org>
Sent: Friday, April 23, 2004 12:49 PM
Subject: Re: ActionErrors in my JSP: how can I rewrite this RT snippet as
EL?


> Niall Pemberton wrote:
>
> > It should be
> >
> >     <logic:present name="org.apache.struts.action.ERROR">
> >       <html:errors property="org.apache.struts.action.GLOBAL_MESSAGE"/>
> >     </logic:present>
> >
> > .. or even
> >
> >     <logic:messagesPresent>
> >       <html:errors  property="org.apache.struts.action.GLOBAL_MESSAGE"/>
> >     </logic:messagesPresent>
>
> Sorry for the delay in replying Niall...my wife MADE ME down tools for a
> day.
>
> Yes, indeed both your suggestions work perfectly.  I'm using the 2nd
> one.  Am I right then in guessing that
>
>    <logic:messagesPresent>
>      <html:messages property="org.apache.struts.action.GLOBAL_MESSAGE"/>
>    </logic:messagesPresent>
>
> would display all messages (errors or otherwise)?  Is it now that simple?
>
> What threw me originally is that 'org.apache.struts.action.ERROR' no
> longer exists in the online Struts javadocs.  So I got embroiled in
> following the path of deprecation, and I couldn't get the current
> recommendations to work :-(
>
> Thanks a mill for your help.
>
> -- 
> bOOyah
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>



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


Re: ActionErrors in my JSP: how can I rewrite this RT snippet as EL?

Posted by bOOyah <bo...@nowhere.org>.
Niall Pemberton wrote:

> It should be 
> 
>     <logic:present name="org.apache.struts.action.ERROR">
>       <html:errors property="org.apache.struts.action.GLOBAL_MESSAGE"/>
>     </logic:present>
> 
> .. or even
> 
>     <logic:messagesPresent>
>       <html:errors  property="org.apache.struts.action.GLOBAL_MESSAGE"/>
>     </logic:messagesPresent>

Sorry for the delay in replying Niall...my wife MADE ME down tools for a 
day.

Yes, indeed both your suggestions work perfectly.  I'm using the 2nd 
one.  Am I right then in guessing that

   <logic:messagesPresent>
     <html:messages property="org.apache.struts.action.GLOBAL_MESSAGE"/>
   </logic:messagesPresent>

would display all messages (errors or otherwise)?  Is it now that simple?

What threw me originally is that 'org.apache.struts.action.ERROR' no 
longer exists in the online Struts javadocs.  So I got embroiled in 
following the path of deprecation, and I couldn't get the current 
recommendations to work :-(

Thanks a mill for your help.

-- 
bOOyah


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


Re: ActionErrors in my JSP: how can I rewrite this RT snippet as EL?

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
It should be 

    <logic:present name="org.apache.struts.action.ERROR">
      <html:errors property="org.apache.struts.action.GLOBAL_MESSAGE"/>
    </logic:present>

.. or even

    <logic:messagesPresent>
      <html:errors  property="org.apache.struts.action.GLOBAL_MESSAGE"/>
    </logic:messagesPresent>


----- Original Message ----- 
From: "bOOyah" <bo...@nowhere.org>
To: <us...@struts.apache.org>
Sent: Thursday, April 22, 2004 1:31 AM
Subject: ActionErrors in my JSP: how can I rewrite this RT snippet as EL?


> Hi
> 
> I'm displaying validate() ActionErrors in my JSP using the RT 
> html:errors tag.  But I can't seem to be able to successfully rewrite my 
> snippet of Struts RT in EL.
> 
> This works:
> 
>    <%@ page import="org.apache.struts.Globals"%>
>    <%@ page import="org.apache.struts.action.ActionMessages"%>
>    ...
>    <logic-rt:present name="<%=Globals.ERROR_KEY%>">
>      <html-rt:errors property="<%=ActionMessages.GLOBAL_MESSAGE%>"/>
>    </logic-rt:present>
> 
> 
> But this doesn't work (using the logic & html EL taglibs):
> 
>    <%@ page import="org.apache.struts.Globals"%>
>    <%@ page import="org.apache.struts.action.ActionMessages"%>
>    ...
>    <logic:present name="org.apache.struts.Globals.ERROR_KEY">
>      <html:errors
> property="org.apache.struts.action.ActionMessages.GLOBAL_MESSAGE"/>
>    </logic:present>
> 
> 
> 
> Can anyone help?
> 
> Thanks
> -- 
> bOOyah
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 


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