Class Places
java.lang.Object
org.jboss.elemento.router.Places
Represents a collection of places in an application. Each place is associated with a page supplier. Supports nested places
and loaders.
public static class EmptyPage implements Page {
@Override
public Iterable<HTMLElement> elements(Place place, Parameter parameter, LoadedData data) {
return emptyList();
}
}
public static class Application {
public void entryPoint() {
/*
The code builds the following places
/
/foo
/bar
/level1
/level1/foo
/level1/bar
/level1/level2/foo
/level1/level2/bar
*/
Places places = places()
.add(place("/"), EmptyPage::new)
.add(place("/foo"), EmptyPage::new)
.add(place("/bar"), EmptyPage::new)
.children("/level1", places()
.add(place("/"), EmptyPage::new)
.add(places() // add siblings!
.add(place("/foo"), EmptyPage::new)
.add(place("/bar"), EmptyPage::new))
.children("/level2", places()
.add(place("/foo"), EmptyPage::new)
.add(place("/bar"), EmptyPage::new)));
}
}
-
Method Summary
Modifier and TypeMethodDescriptionAdds a Place and the corresponding page supplier to the collection of places.Adds all the places from the given Places object to this places object.Adds the children places to the current collection of places.iterator()Assigns a given loader for a specific place.static Placesplaces()Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
places
-
iterator
-
add
-
add
-
children
Adds the children places to the current collection of places. Each child place is created by appending the child's route to the given parent path. The child places and their corresponding page suppliers are added to the current collection.- Parameters:
path- the parent path to append to the child routesplaces- the child places to add
-
loader
-