Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In Tapestry, a parameter is not a slot into which data is pushed: it is a connection between a field of the component (marked with the @Parameter annotation) and a property or resource of the component's container. In most simple examples, the component's container is the page, but since components can have themselves have templates, sometime often the container of a component is another component.

The connection between a component and a property (or resource) of its container is called a binding. The binding is two-way: the component can read the bound property by reading its parameter field. Likewise, a component that updates its parameter field will update the bound property.

...

The default binding prefix in most cases is "prop:", which is why it is usually omitted.

...

validate:

...

Bindings

Main Article: Forms and Validation

...

For example: validate:required,minLength=5 would presumably enforce that a field requires a value, with at least five characters.

...

translate:

...

Bindings

The "translate:" binding prefix is also related to input validator. It is the name of a configured Translator, responsible for converting between server-side and client-side representations of data (for instance, between client-side strings and server-side numeric values).

...

If your component should render informal parameters, just inject the ComponentResources for your component and invoke the renderInformalParameters() method.

...

asset: Bindings

Assets bindings are normally relative to the component class. This can be overridden by prefixing the path with "context:", in which case, the path is a context path from the root of the web application context.

...

Because accessing context assets is relatively common, a separate binding prefix for that purpose exists (described below).

context: Bindings

Context bindings are like asset bindings, but the path is always relative to the root of the web application context. This is intended for use inside templates, i.e.:

...

Parameters that are required must be bound. A runtime exception occurs if a component has unbound required parameters. Note: sometimes

Tip

Sometimes a parameter is marked

...

as required

...

, but may still be omitted if the underlying value is provided by some other means. This is the case, for example, with the Select component's value parameter, which may have its underlying value set by contributing a ValueEncoderSource. Be sure to read the component's parameter documentation carefully. Required simply enables checks that the parameter is bound, it does not mean that you must supply the binding in the template (or @Component annotation).

Optional Parameters

Parameters are optional unless they are marked as required.

...