File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Can EL access the errors object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Can EL access the errors object" Watch "Can EL access the errors object" New topic
Author

Can EL access the errors object

Chris Kitchens
Greenhorn

Joined: Jun 06, 2007
Posts: 2
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

Joined: Jan 10, 2002
Posts: 61201
    
  66

Since this question is regarding the non-standard Struts tags, it has been moved to the Struts forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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 ]

Merrill
Consultant, Sima Solutions
Chris Kitchens
Greenhorn

Joined: Jun 06, 2007
Posts: 2
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

Joined: Feb 15, 2005
Posts: 4864
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
 
subject: Can EL access the errors object