betweenGo

Submitting an ATG Form Using a Text Link

by on Jul.20, 2007, under Form Handlers, JavaScript, Page Development

It has always bedeviled me how to submit an ATG form using a text link. I have asked many people about this but no one seems to know. Finally with the help of ATG support I figured it out.

Below is a simple example of how to do it. The trick is the hidden submit input which triggers ATG to call the handleSubmit method of the form handler.

<%@ taglib uri="/dspTaglib" prefix="dsp"%>

<dsp:page>

<script>
  function submit(form) {
    form.submit();
  }
</script>

<dsp:form action="<%=request.getRequestURI()%>" method="post" name="testForm">

  Foo: <dsp:input type="text" bean="TestFormHandler.foo"/>

  <p><a href="javascript:submit(document.testForm)">Submit</a>

  <dsp:input type="hidden" bean="TestFormHandler.submit" value="Submit"/>

</dsp:form>

</dsp:page>

You can also invoke the JavaScript like this:

  <p><a href="#" onclick="submit(document.testForm); return false;">Submit</a>


Share

Related posts:

  1. Internet Explorer form does not invoke ATG handler
  2. ATG forms do not work if action is an HTML page
  3. Submitting a form with a radio button
  4. How to Set an Array Property in an ATG Form
  5. Unobtrusive JavaScript

:,

2 Comments for this entry

  • Glenn

    Thanks for posting this! It was exactly what I needed to solve my problem. I’m an experienced Java developer, but very new to ATG, so your postings have been very helpful.

  • Ashley

    You can also submit the form via a text link with a simple dsp:a tag by specifying a bean and any parameters.

    Example:

    <dsp:a bean="SomeBean.method" value="" href="#">
    Link Text
    <dsp:param name="parameterName" param="element.value" />
    </dsp:a>

    This will then call your SomeBean’s handleMethod and any parameters that you passed, such as parameterName, will be available via request.getParameter(“parameterName”).

1 Trackback or Pingback for this entry

Leave a Reply

 

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!