Thanks for that Jerry. I've had a look but unfortunately its not quite what
I'm after as I need to redirect the browser to the adp page. Perhaps if I
explain the problem a bit better it might help.

I have a complex form on an ADP page which POSTS to a TCL proc to validate
the form data. If the data fails validation I want to return to the ADP
page, show an error message and repopulate the form with the users original
data and await his correction. Perhaps an example might help...


The ADP Form Page (form.adp)
...
...
set FormData [ns_conn form $conn]
set ValError [ns_set get $FormData valerr]

if {$ValError != {} } {
         # Show the error...
         ns_puts "<B>Error - $ValError</B><br>"

         set OrderRef [ns_set get $FormData orderref]
         set Notes [ns_set get $FormData notes]
} else {
         set OrderRef {}
         set Notes {}
}


ns_puts "
<FORM  ACTION=\"validate.tcl\" METHOD=\"POST\">
         Order Ref <INPUT TYPE=text NAME=\"orderef\" SIZE=10 MAXLENGTH=15
VALUE=\"$OrderRef\">
         Notes <TEXTAREA  NAME=\"notes\"  ROWS=10  COLS=60 >$Notes</TEXTAREA>
         <INPUT TYPE=submit NAME=action VALUE=\"Submit\">
</FORM>"
...
...


The TCL Proc (validate.tcl)
...
...
set FormData [ns_conn form $conn]
set OrderRef [string trim [ns_set get $FormData orderref]]
set Notes [string trim [ns_set get $FormData notes]]

set RetError {}

if {$OrderRef == {} } {
         set RetError "The order reference cannot be blank"
}

if {$RetError != {} } {
         # Error so return to the edit page...
         set RetVal "&valerr=$RetError"

         # Return all the form values...
         set Size [expr [ns_set size $FormData] - 1]
         for {set I 0} {$I < $Size} {incr I} {
                 append RetVal "&[ns_set key $FormData $I]=[ns_set value
$FormData $I]"
         }

         ns_returnredirect "form.adp?$RetVal"
         return
}
...
...
The problem here is that the ns_returnredirect tries to use a GET method to
return the value of the notes textarea which isn't very reliable. I would
like to replace the ns_returnredirect in the tcl proc with a post to the
adp page. If anyone has a different approach to this problem I would
appreciate the input.

The crass options are to display the error with a message telling the user
to hit the Back button or to show the form page with the error but present
a new blank form. Another option is to store the values on the server
somewhere and have the adp page retreive them (abit like a jsp session).

Thanks in hope.

         Steve

p.s I'm using  AOLServer 3.2 and  Tcl 8.x

At 28/04/01 03:30, you wrote:
>Steve Manning writes:
>
>>Is it possible to create a POST method directly from a
>>TCL procedure. I need to return data to an ADP page to
>>repopulate a form.
>
>I think util_httppost might help.  You can get that from OpenACS at
>sourceforge:
>http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/acs-pg/acs-pg/tcl/00-ad-utili
>ties.tcl
>
>Jerry

Reply via email to