Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3188

Don't render action errors/messages when have null message

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.6
    • Fix Version/s: 2.1.8
    • Component/s: None
    • Labels:
      None
    • Environment:

      Freemarker

      Description

      Often I will end up passing an actionMessage to be rendered via an url such as:

      http://www.myco.com/myapp/doit.action?actionMessages=Display+This+Message

      This message is often set dynamically in the result for a redirect, for example:
      <result type="redirect">http://www.myco.com/myapp/doit.action?actionMessages=${actionMessages[0]}</result>

      But of course there may be no actionMessage actually available, and so the url ends up:
      http://www.myco.com/myapp/doit.action?actionMessages=

      In this case we end up with one null action message in the actionMessages list, and so when you use the actionmessage tag, you get a list with "null" as the message.

      I worked around this by just overriding the actionmessage.ftl and actionerror.ftl templates to check that if the list has content, the first element also "?has_content". This isn't terribly general though.

      I think a decent improvement would be to just check each action message with ?has_content (which checks for null and empty string) as you iterate and only render the "li" if it is true. Then just only output the starting "ul" when hit the first one, and the terminating ul if there was a message with content found.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              perfnorm Jasper Rosenberg
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: