How to emulate browser back button
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. However, rather than telling the user to press the back button I want to put an anchor on the screen which says continue - something along the lines of <a href="<dtml-var HTTP_REFERER>">Continue</a> This works, in the sense that it returns to the form, but all the form variables are lost. I've checked the REQUEST variable and they are just not there any more - I guess because the form cannot tell it is being returned to. I just know I'm missing something obvious. Richard Moon richard@dcs.co.uk
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 ?
You can use <a href="javascript:history.go(-1)">Back</a>. But it won't work in browsers that don't support javascript. -- Itamar S.T. itamars@ibm.net
On Mon, 3 Apr 2000, Itamar Shtull-Trauring 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 ?
You can use <a href="javascript:history.go(-1)">Back</a>. But it won't work in browsers that don't support javascript.
You can do it without javascript, but you have to *do* it. HTTP is stateless, so the only way the REQUEST stuff can get forwarded is if you put it into the intermediate web page. That is, you have to make that continue button a form button, and put the current values of the variables in hidden data fields. Then your form has to have logic to recognize that it is being (re)called with values already set, and insert those values into the value fields of your form elements. If you go this route, instead of having a separate error page with a continue button, you might consider having the form be its own action, and have it redisplay with appropriate error messages and field highlights. This could potentialy provide a superior user experience... --RDM
----- Original Message ----- From: Richard Moon <richard@dcs.co.uk> To: <zope@zope.org> Sent: Monday, April 03, 2000 6:06 PM Subject: [Zope] How to emulate browser back button
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.
However, rather than telling the user to press the back button I want to put an anchor on the screen which says continue - something along the lines of
<a href="<dtml-var HTTP_REFERER>">Continue</a>
This works, in the sense that it returns to the form, but all the form variables are lost. I've checked the REQUEST variable and they are just not there any more - I guess because the form cannot tell it is being returned to.
I just know I'm missing something obvious.
I'm not so sure if I understood what did you ask... But maybe this will help you: <A HREF="whatever" onClick="history.back();return true" >Go Back</A> Marcel
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.
However, rather than telling the user to press the back button I want to put an anchor on the screen which says continue - something along the lines of
<a href="<dtml-var HTTP_REFERER>">Continue</a>
You could use: <dtml-if HTTP_REFERER> <form method="POST" action="<dtml-var HTTP_REFERER>"> <dtml-in "REQUEST.form.keys()"> <input type="hidden" name="<dtml-var sequence-item>" value="<dtml-var "_['sequence-item']">"> </dtml-in> <input type="submit" name="dummy" value="Continue"> </form> </dtml-if> And so look for your forms varibles in the input page. HTH Tino Wildenhain
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
Thanks for all the help with this. The javascript idea is a good quick fix so thanks for that, but it's obvious that, like many Zopish things, I need to re-think how I structure my forms. I'm impressed with this idea, though I don't yet fully understand it ! I'll work it out though ! Looking at this code I wonder if it is possible to make it into a ZClass or a Product or something so that we could re-use it and just substitute the variables. You would specify each variable, it's type (char, int etc), validation (either an external method or dtml), error messages and the ultimate destination for the input once valid. It's the kind of thing every self-respecting 4gl had in the 80's (I was there!). It's beyond me at the moment though. Richard
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
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Richard Moon richard@dcs.co.uk
Richard Moon wrote:
Looking at this code I wonder if it is possible to make it into a ZClass or a Product or something so that we could re-use it and just substitute the variables. You would specify each variable, it's type (char, int etc), validation (either an external method or dtml), error messages and the ultimate destination for the input once valid. It's the kind of thing every self-respecting 4gl had in the 80's (I was there!). It's beyond me at the moment though.
The thought has crossed my mind. We are starting to identify some common design patterns from the various features we have implemented and a simple form page turns up fairly often. -- Rupert G. Goldie, Senior Software Engineer rgg@ekorp.com
participants (6)
-
Itamar Shtull-Trauring -
Marcel Preda -
R. David Murray -
Richard Moon -
Rupert G. Goldie -
Tino Wildenhain