OK we updated the generated Javascript with the new version of the Javascript
function

function submitPopupLink(form, elementId, url)
{
  var windowName = 'RDQGraphPopup';
  var randomNumber = Math.floor(Math.random()*1000);
  windowName = windowName+randomNumber;
  aWindow = window.open(url, windowName, 'width=840, height=550,
scrollbars=yes,resizable=yes', false);
  aWindow.focus();
  var form = document.getElementById(form);
  form.target=windowName;
  tapestry.form.submit(form, elementId);
  form.target='';
}

this seems to allow the popup link to work but we're still getting the errors
in the back end.
They don't seem to have any ill effect but they are generated each time the
page serves.

For script generation we are using the version of the call passing this:

        getScript().execute(this, cycle, pageRenderSupport, symbols);

(If this is the call Jessie meant)

Any ideas as to what is causing the error? Even though it does not seem to be
causing any problems I've a feeling it's gonna bite us in the ass at some
point...

Here's PopupLinkSubmit.java if it's any help. As I mentioned before it's
mostly copied from the online example I cited before.

public abstract class PopupLinkSubmit extends CustomSubmit {

    /**
     * The name of an [EMAIL PROTECTED] 
org.apache.tapestry.IRequestCycle}attribute in
which
     * the current submit link is stored. LinkSubmits do not nest.
     */
    public static final String ATTRIBUTE_NAME =
"actualis.web.tapestry.PopupLinkSubmit";

    public static final String ATTRIBUTE_NAME_SCRIPT =
"actualis.web.tapestry.PopupLinkSubmitScript";

    /**
     * The name of an [EMAIL PROTECTED] 
org.apache.tapestry.IRequestCycle}attribute in
which
     * the link submit component that generates the javascript function is
stored.
     * The function is only required once per page (containing a form with a
     * non-disabled LinkSubmit)
     */
    public static final String ATTRIBUTE_FUNCTION_NAME =
"actualis.web.tapestry.PopupLinkSubmit_function";

    @InjectObject("engine-service:external")
    public abstract IEngineService getExternalService();

    @Parameter(required=false)
    public abstract String getStyleClass();
    @Parameter(defaultValue="900", required=false)
    public abstract String getWindowHeight();
    @Parameter(defaultValue="600", required=false)
    public abstract String getWindowWidth();

    /**
     * Checks the submit name ([EMAIL PROTECTED] 
FormConstants#SUBMIT_NAME_PARAMETER}) to
     * see if it matches this LinkSubmit's assigned element name.
     */
    @Override
    protected boolean isClicked(IRequestCycle cycle, String name) {
      String value = cycle.getParameter(FormConstants.SUBMIT_NAME_PARAMETER);

      return name.equals(value);
    }

    /**
     *
     * @param cycle
     * @return
     */
    public ILink getLink(IRequestCycle cycle) {
      Object[] pageParameters =
          DirectLink.constructServiceParameters(getPopupParameters());
      ExternalServiceParameter esp =
          new ExternalServiceParameter(
                  getPopupPage(),
                  pageParameters);

      return getExternalService().getLink(false, esp);
    }

    public abstract Object getPopupParameters();

    public abstract String getPopupPage();

    /**
     * @see
org.apache.tapestry.form.AbstractFormComponent#renderFormComponent(org.apache.tapestry.IMarkupWriter,
     *      org.apache.tapestry.IRequestCycle)
     */
    @Override
    @SuppressWarnings("unchecked")
    protected void renderFormComponent(IMarkupWriter writer, IRequestCycle
cycle) {
      boolean disabled = isDisabled();

      if (!disabled) {
        PageRenderSupport pageRenderSupport =
            TapestryUtils.getPageRenderSupport(cycle,this);

        if (cycle.getAttribute(ATTRIBUTE_NAME_SCRIPT) == null) {

          BodyBuilder builder = new BodyBuilder();

          builder.addln("");
          builder.addln("function {0}(form, elementId, url)",
"submitPopupLink");
          builder.begin();
          builder.addln("var windowName = 'RDQGraphPopup';");
          builder.addln("var randomNumber = Math.floor(Math.random()*1000);");
          builder.addln("windowName = windowName+randomNumber;");
          builder.addln("aWindow = window.open(url, windowName, "
                  + "'width="+getWindowWidth()+", height="+getWindowHeight()
                  + ", scrollbars=yes,resizable=yes'"
                  + ", false);");
          builder.addln("aWindow.focus();");
          builder.addln("var form = document.getElementById(form);");
          builder.addln("form.target=windowName;");
          builder.addln("tapestry.form.submit(form, elementId);");
          builder.addln("form.target='';");
          builder.end();

          pageRenderSupport.addBodyScript(
                  this,
                  builder.toString());
          cycle.setAttribute(ATTRIBUTE_NAME_SCRIPT, this);
        }

        IForm form = getForm();

        String slink = getLink(cycle).getURL(null, true);
        Map symbols = new HashMap();
        symbols.put("form", form);
        symbols.put("name", getName());
        symbols.put("popupLink", slink);
        symbols.put("class", getStyleClass());

        getScript().execute(this, cycle, pageRenderSupport, symbols);

        writer.begin("a");
        writer.attribute("href", (String) symbols.get("href"));
        writer.attribute("class", (String) symbols.get("class"));

      }

      renderBody(writer, cycle);

      if (!disabled) {
        writer.end();
      }
    }

    public abstract IScript getScript();

    /**
     * @see
org.apache.tapestry.AbstractComponent#prepareForRender(org.apache.tapestry.IRequestCycle)
     */
    @Override
    protected void prepareForRender(IRequestCycle cycle) {
        IComponent outer = (IComponent) cycle.getAttribute(ATTRIBUTE_NAME);

        if (outer != null) {
            throw new ApplicationRuntimeException(
                    "no outer component",
                    this,
                    getLocation(),
                    null);
        }

        cycle.setAttribute(ATTRIBUTE_NAME, this);
    }

    /**
     * @see
org.apache.tapestry.AbstractComponent#cleanupAfterRender(org.apache.tapestry.IRequestCycle)
     */
    @Override
    protected void cleanupAfterRender(IRequestCycle cycle) {
      cycle.removeAttribute(ATTRIBUTE_NAME);
    }

    /**
     * Links can not take focus, ever.
     */
    @Override
    protected boolean getCanTakeFocus() {
      return false;
    }

    /**
     * Returns true; the LinkSubmit's body should render during a rewind, even
if
     * the component is itself disabled.
     */
    protected boolean getRenderBodyOnRewind() {
      return true;
    }


Dom

---

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to