Forum OpenACS Q&A: How tcl, adp link and calling other proc's?

Hi,

Im trying to make a simple form to understand how it all integrates and fits together.

Ive currently done the following code. In the adp file I used the 'formtemplate' tag to make the template it is displays correctly. I dont however know how once i submit this information that could execute another procedure.

_____________________________________________________________

# Create form

form create compose
element create compose sender -datatype text
element create compose_email recipients -datatype text

# Set values

if { [form is_request compose_email] } {
element set_properties compose_email sender - value "a@b.com"
}

if { [form is_valid compose_email] } {

# What does this section do?
# When is it used?

}

____________________________________________________________

Questions:
1. See questions in the 'is_valid' section.

2. If i have a procedure called send_mail in another tcl file, how could i call that? Does that tcl file have to be in a certain place? Or does the procedure have to be within the same tcl file as above?

Thanks,
Ayman
Collapse
Posted by Bart Teeuwisse on
Ayman,

You'll find your answers to the questions of the 'is_valid' section in the ACS templating documentation. Read the Form API on your server in: /doc/acs-templating/api/form.html

The function send_mail can be called provided that it is defined in a tcl file that has been source. Tcl files in the tcl directory of packages get sourced at start up of your server so that would be a good place to put it. You can have the package manager (APM) watch tcl files in these directories so that the changes you make to these tcl file are automatically detected without having to restart the web server.

/Bart

Collapse
Posted by Andrew Zeon on
This is the same problem I have in trying to understand OACS... how everything links together, what calls what, how it calls each other, etc. I think it will be a good idea if in the future someone writes a document explaining how things fit together.
Collapse
4: APM watching files - how? (response to 1)
Posted by Ayman M on
Hi,

How do i enable this? I went to the package manager and then my package but i couldnt find the option. Any guide would help.

Thanks,
Ayman

Also, going back to my initial question - i read the form API but im still a little confused - what is required to make something valid - what is it checking for? And does this section get executed as the page is loading?

Thanks again.

Collapse
Posted by Roberto Mello on
I'm trying to have our documentation on this regard improved by this weekend. I know it's past the code freeze, but documentation is not code so I hope Janine won't came after me with a machette 😊