# Nirogen 2.x Documentation

Getting Started | API | Elements | Actions | Validators | Handlers | Configuration Options | About

Nitrogen Restful Elements

## Table of Contents

- 1 Overview
- 2 How it works
- 3 Replaced and new elements
- 4 Supported elements
- 5 No support for validators
- 6 Example

## 1 Overview

Restful elements introduce the possibility to create forms that don't depend on AJAX/Javascript. This is sometimes useful, for example if you want to provide a fallback option when a client does not support javascript or sits behind a firewall that filters active content.

## 2 How it works

Restful requests work a little different compared to the rest of Nitrogen. They don't use the event mechanism. Instead you have to render the reply either on a different page or check if wf:q(restful_method) is set to "post" or "get" depending on the method of the form. Form elements that don't rely on javascript are useable in restful_form elements. The elements that are supported are described below.

Each control within a #restful_form{} element will submit its Nitrogen id as the name of the field, unless overridden by specifying an html_name on the restful elements.

## 3 Replaced and new elements

### New Elements

- restful_form

### Replaced elements

Some elements are replaced with restful_ counterparts:

- restful_submit and restful_reset instead of button
- restful_upload instead of upload

## 4 Supported elements

- Textbox
- Textarea
- Checkbox
- Dropdown
- Password Box
- Hidden Value
- Radio Button

## 5 No support for validators

Validators are not currently supported for restful_submit actions, so be sure extra sure to check your inputs.

## 6 Example

    case wf:q(restful_method) of
      "post" -> [
          % this is code is executed after the submit button was pressed

          #table{rows=[
              #tablerow{cells=[
                  #tablecell{text="text_input"},
                  #tablecell{text=wf:q(text_input)}
              ]}
           ]};
      _else -> [
          % this code is executed when restful_method is "get"
          % or undefined

          #restful_form{id=restful_form, method=post, body=[
             #table{rows=[
                  #tablerow{cells=[
                      #tablecell{text="text_input"},
                      #tablecell{body=[#textbox{id=text_input}]}
                 ]}
              ]},
              #restful_reset{},
              #restful_submit{}
           ]}
      ]
    end

Date: 2012-10-18 03:24:46 CDT

Author: Steffen Panning

Org version 7.8.02 with Emacs version 23

Validate XHTML 1.0

## Comments

Note:To specify code blocks, just use the generic code block syntax:

    <pre><code>your code here</code></pre>

comments powered by Disqus