updated to 2.4.0

The @ZExpose annotation#

Use in classes annotated with @ZRenderer to make values available to your view template.

Also always a second value with suffix 'Bean' will be exposed that contains the original value.

You can annotate standard JavaBeans fields or getter methods with this annotation. The recommended pattern is to make your fields final and annotate them with @ZExpose.

Fields annotated this way will be made accessible (exposed) to the Renderer under the name of the corresponding JavaBeans property.

@ZExpose(render=true)#

Provides the ztemplates include mechanism when used with render=true.

If used as@ZExpose(render=true) object will be rendered and the rendered value (a String) will be exposed to the template.

@ZExpose(render=true) allows you to make the rendering process recursive.

The values can also be used in @ZScript using the ${varname} notation.

Default exposed values#

See default exposed values for the values exposed by the framework to the context without you having to use the @ZExpose annotation.

Examples#

render=false#

  //preferred
  @ZExpose
  private String name;
or
  //also allowed
  @ZExpose
  public String getName(){
     return "myName";
  }

Exposes

  • a property called "name" of type String with value String "myName"
  • a property called "nameBean" with value String "myName"

render=true#

  //preferred
  @ZExpose(render=true)
  private SomeOtherClass nested;
or
  //also allowed
  @ZExpose(render=true)
  public SomeOtherClass getNested(){
     return new SomeOtherClass();
  }  

Exposes

  • a property called "nested" of type String containing the rendered instance.
  • a property called "nestedBean" of type SomeOtherClass containing the instance.

List #

It is allowed to expose a List with @ZExpose(render=true). ztemplates will expose a list containing the rendered values from the List.
  @ZExpose(render=true)
  private List<MyClass> nestedList;

Exposes

  • a property called "nestedList" of type List<String> containing the rendered list elements.
  • a property called "nestedListBean" of type List<MyClass> containing the original list elements.

Neuen Anhang hinzuf�gen

Du bist nicht autorisiert, Anh�nge zu dieser Seite hochzuladen.
« Diese Seite (Version-) wurde zuletzt am 19-Dez-2011 09:29 von gerdziegler.de ge�ndert.