• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ActionMessages causing me great distress

 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all-

I'm trying to distinguish between ActionErrors and ActionMessages but it's not working:
The problem is that when I have an error, it's being displayed twice,
as both an error AND a message
but my messages are not being displayed at all.

(my pages use <html:errors/> and
<logic:messagesPresent>
<html:messages id="message" property="<%=ActionMessages.GLOBAL_MESSAGE%>">
<li><bean:write name="message"/></li>
</html:messages>
</logic:messagesPresent>

Errors are created and saved in ActionErrors
Messages are created and saved in ActionMessages

thanks!
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What version of Struts are you using?

Here is what I do:

I use ActionMessages for errors and messages, I just store in different keys
errors are stored org.apache.struts.Globals.ERROR_KEY and messages are stored in org.apache.struts.Globals.MESSAGE_KEY

<html:messages id="msg" message="true">
<li class="message"><bean:write name="msg"/></li>
</html:messages>
<html:messages id="err" message="false">
<li class="error"><bean:write name="err"/></li>
</html:messages>
[ August 10, 2005: Message edited by: Kerry Wilson ]
 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Kerry-
Turns out the problem is addressability to the MessageResources object:

Even though I was including my own MessageResources, in trace I see the code is using another one (I'm using Struts 1.2)...weird - haven't figured it out yet (but I see embedded property files in the struts.jar)- What I did was use one of the canned message types (message.simple)
and presto - I now get a message - might be a bug (but at least it works for now)..

thanks for the reply
Max
 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should set your resource to not return null. So you will know when one is missing. You get a funky message like:

???RESOURCE_NAME???
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic