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". The second will be set with element, 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?