Karl Munroe wrote:
I am having some problems with a little bit of code I wrote that is of the following format :
1 <dtml-call SomeExpensiveFunction> 2 <dtml-in someListIHave> 3 <dtml-if "_['sequence-item'] == ''"> 4 <dtml-call "RESPONSE.redirect('page_to_see_error_message')"> 5 </dtml-if> 6 </dtml-in> 7 <dtml-call AddSomethingToMyDatabase> 8 <dtml-call "RESPONSE.redirect('page_to_see_results')">
The above code processes some data that I input from a form. I left a field blank and I would be redirected at line 4 to see the error message. Unfortunately I got something else. Instead of stopping at line 4 the above code redirects me at line 8 executing line 7 in the process.
# When I redirect from a dtml method, is such a redirect functionally equivalent to a return statement in C that causes processing to stop???
#I interpret that behaviour to mean that the the above code executes until the loop is finished and then continues to execute. The result is that I am redirected twice, first to see the error message and finally to see the results. If this is the case, is there a tag to stop looping and "return".
Thanks in advance Karl
A redirect does not stop the execution of the method. The redirect actual happens *after* the method completes. RESPONSE.redirect just adds the redirect header to the HTTP response, it does not affect the DTML execution in any way. To halt execution after a redirect, add a dtml-return as in: <dtml-call expr="RESPONSE.redirect('fooURL')"> <dtml-return expr="1"> The return _will_ halt execution of the DTML at that point. -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>