Example usage for org.apache.wicket.util.template TextTemplate getString

List of usage examples for org.apache.wicket.util.template TextTemplate getString

Introduction

In this page you can find the example usage for org.apache.wicket.util.template TextTemplate getString.

Prototype

@Override
public abstract String getString();

Source Link

Document

Retrieves the String resource.

Usage

From source file:fiftyfive.wicket.js.DomReadyTemplate.java

License:Apache License

/**
 * Loads the JavaScript template, determines its dependencies, and then
 * uses PropertyVariableInterpolator to perform variable substitutions.
 * The results are cached in member variables that will be cleared when
 * detach() is called./*w w  w .  jav a  2 s  .com*/
 */
private void load(Component comp) {
    JavaScriptDependencyLocator locator = settings().getLocator();
    this.dependencies = new DependencyCollection();
    locator.findAssociatedScripts(this.templateLocation, this.dependencies);

    this.template = this.dependencies.getRootReference();
    if (null == this.template) {
        throw new WicketRuntimeException(
                String.format("Failed to locate JavaScript template for %s. The JavaScript file must be "
                        + "the same name as the class but with a '.js' extension and be present in "
                        + "the same classpath location.", this.templateLocation));
    }

    TextTemplate tt = new PackageTextTemplate(this.template.getScope(), this.template.getName(),
            "application/javascript", settings().getEncoding());

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("component", comp);
    map.put("behavior", this);

    this.readyScript = getCompressor().compress(PropertyVariableInterpolator.interpolate(tt.getString(), map));
}