Package org.zkoss.stateless.ui.util
Class Immutables
java.lang.Object
org.zkoss.stateless.ui.util.Immutables
An immutables utils.
- Author:
- jumperchen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends IComponent>
List<T>createComponents(String uri, Map<?, ?> arg) CreatesIComponents fromComponents that don't belong to any page from a page file specified by an URI.static <T extends IComponent>
List<T>createComponents(org.zkoss.zk.ui.metainfo.PageDefinition pagedef, Map<?, ?> arg) CreatesIComponents fromComponents that don't belong to any page from the specified page definition.static <T extends IComponent>
List<T>createComponentsDirectly(String content, String extension, Map<?, ?> arg) CreatesIComponents fromComponents that don't belong to any page from the raw content specified by a string.static <T extends IComponent>
IReplacer<T>newReplacer(T root) Constructs a replacer for replacing the descendant of the IComponent tree in a bulk execution for multiple replacements.static IComponentproxyIChild(org.zkoss.zk.ui.Component instance) static IComponentproxyIChild(org.zkoss.zk.ui.Component instance, Class<? extends org.zkoss.zk.ui.Component> skipClass) static List<? extends IComponent>proxyIChildren(org.zkoss.zk.ui.Component instance) static <T extends org.zkoss.zk.ui.Component,I extends IComponent>
IproxyIComponent(T t) Makes a proxy ofComponentintoIComponent.static <R extends IComponent,T extends IComponent>
RreplaceDescendant(R root, T source, T target) Replaces the descendant of the given root with the new child from the given source, if any.static <R extends IComponent,T extends IComponent>
RreplaceDescendantById(R root, String sourceId, CheckedFunction<T, T> targetFunction) Replaces the descendant of the given root with the new child from the given source, if any.static <R extends IComponent>
RreplaceDescendantById(R root, String sourceId, IComponent<?> target) Replaces the descendant of the given root with the new child from the given source, if any.
-
Constructor Details
-
Immutables
public Immutables()
-
-
Method Details
-
proxyIComponent
Makes a proxy ofComponentintoIComponent.- Parameters:
t- a ZKComponent- Returns:
- a proxy of
IComponent
-
proxyIChildren
-
proxyIChild
-
proxyIChild
public static IComponent proxyIChild(org.zkoss.zk.ui.Component instance, Class<? extends org.zkoss.zk.ui.Component> skipClass) -
createComponents
public static <T extends IComponent> List<T> createComponents(org.zkoss.zk.ui.metainfo.PageDefinition pagedef, Map<?, ?> arg) CreatesIComponents fromComponents that don't belong to any page from the specified page definition.- Parameters:
pagedef- the page definition to use. It cannot be null.arg- a map of parameters that is accessible by the arg variable in EL, or byExecution.getArg(). Ignored if null.- Returns:
- the first component being created.
- Since:
- 2.4.0
- See Also:
-
createComponents
CreatesIComponents fromComponents that don't belong to any page from a page file specified by an URI.It loads the page definition from the specified URI (by use
Execution.getPageDefinition(java.lang.String)), and then invokescreateComponents(PageDefinition,Map)to create components.- Parameters:
arg- a map of parameters that is accessible by the arg variable in EL, or byExecution.getArg(). Ignored if null.- See Also:
-
createComponentsDirectly
public static <T extends IComponent> List<T> createComponentsDirectly(String content, String extension, Map<?, ?> arg) CreatesIComponents fromComponents that don't belong to any page from the raw content specified by a string.The raw content is parsed to a page definition by use of
Execution.getPageDefinitionDirectly(String, String), and then invokescreateComponents(PageDefinition,Map)to create components.- Parameters:
content- the raw content of the page. It must be in ZUML.extension- the default extension if the content doesn't specify an language. In other words, if the content doesn't specify an language,LanguageDefinition.getByExtension(java.lang.String)is called. If extension is null and the content doesn't specify a language, the language called "xul/html" is assumed.arg- a map of parameters that is accessible by the arg variable in EL, or byExecution.getArg(). Ignored if null.- See Also:
-
newReplacer
Constructs a replacer for replacing the descendant of the IComponent tree in a bulk execution for multiple replacements. By default, the implementation uses BFS algorithm to traverse the whole tree to seek the replacement target.- Parameters:
root- The root IComponent tree.- Returns:
- A replacer implementation of
IReplacer
-
replaceDescendant
public static <R extends IComponent,T extends IComponent> R replaceDescendant(R root, T source, T target) Replaces the descendant of the given root with the new child from the given source, if any.- Parameters:
root- The root IComponent tree.source- The replaced source.target- The replaced target.- Returns:
- The new IComponent tree.
-
replaceDescendantById
public static <R extends IComponent> R replaceDescendantById(R root, String sourceId, IComponent<?> target) Replaces the descendant of the given root with the new child from the given source, if any.- Parameters:
root- The root IComponent tree.sourceId- The id of the replaced source.target- The replaced target.- Returns:
- The new IComponent tree.
-
replaceDescendantById
public static <R extends IComponent,T extends IComponent> R replaceDescendantById(R root, String sourceId, CheckedFunction<T, T> targetFunction) Replaces the descendant of the given root with the new child from the given source, if any.- Parameters:
root- The root IComponent tree.sourceId- The id of the replaced source.targetFunction- The replacement function by passing the result of the source and returning the new replacement. If null, it means to remove the replaced source.- Returns:
- The new IComponent tree.
-