This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

ActionMessages causing me great distress

 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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???
 
    Bookmark Topic Watch Topic
  • New Topic