Class WTemplate.Functions

java.lang.Object
eu.webtoolkit.jwt.WTemplate.Functions
Enclosing class:
WTemplate

public static class WTemplate.Functions
extends java.lang.Object
A collection of predefined functions.

See Also:
WTemplate.addFunction(String name, WTemplate.Function function)
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static WTemplate.Function block
    A function that renders a macro block.
    static WTemplate.Function id
    A function that resolves the id of a bound widget.
    static WTemplate.Function tr
    A function that resolves to a localized string.
    static WTemplate.Function while_f
    A function that renders a macro block as long as the given condition is true.
  • Constructor Summary

    Constructors 
    Constructor Description
    Functions()  
  • Method Summary

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • tr

      public static final WTemplate.Function tr
      A function that resolves to a localized string.

      For example, when bound to the function "tr", template that contains the placeholder

      
       ... ${tr:name} ...
      
       
      will be resolved to the value of:
      
       WString::tr("name")
      
       

      See Also:
      WTemplate.addFunction(String name, WTemplate.Function function)
    • block

      public static final WTemplate.Function block
      A function that renders a macro block.

      The function will consider the first argument as the key for a localized string that is a macro block, and additional arguments as positional parameters in that block.

      For example, a template that contains:

      
       ...
       ${block:form-field category}
       ...
      
       

      would look-up the following message:

      
       <message id="form-field">
       <div class="control-group">
       ${{1}-info}
       </div>
       </message>
      
       

      and render as:

      
       ...
       <div class="control-group">
       ${category-info}
       </div>
       ...
      
       
    • while_f

      public static final WTemplate.Function while_f
      A function that renders a macro block as long as the given condition is true.

      The function will consider the first argument as the condition, and the second argument as the key for a localized string that is a macro block.

      Just like the block function, you can provide additional arguments, so the third argument will be what is filled in into {1} in the macro block, etc.

    • id

      public static final WTemplate.Function id
      A function that resolves the id of a bound widget.

      For example, when bound to the function "id", template text that contains a place-holder

      
       ... ${id:name} ...
      
       

      will be resolved to the value of:

      
       t.resolveWidget("name").id()
      
       

      This is useful for binding labels to input elements.

      See Also:
      WTemplate.addFunction(String name, WTemplate.Function function)
  • Constructor Details