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

AnchorHandler does not render onclick() correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.3.4.1
    • 2.3.12
    • None

    Description

      The sripting methods are ignored on the <a/> tag.

      It never calls the start on ScriptingEventsHandler so does not add the attributes.

      Have checked it with image href links, which is what I think was the reason it was done this way.

      public class AnchorHandler extends AbstractTagHandler implements TagGenerator {
          public void generate() throws IOException {
              //all rendering must happend at the end of the tag, so we can support nested params
      
      // Added start
      
          	Map<String, Object> params = context.getParameters();
      
              Attributes attrs = new Attributes();
      
              attrs.addIfExists("name", params.get("name"))
                      .addIfExists("id", params.get("id"))
                      .addIfExists("class", params.get("cssClass"))
                      .addIfExists("style", params.get("cssStyle"))
                      .addIfExists("href", params.get("href"), false)
                      .addIfExists("title", params.get("title"))
                      .addIfExists("tabindex", params.get("tabindex"));
              start("a", attrs);
      
      // added end
      
          }
      
          public static class CloseHandler extends AbstractTagHandler implements TagGenerator {
              public void generate() throws IOException {
                  Map<String, Object> params = context.getParameters();
      
      // Removed
                  /*Attributes attrs = new Attributes();
      
                  attrs.addIfExists("name", params.get("name"))
                          .addIfExists("id", params.get("id"))
                          .addIfExists("class", params.get("cssClass"))
                          .addIfExists("style", params.get("cssStyle"))
                          .addIfExists("href", params.get("href"), false)
                          .addIfExists("title", params.get("title"))
                          .addIfExists("tabindex", params.get("tabindex"));
                  start("a", attrs);*/
      // removed
      
                  String body = (String) params.get("body");
                  if (StringUtils.isNotEmpty(body))
                      characters(body, false);
                  end("a");
              }
          }
      

      Attachments

        1. patch.txt
          8 kB
          Greg Huber

        Issue Links

          Activity

            People

              lukaszlenart Lukasz Lenart
              ghuber Greg Huber
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: