List of usage examples for org.apache.wicket.util.template PackageTextTemplate PackageTextTemplate
public PackageTextTemplate(final Class<?> clazz, final String fileName, final String contentType, final String encoding)
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 . j a va 2 s . c o m*/ */ 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)); }