All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.sitebricks.core.Repeat Maven / Gradle / Ivy

package com.google.sitebricks.core;

import java.util.Collection;

/**
 * 

* Repeats tagged content over a collection. This widget is the equivalent of a * closure being projected across the given collection. Where the closure is around * the content of the annotated tag (and any nested tags). Use attribute {@code var} * to specify the name of the variable each collection entry will be bound to. * For example, to create a list of movie titles: *

* *
 * <ul>
 *   {@code @Repeat}(items=movies, var="movie")
 *   <li>${movie.title} starring ${movie.star}</li>
 * </ul>
 * 
* *

* This dynamically produces a repetition of {@code <li>} tags containing the movie title * and star for each entry in a collection property {@code movies}. Repeat widgets only * work on items in a {@code java.util.Collection} (or subtype like {@code java.util.List}). * It does *not* take arrays. *

* *

* Since the items attribute takes the result of an expression, you can place any expression in * it that evaluates to a collection: *

* *
 * <ul>
 *   {@code @Repeat}(items=person.siblings, var="sib")
 *   <li>${sib.name}</li>
 * </ul>
 * 
* *

* This bit of code reads the siblings of a property {@code person} and binds it to a temporary * variable {@code sib} that when repeating the list elements. * * Of course, the repeat widget repeats *any* content inside it, so you are free to nest any * content you like inside, and they will be projected over the given collection: *

* *
 * <div>
 *   {@code @Repeat}(items=person.siblings, var="sib")
 *   <div>
 *      {@code @ShowIf}(sib.age > 1)
 *      <div>
 *          <p>${sib.name} is <b>${sib.age}</b> years old.</p>
 *      </div>
 *  </div>
 * </div>
 * 
* * *

* *

* * @author Dhanji R. Prasanna ([email protected]) */ @interface Repeat { /** * @instanceof java.util.Collection * @return Returns any subclass of collection to project across. */ Class items(); //not really a Class String var() default "__this"; String pageVar() default "__page"; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy