Tapestry
  1. Tapestry
  2. TAPESTRY-829

FormLinkRenderer throws NPE with DirectlLinks

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0
    • Fix Version/s: 4.1.1
    • Component/s: Contrib
    • Labels:
      None
    • Environment:
      tapestry 4.0 rc 3

      Description

      From DirectLink it gets the following prameterNames: component container page service session sp
      but link.getParameterValues("container") returns null;

      my workaround is to wrap the loop in a test, then it works again.
      if( values != null ){ }

      In addition to this deprecated methods are used.
      private String generateFormFunction(String formName, ILink link, String anchor)
      {
      String[] parameterNames = link.getParameterNames();

      StringBuffer buf = new StringBuffer();
      buf.append("function prepare" + formName + "() {\n");

      buf.append(" var html = \"\";\n");
      buf.append(" html += \"<div style='position: absolute'>\";\n");

      String url = link.getURL(anchor, false);
      buf.append(" html += \"<form name='" + formName + "' method='post' action='" + url + "'>\";\n");

      for (int i = 0; i < parameterNames.length; i++) {
      String parameter = parameterNames[i];
      String[] values = link.getParameterValues(parameter);
      if( values != null ){
      for (int j = 0; j < values.length; j++)

      { String value = values[j]; buf.append(" html += \"<input type='hidden' name='" + parameter + "' value='" + value + "'/>\";\n"); }


      }
      }
      buf.append(" html += \"<\" + \"/form>\";\n");
      buf.append(" html += \"<\" + \"/div>\";\n");
      buf.append(" document.write(html);\n");
      buf.append("}\n");

      buf.append("prepare" + formName + "();\n\n");

      return buf.toString();
      }

        Activity

        Hide
        Andreas Andreou added a comment -

        Thanks Ido !

        Show
        Andreas Andreou added a comment - Thanks Ido !

          People

          • Assignee:
            Andreas Andreou
            Reporter:
            Ido M. Tamir
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development