Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
/**
 * Context object available to the view components to provide access to
 * the view and instance attributes as well as run time information about
 * the current execution context.
 */
public interface ViewContext {

 /**
   * Save an instance data value for the given key.
   *
   * @param key    the key
   * @param value  the value
   *
   * @throws IllegalStateException if no instance is associated
   */
  public void putInstanceData(String key, String value);
  /**
   * Get the instance data value for the given key.
   *
   * @param key  the key
   *
   * @return the instance data value; null if no instance is associated
   */
  public String getInstanceData(String key);

}

Instance Configuration Properties

The instance configuration properties (set when you created your view instance) are accessible from the view context:

Code Block
viewContext.getProperties();

Configuration properties also supports a set of pre-defined variables that will be replaced when you read the property from the view context. For example, if your view requires a configuration parameter "hdfs.file.path" and that path is going to be set based on the username, when you configure the view instance, set the configuration property like so:

Code Block
"hdfs.file.path" : "/this/is/some/path/${username}"

When you get this property from the view context, the ${username} variable will be replaced automatically.

Code Block
viewContext.getProperties().get("hdfs.file.path") returns "/this/is/some/path/pramod"

Instance parameters support the following pre-defined variables: username, viewName and instanceName

Events

Events are an important component of the views framework. Events allow the view to interact with the framework on lifecycle changes (i.e. "framework events"). such as deploy, create and destroy. As well, once a user has collection of views available, eventing allows the views to communicate with other views (i.e. "view events").

...