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

Can EL access the errors object

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to put my struts error message in the title attribute of an html:text tag. Since you can't embed the html:errors tag in a html:text tag, I was hoping to use el. My question is can you access the errors object directly with el? The closest I've came so far is this:

<code>
<logic:messagesPresent property="widgit">
<bean:define id="myWidgitError">
<html:errors property="widgit"/>
</bean:define>
</logic:messagesPresent>
</code>

Then, in my html:text tag I do this:
<code>
<html:text property="widgit" title="${myWidgitError}"/>
</code>

Is there any way I could do something like: ${errors.myWidgitError}
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this question is regarding the non-standard Struts tags, it has been moved to the Struts forum.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Chris Kitchens:
Is there any way I could do something like: ${errors.myWidgitError}


No. The logic for getting an error message for a specific property is more complicated than can be handled with an EL expression. Your original idea is probably best, although I'd probably use <html:messages> rather than <html:errors> and define the bean containing the error message inside the <html:messages> stanza. Example:


[ June 06, 2007: Message edited by: Merrill Higginson ]
[ June 06, 2007: Message edited by: Merrill Higginson ]
 
Chris Kitchens
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to dynamically build the bean defines so that I could have one for every field on the form that has an error?

This doesn't work, but hopefully it gives you an idea of what I'm trying to accomplish.



I see that I can't dynamically build the bean define's id so this may be a dead end.

Thanks in advance for your help.
[ June 06, 2007: Message edited by: Chris Kitchens ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I don't think that would work. You'd probably have to have one <html:messages> stanza for each field in order to capture the error message for that field.
 
"I know this defies the law of gravity... but I never studied law." -B. Bunny Defiant tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic