Class Apply

All Implemented Interfaces:
Serializable, Cloneable, Component, AfterCompose, DynamicPropertied, Scope, ShadowElement, ShadowElementCtrl, ComponentCtrl

public class Apply extends TemplateBasedShadowElement implements DynamicPropertied
The apply tag allows you to choose which template to be applied. You specify the template's name using the template attribute or the template's URI using the templateURI attribute.

Passing Parameters

There are two ways to pass parameters to the apply shadow:

First, you can use setDynamicProperty(java.lang.String, java.lang.Object), or, in ZUL,

<apply templateURI="/WEB-INF/mypage" arg="something"/>

Second, you can use the query string:

<apply templateURI="/WEB-INF/mypage?arg=something"/>

With the query string, you can pass only the String values. and the parameter can be accessed by Execution.getArg() Or, you can access it with the arg variable in EL expressions.

Since:
8.0.0
Author:
jumperchen
See Also:
  • Field Details

  • Constructor Details

    • Apply

      public Apply()
  • Method Details

    • getTemplate

      public String getTemplate()
      Returns the template name

      Default: empty string

    • setTemplate

      public void setTemplate(String template)
      Sets the template name to apply.

      One cannot set both template and template URI in the same time.

      Notice that, the template enclosed with <apply> tag will be created only when both template and template URI are not set.

    • setTemplateURI

      public void setTemplateURI(String templateURI)
      Sets the template uri.

      If templateURI is changed, the whole shadow is recreated. One cannot set both template and template URI in the same time.

      Notice that, the template enclosed with <apply> tag will be created only when both template and template URI are not set.

      Parameters:
      templateURI - the template URI. If null or empty, nothing is applied. You can specify the template URI with the query string and they will become a map of parameters that is accessible by the arg variable in EL, or by Execution.getArg(). For example, if "/a.zul?b=c" is specified, you can access the parameter with ${arg.b} in a.zul.
      See Also:
    • getTemplateURI

      public String getTemplateURI()
    • resolveTemplate

      protected Template resolveTemplate()
      Return the template, if any, the default implementation will look up the template where in its parent shadow or its shadow host.
      Returns:
      Template
    • resolveVariable

      public Object resolveVariable(Component child, String name, boolean recurse)
      Description copied from interface: ShadowElementCtrl
      Returns the variable associated with this base component or null if not found.

      Notice that it doesn't check any variable defined in VariableResolver (of Page.addVariableResolver(org.zkoss.xel.VariableResolver)).

      Specified by:
      resolveVariable in interface ShadowElementCtrl
      Overrides:
      resolveVariable in class HtmlShadowElement
      Parameters:
      child - the child component of the shadow host
      recurse - whether to look up the parent shadow for the existence of the variable.
      If recurse is true, it will look up all parents until found.
    • compose

      protected void compose(Component host)
      Composes from template name and then template uri, if any.
      Overrides:
      compose in class TemplateBasedShadowElement
      Parameters:
      host - the shadow host component, never null.
    • isEffective

      protected boolean isEffective()
      Description copied from class: HtmlShadowElement
      Returns whether the shadow element is effective
      Overrides:
      isEffective in class TemplateBasedShadowElement
    • hasDynamicProperty

      public boolean hasDynamicProperty(String name)
      Description copied from interface: DynamicPropertied
      Returns whether a dynamic property is defined.
      Specified by:
      hasDynamicProperty in interface DynamicPropertied
    • getDynamicProperty

      public Object getDynamicProperty(String name)
      Description copied from interface: DynamicPropertied
      Returns the property value of the specified name.
      Specified by:
      getDynamicProperty in interface DynamicPropertied
    • getDynamicProperties

      public Map<String,Object> getDynamicProperties()
      Description copied from interface: DynamicPropertied
      Returns all available dynamic properties.
      Specified by:
      getDynamicProperties in interface DynamicPropertied
    • setDynamicProperty

      public void setDynamicProperty(String name, Object value) throws WrongValueException
      Description copied from interface: DynamicPropertied
      Sets a property with the specified name and value.

      If a component supports only String-type values, it could use org.zkoss.lang.Objects.toString() to convert the value to a String instance.

      Specified by:
      setDynamicProperty in interface DynamicPropertied
      Throws:
      WrongValueException
    • getPropertyAccess

      public PropertyAccess getPropertyAccess(String prop)
      Description copied from interface: ComponentCtrl
      Returns the corresponding property access object from the given property name, if any.
      Specified by:
      getPropertyAccess in interface ComponentCtrl
      Overrides:
      getPropertyAccess in class AbstractComponent
      Parameters:
      prop - the name of the property
      Returns:
      null it means not to support for the property name.
    • clone

      public Object clone()
      Description copied from interface: Component
      Clones the component. All of its children and descendants are cloned. Also, ID are preserved.
      Specified by:
      clone in interface Component
      Overrides:
      clone in class TemplateBasedShadowElement
      Returns:
      the new component. Notice that it doesn't belong to any page, nor desktop. It doesn't have a parent, either.