Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can EL access the errors object

 
Chris Kitchens
Greenhorn
Posts: 2
  • 0
  • 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}
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • 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.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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 agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic