Class ServerValuesVar


public class ServerValuesVar extends DefaultingVar
The "$FV{name}" / "$FV{name,default}" server-values variable.

Resolves author-declared scalar values from a ServerValuesRegistry placed in the per-render session by the widget emitter. It is a DefaultingVar: "$FV{name}" resolves the named provider and "$FV{name,default}" falls back to default when the provider is missing or returns null.

Not $W. This var emits declared scalar values as plain text (the caller places the returned string into html5 beans and the serializer entity-encodes it). It is distinct from $W (org.apache.juneau.html.HtmlWidgetVar), which emits raw widget HTML. $FV never injects HTML.

allowRecurse() is false: a provider's returned string is emitted literally and is never re-parsed as SVL (untrusted computed data must not be recursively resolved). When no registry is present in the session the var is not resolvable and the "$FV{...}" token is left literal (fail-open).

Since:
10.0.0
  • Field Details

  • Constructor Details

  • Method Details

    • allowRecurse

      protected boolean allowRecurse()
      Description copied from class: Var
      Returns whether variables in the resolved contents of this variable should also be resolved.

      For example, if "$X{xxx}" resolves to "$Y{xxx}", then the $Y variable will be recursively resolved if this method returns true.

      The default implementation of this method always returns true.
      Subclasses can override this method to override the default behavior.

      As a general rule, variables that resolve user-entered data should not be recursively resolved as this may cause a security hole.
      Overrides:
      allowRecurse in class Var
      Returns:
      true if resolved variables should be recursively resolved.
    • canResolve

      protected boolean canResolve(VarResolverSession session)
      Description copied from class: Var
      Returns true if this variable can be resolved in the specified session.

      For example, some variable cannot resolve unless specific context or session objects are available.

      Overrides:
      canResolve in class Var
      Parameters:
      session - The current session.
      Returns:
      true if this variable can be resolved in the specified session.
    • resolve

      public String resolve(VarResolverSession session, String key)
      Description copied from class: Var
      The interface that needs to be implemented for subclasses of SimpleVar.
      Specified by:
      resolve in class Var
      Parameters:
      session - The session object used for a single instance of a var resolution.
      key - The inside argument of the variable.
      Returns:
      The resolved value.