Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixed ../apidocs/ links. (More broken links there, though)

...

Parameters are defined by placing a Parameter annotation onto a private field.

...

Prefix

Description

asset

The relative path to an asset file (which must exist).

block

The id of a block within the template.

component

The id of another component within the same template.

context

Context asset: path from context root.

literal

A literal string.

nullfieldstrategy

Used to locate a pre-defined NullFieldStrategy

message

Retrieves a value from the component's message catalog.

...

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).

The list of available translators is configured by the TranslatorSource service.

Informal Parameters

...

Only components whose class is annotated with SupportsInformalParameters will support informal parameters.

...

The default binding prefix for informal parameters depends on where the parameter binding is specified. If the parameter is bound inside a Java class, within the Component annotation, then the default binding prefix is "prop:". If the parameter is bound inside the component template, then the default binding prefix is "literal:". This reflects the fact that a parameter specified in the Java class, using the annotation, is most likely a computed value, whereas a value in the template should simply be copied, as is, into the result HTML stream.

...

Only components which area annotated with SupportsInformalParameters may have informal parameters. Tapestry silently drops informal parameters that are specified for components that do not have this annotation.

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

...

In rare cases, you may want to compute the binding to be used as a parameter default. In this case, you will provide a default binding method, a method that takes no parameters. The returned value is used to bind the parameter. The return value may be a Binding instance, or it may be a simple value (which is more often the case).

...

In rare cases, you may want to take different behaviors based on whether a parameter is bound or not. This can be accomplished by querying the component's resources, which can be injected into the component using the Inject annotation:

Code Block
java
java
public class MyComponent
{
  @Parameter
  private int myParam;
  
  @Inject
  private ComponentResources resources;
  
  @BeginRender
  void setup()
  {
      if (resources.isBound("myParam"))
      {
        . . .
      }
  }
}

...

The Inject annotation will inject the ComponentResources for the component. These resources are the linkage between the Java class you provide, and the infrastructure Tapestry builds around your class. In any case, once the resources are injected, they can be queried.

...

In Tapestry 5.1, you may use the publishParameters attribute of the Component annotation. List one or more parameters separated by commas: those parameters of the inner/embedded component become parameters of the outer component. You should not define a parameter field in the outer component.

...