apache > cocoon

- Home

# RequestParameter-Selector in Cocoon

## RequestParameterSelector

NAME | request-parameter
WHAT | The `RequestParameterSelector` component is used to select appropriate sitemap processing depending on a request parameter value.
TYPE | Selector, Sitemap Component
BLOCK | Core
CLASS | org.apache.cocoon.selection.RequestParameterSelector
SINCE | Cocoon 2.0
CACHEABLE | not applicable

## Description

The `RequestParameterSelector` tests the value of request parameter against the test attribute of the selector's when clause.

## Usage

The `RequestParameterSelector` allows to control the sitemap processing depending on a request parameter.

### Sitemap pipeline examples

The snippet below uses a `RequestParameterSelector` named `request-parameter`. It tests the value of request parameter named `command` against `list`, `create`; finally it has a `otherwise` clause.

    <map:select type="request-parameter">
      <map:parameter name="parameter-name" value="command"/>
      <map:when test="list">
      ....
      </map:when>
      <map:when test="create">
      ...
      </map:when>
      ...
      <map:otherwise>
      ...
      </map:otherwise>
    </map:select>

### Sitemap component configuration example

The snippet below declares a `RequestParameterSelector` defining to use the request parameter `command`.

    <map:selectors...
      <map:selector name="request-parameter"
        src="org.apache.cocoon.selection.RequestParameterSelector"
        logger="sitemap.selector.requestparameter">

        <parameter-name>command</parameter-name>
      </map:selectors>
    ...

### Configuration

The configuration section of `RequestParameterSelector` specifies the default name of the request parameter, used for testing.

### Setup

Setting up a `RequestParameterSelector` includes

- Defining an optional sitemap parameter named `request-name`, it overrides the parameter-name setting in the configuration section.
- choosing the `<map:when>` test expressions, and a optional `<map:otherwise>` clause.

The test attribute of the `<map:when>` clause shall match the value of the request parameter. If no test value matches, or the request parameter is not defined at all, the `<map:otherwise` clause is selected.

### Effect on Object Model and Sitemap Parameters

The `RequestParameterSelector` has no side effects on the object model, or any sitemap parameters.

## Bugs/Caveats

## History

28-12-02: initial creation

## See also

A general documentation about selectors is available at Matchers and Selectors.

Errors and Improvements? If you see any errors or potential improvements in this document please help us: View, Edit or comment on the latest development version (registration required).