Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamically Setting and Displaying Messages

 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Junilu Lacar
Bartender
Pie
Posts: 7465
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you try using a JSP expression?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic