* Gets the {@link IScript}for the correct script.
*/
private IScript getParsedScript()
{
IAsset scriptAsset = getScriptAsset();
String scriptPath = getScriptPath();
// only one of the two is allowed
if (scriptAsset != null && scriptPath != null)
throw new ApplicationRuntimeException(HTMLMessages
.multiAssetParameterError(getBinding("scriptAsset"),
getBinding("scriptPath")));
if (scriptPath == null && scriptAsset == null)
throw new ApplicationRuntimeException(HTMLMessages
.noScriptPathError());
IScriptSource source = getScriptSource();
Resource scriptLocation = null;
if (scriptPath != null)
{
// If the script path is relative, it should be relative to the
// Script component's
// container (i.e., relative to a page in the application).
Resource rootLocation = getContainer().getSpecification()
.getSpecificationLocation();
scriptLocation = rootLocation.getRelativeResource(scriptPath);
}
else scriptLocation = scriptAsset.getResourceLocation();
try
{
return source.getScript(scriptLocation);
}