[Zope] How to emulate browser back button

Rupert G. Goldie rupert@ekit-inc.com
Tue, 04 Apr 2000 10:18:28 +1000


Tino Wildenhain wrote:
> Hello,
> 
> Richard Moon wrote:
> > 
> > I feel there must be a way to emulate the browser 'back' button in Zope.
> > Can anyone tell me if this is possible please ?
> > 
> > The reason is that I have a form, with input fields like
> > 
> > input name="address1"
> >                 width=30 value="&dtml.missing-address1;">
> > 
> > Input from the form is validated in the dtml-method which receives the
> > input from the form. So if a particular field is invalid I can tell the
> > user to use their back button to return to the form. Using the
> > &dtml.missing- means that other data already entered is re-displayed to the
> > user. This is excellent stuff.

The structure that we use is to have the form post to itself and validate
the input.

ie. 
form/index_html looks like

<dtml-if update.x>
  <dtml-if "not all_digits(entry)">
    <dtml-call "REQUEST.set('errorMsg','Sorry, you must enter only digits')">
  <dtml-elif "entry < 10">
    <dtml-call "REQUEST.set('errorMsg','Sorry, the number is too small')">
  </dtml-if>

  <dtml-if errorMsg>
    <dtml-var submit_page>
  <dtml-else>
    do the work with the form data
    <dtml-var results_page>
  </dtml-if>
<dtml-else>
  <dtml-var submit_page>
</dtml-if>

form/submit page has the HTML form

<form method="post">
<dtml-if errorMsg>
  <FONT color=red><dtml-var errorMsg></Font>
</dtml-if>
Enter the data
<input type=password name="entry" size=8 maxlength=10>
<input type=image  name="update" src="images/continue" value="submit_pin" border="0">
</form>

--
Rupert G. Goldie, Senior Software Engineer        rgg@ekit-inc.com