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 Dynamically Setting and Displaying Messages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dynamically Setting and Displaying Messages" Watch "Dynamically Setting and Displaying Messages" New topic
Author

Dynamically Setting and Displaying Messages

Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Hey folks,

I've run into a bit of a snag while trying to display messages to my users. On one page of my web application, I'm using a logic:iterate tag to iterate over a collection of objects and display the data in those objects to the user. This is working fine.

What I want to do is validate the user's input into this list of elements and, if there's a problem, display an error message back to the user near the element in question (as opposed to at the top of the page).

My validation procedure simply loops through all of the elements in the collection and checks each one for validity. I can use a simple counter to keep track of which element I'm on. So, for example, I have a line of code that looks similar to this (messages is of type ActionMessages):



So, for the first element in the collection, the ActionMessage should be set with the String "element[0]". The second will be set with element[1], and so on. This appears to be functioning properly - I've run my debugger through this and it seems correct.

Then, in my JSP page, I have a snippet that looks like this:



This should, in theory display the message for the first element in the collection for every element in the collection, which is obviously not what I'm after. Is there a way to set the messages.property attribute to be a real-time expression? If so, how do I do that? I want it to look something like this:



That, however, is not valid. Anyone know how to accomplish what I'm after?

Thanks,
Corey


SCJP Tipline, etc.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4699
    
    7

did you try using a JSP expression?



Junilu - [How to Ask Questions] [How to Answer Questions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamically Setting and Displaying Messages