public class ScriptViewElement
extends com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
<script> element. A script tag may not be safely nested, using a ScriptViewElement will ensure that
any nested ScriptViewElement will get written after the original instead of inside it. In the original location a reference
node with all the same non-script-specific attributes will be written instead. A special attribute data-bum-ref-id will be added
holding the HTML id of the actual <script> that has been written in a valid location. Client-side you can use
BootstrapUiModule.refTarget(node) on a selector to ensure you transparently fetch the actual script node.
The replacement tag written inside the original script is by default an i element with explicit hidden styling. You can use a
different tag if necessary by setting it using setTagName(String).
If you really want to nest script elements, use a regular NodeViewElement instead.com.foreach.across.modules.web.ui.elements.HtmlViewElement.Functionscom.foreach.across.modules.web.ui.ViewElement.Wither<T extends com.foreach.across.modules.web.ui.ViewElement>, com.foreach.across.modules.web.ui.ViewElement.WitherGetter<T extends com.foreach.across.modules.web.ui.ViewElement,U>, com.foreach.across.modules.web.ui.ViewElement.WitherRemover<T extends com.foreach.across.modules.web.ui.ViewElement>, com.foreach.across.modules.web.ui.ViewElement.WitherSetter<T extends com.foreach.across.modules.web.ui.ViewElement>| Modifier and Type | Field and Description |
|---|---|
static String |
NO_REF_TAG
Value to set on
#setRefTagName(String) to avoid a reference tag from being written. |
| Constructor and Description |
|---|
ScriptViewElement() |
| Modifier and Type | Method and Description |
|---|---|
ScriptViewElement |
addAttributes(Map<String,Object> attributes) |
ScriptViewElement |
addChild(com.foreach.across.modules.web.ui.ViewElement element) |
ScriptViewElement |
addChildren(Collection<? extends com.foreach.across.modules.web.ui.ViewElement> elements) |
ScriptViewElement |
addCssClass(String... cssClass) |
ScriptViewElement |
addFirstChild(com.foreach.across.modules.web.ui.ViewElement element) |
ScriptViewElement |
apply(Consumer<com.foreach.across.modules.web.ui.elements.ContainerViewElement> consumer) |
<U extends com.foreach.across.modules.web.ui.ViewElement> |
applyUnsafe(Consumer<U> consumer) |
ScriptViewElement |
clearChildren() |
String |
getCharset() |
String |
getSource() |
org.springframework.http.MediaType |
getType() |
boolean |
isAsync() |
boolean |
isDefer() |
ScriptViewElement |
remove(com.foreach.across.modules.web.ui.ViewElement.WitherRemover... functions) |
ScriptViewElement |
removeAttribute(String attributeName) |
ScriptViewElement |
removeCssClass(String... cssClass) |
ScriptViewElement |
set(com.foreach.across.modules.web.ui.ViewElement.WitherSetter... setters) |
ScriptViewElement |
setAsync(boolean async)
Specifies that the script is executed asynchronously (only for external scripts).
|
ScriptViewElement |
setAttribute(String attributeName,
Object attributeValue) |
ScriptViewElement |
setAttributes(Map<String,Object> attributes) |
ScriptViewElement |
setCharset(String charset)
Specifies the character encoding used in an external script file.
|
ScriptViewElement |
setCustomTemplate(String customTemplate) |
ScriptViewElement |
setDefer(boolean defer)
Specifies that the script is executed when the page has finished parsing (only for external scripts).
|
protected ScriptViewElement |
setElementType(String elementType) |
ScriptViewElement |
setHtmlId(String htmlId) |
ScriptViewElement |
setName(String name) |
ScriptViewElement |
setSource(String src)
Specifies the URL of an external script file.
|
protected ScriptViewElement |
setTagName(String tagName) |
ScriptViewElement |
setType(@NonNull org.springframework.http.MediaType mediaType)
Set the script media type.
|
ScriptViewElement |
setType(String mediaType)
Set the script media type.
|
get, getAttribute, getAttribute, getAttributes, getHtmlId, getTagName, hasAttribute, hasCssClass, returnIfTypeelementStream, find, find, findAll, findAll, findAll, findOrSelf, findOrSelf, flatStream, getChildren, getCustomTemplate, getElementType, getName, hasChildren, removeAllFromTree, removeChild, removeFromTree, removeFromTreepublic static final String NO_REF_TAG
#setRefTagName(String) to avoid a reference tag from being written.public ScriptViewElement setSource(String src)
src - urlpublic String getSource()
public ScriptViewElement setCharset(String charset)
charset - encodingpublic String getCharset()
public ScriptViewElement setType(String mediaType)
mediaType - to setpublic ScriptViewElement setType(@NonNull @NonNull org.springframework.http.MediaType mediaType)
mediaType - to setpublic org.springframework.http.MediaType getType()
public ScriptViewElement setAsync(boolean async)
async - true if asyncpublic boolean isAsync()
public ScriptViewElement setDefer(boolean defer)
defer - true if script is deferredpublic boolean isDefer()
public ScriptViewElement addCssClass(String... cssClass)
addCssClass in interface com.foreach.across.modules.web.ui.elements.HtmlViewElementaddCssClass in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement removeCssClass(String... cssClass)
removeCssClass in interface com.foreach.across.modules.web.ui.elements.HtmlViewElementremoveCssClass in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement setAttributes(Map<String,Object> attributes)
setAttributes in interface com.foreach.across.modules.web.ui.elements.HtmlViewElementsetAttributes in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement setAttribute(String attributeName, Object attributeValue)
setAttribute in interface com.foreach.across.modules.web.ui.elements.HtmlViewElementsetAttribute in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement addAttributes(Map<String,Object> attributes)
addAttributes in interface com.foreach.across.modules.web.ui.elements.HtmlViewElementaddAttributes in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement removeAttribute(String attributeName)
removeAttribute in interface com.foreach.across.modules.web.ui.elements.HtmlViewElementremoveAttribute in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement setName(String name)
setName in interface com.foreach.across.modules.web.ui.MutableViewElementsetName in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement setCustomTemplate(String customTemplate)
setCustomTemplate in interface com.foreach.across.modules.web.ui.MutableViewElementsetCustomTemplate in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementprotected ScriptViewElement setElementType(String elementType)
setElementType in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement addChild(com.foreach.across.modules.web.ui.ViewElement element)
addChild in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement addChildren(Collection<? extends com.foreach.across.modules.web.ui.ViewElement> elements)
addChildren in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement addFirstChild(com.foreach.across.modules.web.ui.ViewElement element)
addFirstChild in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement clearChildren()
clearChildren in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement apply(Consumer<com.foreach.across.modules.web.ui.elements.ContainerViewElement> consumer)
apply in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic <U extends com.foreach.across.modules.web.ui.ViewElement> ScriptViewElement applyUnsafe(Consumer<U> consumer)
applyUnsafe in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementprotected ScriptViewElement setTagName(String tagName)
setTagName in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement setHtmlId(String htmlId)
setHtmlId in interface com.foreach.across.modules.web.ui.elements.HtmlViewElementsetHtmlId in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement set(com.foreach.across.modules.web.ui.ViewElement.WitherSetter... setters)
set in interface com.foreach.across.modules.web.ui.elements.HtmlViewElementset in interface com.foreach.across.modules.web.ui.MutableViewElementset in interface com.foreach.across.modules.web.ui.ViewElementset in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementpublic ScriptViewElement remove(com.foreach.across.modules.web.ui.ViewElement.WitherRemover... functions)
remove in interface com.foreach.across.modules.web.ui.elements.HtmlViewElementremove in interface com.foreach.across.modules.web.ui.MutableViewElementremove in interface com.foreach.across.modules.web.ui.ViewElementremove in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElementCopyright © 2020. All rights reserved.