Versions Compared

Key

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

...

This example defines a component of type TextField and mixes in the hypothetical Autocomplete and DefaultFromCookie mixins.

Ordering the Mixins

With @Mixins and @MixinClasses annotations, we can order the list of mixins, by adding a constraint.

Code Block
java
java

  @Component(parameters=. . .) @Mixins({"Autocomplete", "DefaultFromCookie::before:Autocomplete"})
  private TextField userId;
Code Block
java
java

  @Component(parameters=. . .) 
  @MixinClasses(value={Autocomplete.class, DefaultFromCookie.class}, order={"","before:AutoComplete"})
  private TextField userId;

You can specify many contraints for a mixin. You just need to separate them with a ";".

Implementation Mixins

Implementation mixins, mixins which apply to all instances of a component, are added using the @Mixin annotation. This annotation defines a field that will contain the mixin instance.

Code Block
java
java
public class AutocompleteField extendesextends TextField
{
  @Mixin
  private Autocomplete autocompleteMixin;
  
  . . .
}

...

Code Block
java
java
public class AutocompleteField extendesextends TextField
{
  @Mixin("Autocomplete")
  private Object autocompleteMixin;
  
  . . .
}

...