that the script will change the content of -> target
WebElement webElement;
String jQueryImports = jQueryLibraries.stringValue();
if (!jQueryImports.trim().equals("")) {
//Create WebElement for jQueryLibraries and add the exporter.
//content should only be added once(true)
webElement = WebElement.createWebElement(getContainer(),
"jQueryLibraries", "jQueryLibraries");
webElement.setParent(WebElement.HEAD);
webElement.setExpression(jQueryImports);
exporter.defineElement(webElement, true);
}
String scriptValue;
// Check whether the user wants to insert the evaluated expression
// or the exact text for the script
if (evaluateScript.getToken().isEqualTo(BooleanToken.TRUE)
.booleanValue()) {
scriptValue = script.stringValue();
} else {
scriptValue = script.getExpression();
}
if (!scriptValue.trim().equals("")) {
// Create WebElement for script and add to exporter.
// Content should only be added once (onceOnly -> true).
webElement = WebElement.createWebElement(getContainer(), "script",
"script");
webElement.setParent(WebElement.HEAD);
webElement.setExpression("\n");
exporter.defineElement(webElement, true);
}
String startTextValue = startText.stringValue();
if (!startTextValue.trim().equals("")) {
// Create WebElement for start text and add to exporter.
// Content should only be added once (onceOnly -> true).
webElement = WebElement.createWebElement(getContainer(),
"startText", "startText");
webElement.setParent(WebElement.START);
webElement.setExpression(startTextValue);
exporter.defineElement(webElement, true);
}
String endTextValue = endText.stringValue();
if (!endTextValue.trim().equals("")) {
// Create WebElement for end text and add to exporter.
// Content should only be added once (onceOnly -> true).
webElement = WebElement.createWebElement(getContainer(), "endText",
"endText");
webElement.setParent(WebElement.END);
webElement.setExpression(endTextValue);
exporter.defineElement(webElement, true);
}
}
/** Provide method call to invoke script that can be included as an
* attribute of an HTML tag, e.g. onclick="runFunction()" in
* <button onclick="runFunction()"/>
*
* @param exporter The web exporter to which to write content.
* @exception IllegalActionException If the eventType cannot be obtained,
* the web attribute cannot be created or set.
*/
@Override
protected void _provideAttributes(WebExporter exporter)
throws IllegalActionException {
// FIXME: Support multiple events in the future. E.g. onclick() and
// ontap() might call the same Javascript method.
WebAttribute webAttribute;
NamedObj container = getContainer();
if (container != null) {
String eventTypeValue = eventType.stringValue();
if (!eventTypeValue.trim().equals("")) {
// Create WebAttribute for event and add to exporter.
// Content should only be added once (onceOnly -> true).
webAttribute = WebAttribute.createWebAttribute(getContainer(),
eventTypeValue + "WebAttribute", eventTypeValue);
webAttribute.setExpression(stringValue());
exporter.defineAttribute(webAttribute, true);
}
}
}
}